Skip to content

Commit 4bbd4b1

Browse files
authored
chore(repo): migrate nx repo to eslint v9 flat config (#35359)
## Current Behavior The nx repo uses the legacy eslintrc format (`.eslintrc.json`, `.eslintignore`) with ESLint v8 and outdated plugin versions. Several of those plugins ship code that crashes under ESLint v9 (`context.getScope` removed, etc.), and the `@nx/eslint` / `@nx/eslint-plugin` sources still reference APIs removed in v9 (`Linter.defineParser`, `Linter.defineRule`, classic `Linter.Config` shape). ## Expected Behavior Every project in the repo uses an `eslint.config.mjs` flat config, the ESLint ecosystem is on the latest v9-compatible versions, and `@nx/eslint` / `@nx/eslint-plugin` sources compile and test cleanly against the v9 type split. ### Main changes - Replaced every `.eslintrc.json` / `.eslintignore` with an `eslint.config.mjs`. - Rewrote the root `eslint.config.mjs`: - Exports a named `baseConfig` that leaf configs import, plus a default export that opts out of linting (`**/*` ignored) so the root acts as a shared base and isn't lint-checked directly. - Drops `FlatCompat` in favor of native plugin imports. - Exports shared `reactHooksV7Off`, `e2eTestOnlyIgnores`, and a `storybookConfigs` wrapper that filters v10's preset down to `storybook/*` rules (the preset references foreign rules like `import-x/*` that we don't register). - Cleaned up leaf configs emitted by the generator: deduplicated file entries, merged split `package.json` blocks, fixed the jsonc parser namespace import after v3 dropped its default export. - Scoped the 15 e2e projects to `*.test.ts` files only via a shared export. - Bumped the ESLint ecosystem to the latest v9-compatible versions: `eslint@^9.39.4`, `@eslint/js@^9.39.4`, `@typescript-eslint/*@^8.58.2`, `eslint-plugin-storybook@^10.3.5`, `eslint-plugin-react-hooks@^7.1.0`, `eslint-plugin-jsx-a11y@^6.10.2`, `eslint-plugin-import@^2.32.0`, `eslint-plugin-playwright@^2.10.1`, `eslint-plugin-cypress@^6.3.1`, `eslint-plugin-jest@^29.15.2`, `toml-eslint-parser@^1.0.3`, `jsonc-eslint-parser@^3.1.0`, `angular-eslint@^21.3.1`. Dropped `@eslint/eslintrc`, `@types/eslint`, `@types/eslint__js`. - Aligned `@nx/eslint` source with the v9 type split: `Linter.Config` → `Linter.LegacyConfig`, `ESLint.Options` → `ESLint.LegacyOptions` wherever the underlying shape is eslintrc. - Rewrote `@nx/eslint-plugin` rule specs (`dependency-checks`, `enforce-module-boundaries`) as flat-config inline tests since `Linter.defineParser`/`defineRule` were removed in v9. - Aligned react/angular/expo/react-native add-linting helpers with the v9 type split. - Migrated `tools/eslint-rules` specs from `TSESLint.RuleTester` (legacy config, rejected by v9's flat Linter) to `@typescript-eslint/rule-tester`; added `isolatedModules: true` so ts-jest resolves the new types under `module: node16`. - Downgraded the new react-hooks v7 rules to `off` via a shared export so the migration doesn't require rewriting legacy code. - Auto-fixed unused eslint-disable directives (`linterOptions.reportUnusedDisableDirectives` defaults to warn in v9). - Ignored `packages/workspace/**/__fixtures__/**` in lint and updated the affected snapshot so the fixture matches what the jest generator templates actually emit. ### Note on ESLint v10 This PR stays on ESLint v9. A few plugins we rely on (`eslint-plugin-import`, `eslint-plugin-jsx-a11y`, `eslint-plugin-react`) still don't declare v10 peer support. The jump to v10 will happen in a follow-up PR once those plugins publish v10-compatible releases.
1 parent 1507788 commit 4bbd4b1

319 files changed

Lines changed: 3813 additions & 4206 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.eslintignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

.eslintrc.json

Lines changed: 0 additions & 118 deletions
This file was deleted.

astro-docs/.eslintignore

Lines changed: 0 additions & 6 deletions
This file was deleted.

astro-docs/.eslintrc.json

Lines changed: 0 additions & 28 deletions
This file was deleted.

astro-docs/eslint.config.mjs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { baseConfig } from '../eslint.config.mjs';
2+
import playwright from 'eslint-plugin-playwright';
3+
4+
export default [
5+
...baseConfig,
6+
playwright.configs['flat/recommended'],
7+
{
8+
files: ['**/*.spec.ts', '**/*.test.ts', '**/*.spec.js', '**/*.test.js'],
9+
rules: {
10+
'playwright/no-standalone-expect': 'off',
11+
},
12+
},
13+
{
14+
ignores: [
15+
'node_modules/',
16+
'dist/',
17+
'.astro/',
18+
'.netlify/',
19+
'test-output/',
20+
'playwright-report/',
21+
],
22+
},
23+
];

e2e/angular/.eslintrc.json

Lines changed: 0 additions & 17 deletions
This file was deleted.

e2e/angular/eslint.config.mjs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import { baseConfig, e2eTestOnlyIgnores } from '../../eslint.config.mjs';
2+
3+
export default [...baseConfig, e2eTestOnlyIgnores];

e2e/cypress/.eslintrc.json

Lines changed: 0 additions & 17 deletions
This file was deleted.

e2e/cypress/eslint.config.mjs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import { baseConfig, e2eTestOnlyIgnores } from '../../eslint.config.mjs';
2+
3+
export default [...baseConfig, e2eTestOnlyIgnores];

e2e/expo/.eslintrc.json

Lines changed: 0 additions & 17 deletions
This file was deleted.

0 commit comments

Comments
 (0)