feat(linter): deprecate ESLint v8 support#35819
Conversation
✅ Deploy Preview for nx-dev ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for nx-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
View your CI Pipeline Execution ↗ for commit 11a24c8
☁️ Nx Cloud last updated this comment at |
There was a problem hiding this comment.
Important
At least one additional CI pipeline execution has run since the conclusion below was written and it may no longer be applicable.
Nx Cloud is proposing a fix for your failed CI:
We updated the snapshot for @nx/eslint:workspace-rules-project should generate the required files 4 to include "isolatedModules": true in the generated tsconfig.spec.json compiler options. This fix aligns the snapshot with the intentional generator change from the fix(linter): generate workspace-rules-project tsconfig.spec.json with isolatedModules commit. Without this update, the test fails on a snapshot mismatch even though the generated output is correct.
Note
⏳ We are verifying this fix by re-running a subset of the 2 failed tasks that were analyzed.
diff --git a/packages/eslint/src/generators/workspace-rules-project/__snapshots__/workspace-rules-project.spec.ts.snap b/packages/eslint/src/generators/workspace-rules-project/__snapshots__/workspace-rules-project.spec.ts.snap
index fb771952..4bc20e65 100644
--- a/packages/eslint/src/generators/workspace-rules-project/__snapshots__/workspace-rules-project.spec.ts.snap
+++ b/packages/eslint/src/generators/workspace-rules-project/__snapshots__/workspace-rules-project.spec.ts.snap
@@ -70,7 +70,8 @@ exports[`@nx/eslint:workspace-rules-project should generate the required files 4
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc",
- "types": ["jest", "node"]
+ "types": ["jest", "node"],
+ "isolatedModules": true
},
"include": [
"jest.config.ts",
Or Apply changes locally with:
npx nx-cloud apply-locally 28PZ-kTWD
Apply fix locally with your editor ↗ View interactive diff ↗
🎓 Learn more about Self-Healing CI on nx.dev
…emoved in Nx v24 Add a shared warning for ESLint v8 users emitted at both generator entry (via `assertSupportedEslintVersion`, which is the choke point for the init / lint-project / workspace-rule(s) / convert-to-flat-config / convert-to-inferred generators) and lint-executor entry. v8 stays fully supported until v24 — this is a soft deprecation only.
…+ eslintrc workspaces ESLint v9 dropped the eslintrc-style `RuleTester` class, so the generated `.spec.ts` template's `TSESLint.RuleTester` (which extends `eslint.RuleTester`) breaks on v9 even when running in eslintrc mode. Switch the generator to emit the flat-style `@typescript-eslint/rule-tester` template whenever the workspace ends up on ESLint v9+ regardless of the config-file shape, and install `@typescript-eslint/rule-tester` on that path. v8 + eslintrc workspaces continue to use the existing `TSESLint.RuleTester` template unchanged.
…hapes Fresh installs (no `eslint` declared) now always pull ESLint v9 regardless of the user's flat-config preference. The eslintrc-shape config files generated when `useFlatConfig(tree)` is false are still honored — v9 loads them through `LegacyESLint` — only the installed package versions move forward. Existing v8 workspaces are untouched because their declared major still routes through `versionMap[8]`.
…emplate change The snapshots were captured against the eslintrc-style template and became stale once the generator started emitting the flat-style `@typescript-eslint/rule-tester` template for fresh installs (which now default to ESLint v9).
…test template across ESLint majors `TSESLint.RuleTester` (from `@typescript-eslint/utils`, already installed by `lintWorkspaceRulesProjectGenerator`) just extends `eslint.RuleTester`, so its accepted constructor shape follows the installed ESLint major. The eslintrc rule-test template now branches on `eslintMajor` to emit eslintrc-style args for v8 and flat-style args for v9, while `@typescript-eslint/rule-tester` stays scoped to flat-config workspaces. This avoids requiring v9 + eslintrc workspaces to install an extra dependency.
… isolatedModules `@typescript-eslint/rule-tester` only exposes its API through an `exports` map (no `main`). Without `isolatedModules: true`, the `module: node16` setting inherited from the project's base `tsconfig.json` triggers ts-jest's TS151002 warning and the generated `.spec.ts` fails to resolve `@typescript-eslint/rule-tester`. Setting `isolatedModules: true` (matching the repo's own `tools/eslint-rules` configuration) ensures the package resolves reliably. Also restores the workspace-rule template's `@typescript-eslint/rule-tester` import for any ESLint v9+ workspace (flat or eslintrc) — typescript-eslint's recommended replacement for the eslintrc-style `RuleTester` API that v9 dropped — instead of relying on `TSESLint.RuleTester`, whose `@typescript-eslint/utils@^8` type definitions are still locked to the eslintrc constructor shape and reject flat-style args at type-check time.
…g.spec.json isolatedModules Follow-up to 069cf30 which added `isolatedModules: true` to the generated tsconfig.spec.json. Snapshot entry 4 was not refreshed.
## Current Behavior The `@nx/eslint` package supports ESLint v8 as a first-class citizen. Fresh installs without flat config get ESLint v8 + typescript-eslint v8, and there is no signal to users that this support is going away. In addition, workspaces that end up on ESLint v9 with eslintrc-style config get a broken `workspace-rule` rule-test template. ESLint v9 dropped the eslintrc-style `RuleTester` class, but the generator emits `TSESLint.RuleTester` (which extends `eslint.RuleTester`) regardless of the installed major. v9 + eslintrc users currently can't run the generated `.spec.ts` without manual edits. ## Expected Behavior - ESLint v8 support is soft-deprecated. `@nx/eslint` generators (via `assertSupportedEslintVersion`) and the `@nx/eslint:lint` executor emit a deprecation warning on every invocation when the workspace's installed ESLint major is 8. v8 keeps working unchanged; hard removal is scheduled for Nx v24. - Fresh installs always pull the latest supported ESLint stack (v9 + typescript-eslint v8) regardless of the user's flat-config preference. The eslintrc config-file shape is still honored at the file level (ESLint v9 loads eslintrc files through `LegacyESLint`); only the installed package versions move forward. - The `workspace-rule` generator emits the flat-style `@typescript-eslint/rule-tester` template (and installs that dep) for any workspace ending up on ESLint v9+, not just flat-config ones. v8 + eslintrc workspaces continue to use the existing `TSESLint.RuleTester` template unchanged. ## Implementation Details - New `warnEslintV8Deprecation()` in `packages/eslint/src/utils/deprecation.ts`, fired from `assertSupportedEslintVersion` (choke point for the `init`, `lint-project`, `workspace-rule`, `workspace-rules-project`, `convert-to-flat-config`, and `convert-to-inferred` generators) and the lint executor. - The `workspace-rule` generator now gates the rule-test template on `useFlatRuleTester = flatConfig || effectiveEslintMajor >= 9`, derived from `versions(tree).eslintVersion` so it covers both declared workspaces and fresh installs. - `versions(tree)` no longer consults `useFlatConfig` for the fresh-install branch; both lanes return `latestVersions`. `minSupportedEslintVersion` stays at `'8.0.0'` and `versionMap[8]` stays in place so existing v8 workspaces keep getting a coherent stack until v24 removes them. <!-- polygraph-session-start --> --- [View session information ↗](https://snapshot.app.trypolygraph.com/orgs/69cdc268b6aa527e4129c2b4/sessions/nxc-3986-ac90716f) <!-- polygraph-session-end --> --------- Co-authored-by: Leosvel Pérez Espinosa <leosvel.perez.espinosa@gmail.com>
Current Behavior
The
@nx/eslintpackage supports ESLint v8 as a first-class citizen. Fresh installs without flat config get ESLint v8 + typescript-eslint v8, and there is no signal to users that this support is going away.In addition, workspaces that end up on ESLint v9 with eslintrc-style config get a broken
workspace-rulerule-test template. ESLint v9 dropped the eslintrc-styleRuleTesterclass, but the generator emitsTSESLint.RuleTester(which extendseslint.RuleTester) regardless of the installed major. v9 + eslintrc users currently can't run the generated.spec.tswithout manual edits.Expected Behavior
@nx/eslintgenerators (viaassertSupportedEslintVersion) and the@nx/eslint:lintexecutor emit a deprecation warning on every invocation when the workspace's installed ESLint major is 8. v8 keeps working unchanged; hard removal is scheduled for Nx v24.LegacyESLint); only the installed package versions move forward.workspace-rulegenerator emits the flat-style@typescript-eslint/rule-testertemplate (and installs that dep) for any workspace ending up on ESLint v9+, not just flat-config ones. v8 + eslintrc workspaces continue to use the existingTSESLint.RuleTestertemplate unchanged.Implementation Details
warnEslintV8Deprecation()inpackages/eslint/src/utils/deprecation.ts, fired fromassertSupportedEslintVersion(choke point for theinit,lint-project,workspace-rule,workspace-rules-project,convert-to-flat-config, andconvert-to-inferredgenerators) and the lint executor.workspace-rulegenerator now gates the rule-test template onuseFlatRuleTester = flatConfig || effectiveEslintMajor >= 9, derived fromversions(tree).eslintVersionso it covers both declared workspaces and fresh installs.versions(tree)no longer consultsuseFlatConfigfor the fresh-install branch; both lanes returnlatestVersions.minSupportedEslintVersionstays at'8.0.0'andversionMap[8]stays in place so existing v8 workspaces keep getting a coherent stack until v24 removes them.View session information ↗