Skip to content

An open source design system that's fully customizable and agent ready

TypeScript

chore(lint): make .gitignore the source of truth for lint ignores (#4919)

nynexman4464d31557bd327e
diff --git a/eslint.config.js b/eslint.config.js
index ed3dcd0288..fdeeff8615 100644
--- a/eslint.config.js
+++ b/eslint.config.js
@@ -1,6 +1,8 @@
// Copyright (c) Meta Platforms, Inc. and affiliates.
import { defineConfig } from "eslint/config";
+import { includeIgnoreFile } from "@eslint/compat";
+import path from "node:path";
import js from "@eslint/js";
import tseslint from "typescript-eslint";
import eslintReact from "@eslint-react/eslint-plugin";
@@ -33,6 +35,38 @@ const astryxEslintPlugin = /** @type {import('eslint').ESLint.Plugin} */ (
/** @type {unknown} */ (astryxPlugin)
);
+/**
+ * Reuse a `.gitignore` as lint ignores, so generated and vendored files are
+ * never linted. Without this, anything git ignores but that exists on disk
+ * gets linted the moment you generate it — e.g. `apps/docsite/public/monaco`
+ * (25MB of minified Monaco + the TS compiler, copied in by
+ * `scripts/copy-vendor.mjs`) produced ~23.5k errors for anyone who had run
+ * the docsite. CI never saw it: it lints a fresh checkout, where the
+ * generated files don't exist yet.
+ *
+ * Patterns in a nested `.gitignore` are relative to that file, so each one
+ * needs its directory as `basePath`.
+ */
+const gitignoreDirs = [
+ "apps/docsite",
+ "apps/sandbox",
+ "apps/template-viewer",
+ "internal/vibe-tests",
+ "packages/build",
+ "packages/cli",
+];
+
+const gitignores = [
+ includeIgnoreFile(path.join(import.meta.dirname, ".gitignore"), "root .gitignore"),
+ ...gitignoreDirs.map((dir) => ({
+ basePath: dir,
+ ...includeIgnoreFile(
+ path.join(import.meta.dirname, dir, ".gitignore"),
+ `${dir}/.gitignore`,
+ ),
+ })),
+];
+
// typescript-eslint ≥8.62 types its presets with loose cross-version
// "compatibility" shapes (`CompatibleConfig` = `{name?, rules?: object}`);
// normalize back to ESLint's own config type for `defineConfig`.
@@ -43,10 +77,10 @@ const tseslintRecommended = /** @type {import('eslint').Linter.Config[]} */ (
export default defineConfig(
js.configs.recommended,
tseslintRecommended,
+ ...gitignores,
{
ignores: [
- "**/dist/**",
- "**/node_modules/**",
+ // dist/** and node_modules/** come from the .gitignore imports above.
".claude/**",
"**/internal/eslint-plugin-astryx/**",
".github/scripts/**",
diff --git a/package.json b/package.json
index ebdfd6a79a..755901490d 100644
--- a/package.json
+++ b/package.json
@@ -46,6 +46,7 @@
"@axe-core/playwright": "^4.12.1",
"@changesets/cli": "^2.31.0",
"@eslint-react/eslint-plugin": "^5.10.4",
+ "@eslint/compat": "^2.1.0",
"@eslint/js": "^10.0.1",
"@playwright/test": "^1.61.1",
"@testing-library/user-event": "^14.5.0",
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 9bec57b073..13e397ef4b 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -44,6 +44,9 @@ importers:
'@eslint-react/eslint-plugin':
specifier: ^5.10.4
+ '@eslint/compat':
+ specifier: ^2.1.0
'@eslint/js':
specifier: ^10.0.1
@@ -1546,6 +1549,15 @@ packages:
eslint: '*'
typescript: '*'
+ '@eslint/[email protected]':
+ resolution: {integrity: sha512-LgaSCymEpw7tF53xvDw9SNsraPb1IBHxpdABIOM0hW8UAlP8znrjYtuxfR58FSJ3L9BhwD+FaPRFQpZq84Nh6g==}
+ engines: {node: ^20.19.0 || ^22.13.0 || >=24}
+ peerDependencies:
+ eslint: ^8.40 || 9 || 10
+ peerDependenciesMeta:
+ eslint:
+ optional: true
+
'@eslint/[email protected]':
resolution: {integrity: sha512-Y3kKLvC1dvTOT+oGlqNQ1XLqK6D1HU2YXPc52NmAlJZbMMWDzGYXMiPRJ8TYD39muD/OTjlZmNJ4ib7dvSrMBA==}
engines: {node: ^20.19.0 || ^22.13.0 || >=24}
@@ -7090,6 +7102,12 @@ snapshots:
transitivePeerDependencies:
- supports-color
+ dependencies:
+ '@eslint/core': 1.2.1
+ optionalDependencies:
+ eslint: 10.6.0([email protected])
+
'@eslint/[email protected]':
dependencies:
'@eslint/object-schema': 3.0.5