@nx/eslint 23.0.0-beta.21 → 23.0.0-beta.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/executors/lint/lint.impl.js +5 -0
- package/dist/src/generators/convert-to-inferred/convert-to-inferred.js +1 -1
- package/dist/src/generators/init/init.js +2 -2
- package/dist/src/generators/workspace-rule/files/__name__.spec.ts__tmpl__ +1 -1
- package/dist/src/generators/workspace-rule/workspace-rule.js +12 -3
- package/dist/src/generators/workspace-rules-project/workspace-rules-project.js +7 -0
- package/dist/src/plugins/plugin.d.ts +3 -3
- package/dist/src/utils/assert-supported-eslint-version.js +4 -0
- package/dist/src/utils/deprecation.d.ts +2 -0
- package/dist/src/utils/deprecation.js +11 -1
- package/dist/src/utils/versions.js +5 -6
- package/migrations.json +4 -2
- package/package.json +5 -5
|
@@ -6,6 +6,7 @@ const internal_1 = require("@nx/devkit/internal");
|
|
|
6
6
|
const fs_1 = require("fs");
|
|
7
7
|
const utils_1 = require("nx/src/tasks-runner/utils");
|
|
8
8
|
const path_1 = require("path");
|
|
9
|
+
const semver_1 = require("semver");
|
|
9
10
|
const config_file_1 = require("../../utils/config-file");
|
|
10
11
|
const deprecation_1 = require("../../utils/deprecation");
|
|
11
12
|
const versions_1 = require("../../utils/versions");
|
|
@@ -47,6 +48,10 @@ async function run(options, context) {
|
|
|
47
48
|
: undefined;
|
|
48
49
|
const { eslint, ESLint } = await (0, eslint_utils_1.resolveAndInstantiateESLint)(eslintConfigPath, normalizedOptions, hasFlatConfig);
|
|
49
50
|
(0, internal_1.assertSupportedInstalledPackageVersion)('eslint', versions_1.minSupportedEslintVersion);
|
|
51
|
+
const installedEslintVersion = (0, internal_1.getInstalledPackageVersion)('eslint');
|
|
52
|
+
if (installedEslintVersion && (0, semver_1.major)(installedEslintVersion) === 8) {
|
|
53
|
+
(0, deprecation_1.warnEslintV8Deprecation)();
|
|
54
|
+
}
|
|
50
55
|
if (printConfig) {
|
|
51
56
|
try {
|
|
52
57
|
const fileConfig = await eslint.calculateConfigForFile(printConfig);
|
|
@@ -12,7 +12,7 @@ const target_options_map_1 = require("./lib/target-options-map");
|
|
|
12
12
|
async function convertToInferred(tree, options) {
|
|
13
13
|
(0, assert_supported_eslint_version_1.assertSupportedEslintVersion)(tree);
|
|
14
14
|
const projectGraph = await (0, devkit_1.createProjectGraphAsync)();
|
|
15
|
-
const migratedProjects = await (0, internal_1.migrateProjectExecutorsToPlugin)(tree, projectGraph, '@nx/eslint/plugin', plugin_1.
|
|
15
|
+
const migratedProjects = await (0, internal_1.migrateProjectExecutorsToPlugin)(tree, projectGraph, '@nx/eslint/plugin', plugin_1.createNodes, { targetName: 'lint' }, [
|
|
16
16
|
{
|
|
17
17
|
executors: ['@nx/eslint:lint', '@nrwl/linter:eslint'],
|
|
18
18
|
postTargetTransformer,
|
|
@@ -90,7 +90,7 @@ async function initEsLint(tree, options) {
|
|
|
90
90
|
'_eslint-lint',
|
|
91
91
|
];
|
|
92
92
|
if (rootEslintFile && options.addPlugin && !hasPlugin) {
|
|
93
|
-
await (0, internal_1.addPlugin)(tree, graph, '@nx/eslint/plugin', plugin_1.
|
|
93
|
+
await (0, internal_1.addPlugin)(tree, graph, '@nx/eslint/plugin', plugin_1.createNodes, {
|
|
94
94
|
targetName: lintTargetNames,
|
|
95
95
|
}, options.updatePackageScripts);
|
|
96
96
|
return () => { };
|
|
@@ -101,7 +101,7 @@ async function initEsLint(tree, options) {
|
|
|
101
101
|
updateProductionFileset(tree, options.eslintConfigFormat);
|
|
102
102
|
updateVsCodeRecommendedExtensions(tree);
|
|
103
103
|
if (options.addPlugin) {
|
|
104
|
-
await (0, internal_1.addPlugin)(tree, graph, '@nx/eslint/plugin', plugin_1.
|
|
104
|
+
await (0, internal_1.addPlugin)(tree, graph, '@nx/eslint/plugin', plugin_1.createNodes, {
|
|
105
105
|
targetName: lintTargetNames,
|
|
106
106
|
}, options.updatePackageScripts);
|
|
107
107
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<% if (
|
|
1
|
+
<% if (useFlatRuleTester) { %>import { RuleTester } from '@typescript-eslint/rule-tester';
|
|
2
2
|
import type { RuleTesterConfig } from '@typescript-eslint/rule-tester';
|
|
3
3
|
import { rule, RULE_NAME } from './<%= name %>';
|
|
4
4
|
|
|
@@ -5,6 +5,7 @@ const tslib_1 = require("tslib");
|
|
|
5
5
|
const internal_1 = require("@nx/devkit/internal");
|
|
6
6
|
const devkit_1 = require("@nx/devkit");
|
|
7
7
|
const path_1 = require("path");
|
|
8
|
+
const semver_1 = require("semver");
|
|
8
9
|
const ts = tslib_1.__importStar(require("typescript"));
|
|
9
10
|
const workspace_lint_rules_1 = require("../../utils/workspace-lint-rules");
|
|
10
11
|
const workspace_rules_project_1 = require("../workspace-rules-project/workspace-rules-project");
|
|
@@ -15,6 +16,15 @@ async function lintWorkspaceRuleGenerator(tree, options) {
|
|
|
15
16
|
(0, assert_supported_eslint_version_1.assertSupportedEslintVersion)(tree);
|
|
16
17
|
const tasks = [];
|
|
17
18
|
const flatConfig = (0, flat_config_1.useFlatConfig)(tree);
|
|
19
|
+
// ESLint v9 dropped the eslintrc-style `RuleTester` API. typescript-eslint's
|
|
20
|
+
// recommended replacement for any v9 workspace (flat or eslintrc) is the
|
|
21
|
+
// separate `@typescript-eslint/rule-tester` package, which has a flat-style
|
|
22
|
+
// API that works with ESLint v8.57+ and v9 alike. We resolve the effective
|
|
23
|
+
// major from `versions(tree)` to cover both declared workspaces and fresh
|
|
24
|
+
// installs that will be bumped to v9.
|
|
25
|
+
const { eslintVersion, typescriptESLintVersion } = (0, versions_1.versions)(tree);
|
|
26
|
+
const effectiveEslintMajor = (0, semver_1.major)((0, semver_1.coerce)(eslintVersion));
|
|
27
|
+
const useFlatRuleTester = flatConfig || effectiveEslintMajor >= 9;
|
|
18
28
|
const nxJson = (0, devkit_1.readNxJson)(tree);
|
|
19
29
|
// Ensure that the workspace rules project has been created
|
|
20
30
|
tasks.push(await (0, workspace_rules_project_1.lintWorkspaceRulesProjectGenerator)(tree, {
|
|
@@ -22,8 +32,7 @@ async function lintWorkspaceRuleGenerator(tree, options) {
|
|
|
22
32
|
addPlugin: process.env.NX_ADD_PLUGINS !== 'false' &&
|
|
23
33
|
nxJson.useInferencePlugins !== false,
|
|
24
34
|
}));
|
|
25
|
-
if (
|
|
26
|
-
const { typescriptESLintVersion } = (0, versions_1.versions)(tree);
|
|
35
|
+
if (useFlatRuleTester) {
|
|
27
36
|
tasks.push((0, devkit_1.addDependenciesToPackageJson)(tree, {}, { '@typescript-eslint/rule-tester': typescriptESLintVersion }, undefined, true));
|
|
28
37
|
}
|
|
29
38
|
const ruleDir = (0, devkit_1.joinPathFragments)(workspace_lint_rules_1.workspaceLintPluginDir, options.directory ?? '');
|
|
@@ -31,7 +40,7 @@ async function lintWorkspaceRuleGenerator(tree, options) {
|
|
|
31
40
|
(0, devkit_1.generateFiles)(tree, (0, path_1.join)(__dirname, 'files'), ruleDir, {
|
|
32
41
|
tmpl: '',
|
|
33
42
|
name: options.name,
|
|
34
|
-
|
|
43
|
+
useFlatRuleTester,
|
|
35
44
|
});
|
|
36
45
|
const nameCamelCase = (0, internal_1.camelize)(options.name);
|
|
37
46
|
/**
|
|
@@ -57,6 +57,13 @@ async function lintWorkspaceRulesProjectGenerator(tree, options = {}) {
|
|
|
57
57
|
(0, devkit_1.updateJson)(tree, (0, path_1.join)(workspace_lint_rules_1.workspaceLintPluginDir, 'tsconfig.spec.json'), (json) => {
|
|
58
58
|
delete json.compilerOptions?.module;
|
|
59
59
|
delete json.compilerOptions?.moduleResolution;
|
|
60
|
+
// Inherits `module: node16` from the project's base `tsconfig.json`,
|
|
61
|
+
// which requires `isolatedModules: true` to reliably honor packages'
|
|
62
|
+
// `exports` maps (e.g. `@typescript-eslint/rule-tester`).
|
|
63
|
+
json.compilerOptions = {
|
|
64
|
+
...json.compilerOptions,
|
|
65
|
+
isolatedModules: true,
|
|
66
|
+
};
|
|
60
67
|
if (json.include) {
|
|
61
68
|
json.include = json.include.map((v) => {
|
|
62
69
|
if (v.startsWith('src/**')) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CreateNodes } from '@nx/devkit';
|
|
2
2
|
export interface EslintPluginOptions {
|
|
3
3
|
targetName?: string;
|
|
4
4
|
extensions?: string[];
|
|
5
5
|
}
|
|
6
|
-
export declare const createNodes:
|
|
7
|
-
export declare const createNodesV2:
|
|
6
|
+
export declare const createNodes: CreateNodes<EslintPluginOptions>;
|
|
7
|
+
export declare const createNodesV2: CreateNodes<EslintPluginOptions>;
|
|
@@ -2,7 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.assertSupportedEslintVersion = assertSupportedEslintVersion;
|
|
4
4
|
const internal_1 = require("@nx/devkit/internal");
|
|
5
|
+
const deprecation_1 = require("./deprecation");
|
|
5
6
|
const versions_1 = require("./versions");
|
|
6
7
|
function assertSupportedEslintVersion(tree) {
|
|
7
8
|
(0, internal_1.assertSupportedPackageVersion)(tree, 'eslint', versions_1.minSupportedEslintVersion);
|
|
9
|
+
if ((0, versions_1.getInstalledEslintMajorVersion)(tree) === 8) {
|
|
10
|
+
(0, deprecation_1.warnEslintV8Deprecation)();
|
|
11
|
+
}
|
|
8
12
|
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
export declare const ESLINT_EXECUTOR_DEPRECATION_MESSAGE = "The `@nx/eslint:lint` executor is deprecated and will be removed in Nx v24. Run `nx g @nx/eslint:convert-to-inferred` to migrate to the `@nx/eslint/plugin` inferred targets. See https://nx.dev/docs/guides/tasks--caching/convert-to-inferred for details.";
|
|
2
2
|
export declare function warnEslintExecutorDeprecation(): void;
|
|
3
3
|
export declare function warnEslintExecutorGenerating(): void;
|
|
4
|
+
export declare const ESLINT_V8_DEPRECATION_MESSAGE = "Support for ESLint v8 is deprecated and will be removed in Nx v24. Please upgrade to ESLint v9.";
|
|
5
|
+
export declare function warnEslintV8Deprecation(): void;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ESLINT_EXECUTOR_DEPRECATION_MESSAGE = void 0;
|
|
3
|
+
exports.ESLINT_V8_DEPRECATION_MESSAGE = exports.ESLINT_EXECUTOR_DEPRECATION_MESSAGE = void 0;
|
|
4
4
|
exports.warnEslintExecutorDeprecation = warnEslintExecutorDeprecation;
|
|
5
5
|
exports.warnEslintExecutorGenerating = warnEslintExecutorGenerating;
|
|
6
|
+
exports.warnEslintV8Deprecation = warnEslintV8Deprecation;
|
|
6
7
|
const devkit_1 = require("@nx/devkit");
|
|
7
8
|
// TODO(v24): Remove the @nx/eslint:lint executor. The inferred plugin
|
|
8
9
|
// (@nx/eslint/plugin) and the convert-to-inferred generator stay supported.
|
|
@@ -13,3 +14,12 @@ function warnEslintExecutorDeprecation() {
|
|
|
13
14
|
function warnEslintExecutorGenerating() {
|
|
14
15
|
devkit_1.logger.warn('Generating a target that uses the deprecated `@nx/eslint:lint` executor. The executor will be removed in Nx v24. Run `nx g @nx/eslint:convert-to-inferred` next to migrate this target to the `@nx/eslint/plugin` inferred plugin and prevent future generators from emitting executor targets. See https://nx.dev/docs/guides/tasks--caching/convert-to-inferred for details.');
|
|
15
16
|
}
|
|
17
|
+
// TODO(v24): Remove ESLint v8 support. Concrete removals:
|
|
18
|
+
// - Raise `minSupportedEslintVersion` to '9.0.0' in versions.ts.
|
|
19
|
+
// - Delete `versionMap[8]` and the `CompatVersions` type alias.
|
|
20
|
+
// - Delete this constant + `warnEslintV8Deprecation` and their call sites.
|
|
21
|
+
// - Drop the v8 branch in the workspace-rule generator/template.
|
|
22
|
+
exports.ESLINT_V8_DEPRECATION_MESSAGE = 'Support for ESLint v8 is deprecated and will be removed in Nx v24. Please upgrade to ESLint v9.';
|
|
23
|
+
function warnEslintV8Deprecation() {
|
|
24
|
+
devkit_1.logger.warn(exports.ESLINT_V8_DEPRECATION_MESSAGE);
|
|
25
|
+
}
|
|
@@ -7,7 +7,6 @@ exports.getInstalledEslintMajorVersion = getInstalledEslintMajorVersion;
|
|
|
7
7
|
const internal_1 = require("@nx/devkit/internal");
|
|
8
8
|
const path_1 = require("path");
|
|
9
9
|
const semver_1 = require("semver");
|
|
10
|
-
const flat_config_1 = require("./flat-config");
|
|
11
10
|
exports.nxVersion = require((0, path_1.join)('@nx/eslint', 'package.json')).version;
|
|
12
11
|
exports.minSupportedEslintVersion = '8.0.0';
|
|
13
12
|
exports.eslintConfigPrettierVersion = '^10.0.0';
|
|
@@ -32,11 +31,11 @@ function versions(tree) {
|
|
|
32
31
|
const eslintMajorVersion = (0, semver_1.major)(installedEslintVersion);
|
|
33
32
|
return versionMap[eslintMajorVersion] ?? latestVersions;
|
|
34
33
|
}
|
|
35
|
-
// No ESLint declared yet — fresh installs
|
|
36
|
-
//
|
|
37
|
-
//
|
|
38
|
-
//
|
|
39
|
-
return
|
|
34
|
+
// No ESLint declared yet — fresh installs always go to the latest supported
|
|
35
|
+
// ESLint stack (v9 + typescript-eslint v8). The eslintrc config shape is
|
|
36
|
+
// still respected at the config-file level when `useFlatConfig(tree)` is
|
|
37
|
+
// false; only the installed package versions move forward.
|
|
38
|
+
return latestVersions;
|
|
40
39
|
}
|
|
41
40
|
function getInstalledEslintVersion(tree) {
|
|
42
41
|
if (!tree) {
|
package/migrations.json
CHANGED
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
"implementation": "./dist/src/migrations/update-20-2-0/update-typescript-eslint-v8-13-0",
|
|
7
7
|
"requires": {
|
|
8
8
|
"@typescript-eslint/parser": ">=8.0.0"
|
|
9
|
-
}
|
|
9
|
+
},
|
|
10
|
+
"documentation": "./dist/src/migrations/update-20-2-0/update-typescript-eslint-v8-13-0.md"
|
|
10
11
|
},
|
|
11
12
|
"add-file-extensions-to-overrides": {
|
|
12
13
|
"version": "20.3.0-beta.1",
|
|
@@ -14,7 +15,8 @@
|
|
|
14
15
|
"implementation": "./dist/src/migrations/update-20-3-0/add-file-extensions-to-overrides",
|
|
15
16
|
"requires": {
|
|
16
17
|
"eslint": ">=8.57.0"
|
|
17
|
-
}
|
|
18
|
+
},
|
|
19
|
+
"documentation": "./dist/src/migrations/update-20-3-0/add-file-extensions-to-overrides.md"
|
|
18
20
|
},
|
|
19
21
|
"update-executor-lint-inputs": {
|
|
20
22
|
"version": "22.7.0-beta.12",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/eslint",
|
|
3
|
-
"version": "23.0.0-beta.
|
|
3
|
+
"version": "23.0.0-beta.23",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"files": [
|
|
@@ -73,17 +73,17 @@
|
|
|
73
73
|
"peerDependencies": {
|
|
74
74
|
"@zkochan/js-yaml": "0.0.7",
|
|
75
75
|
"eslint": "^8.0.0 || ^9.0.0 || ^10.0.0",
|
|
76
|
-
"@nx/jest": "23.0.0-beta.
|
|
76
|
+
"@nx/jest": "23.0.0-beta.23"
|
|
77
77
|
},
|
|
78
78
|
"dependencies": {
|
|
79
79
|
"semver": "^7.6.3",
|
|
80
80
|
"tslib": "^2.3.0",
|
|
81
81
|
"typescript": "~5.9.2",
|
|
82
|
-
"@nx/js": "23.0.0-beta.
|
|
83
|
-
"@nx/devkit": "23.0.0-beta.
|
|
82
|
+
"@nx/js": "23.0.0-beta.23",
|
|
83
|
+
"@nx/devkit": "23.0.0-beta.23"
|
|
84
84
|
},
|
|
85
85
|
"devDependencies": {
|
|
86
|
-
"nx": "23.0.0-beta.
|
|
86
|
+
"nx": "23.0.0-beta.23"
|
|
87
87
|
},
|
|
88
88
|
"peerDependenciesMeta": {
|
|
89
89
|
"@nx/jest": {
|