@nx/eslint 24.0.0-pr.37405.acdaf31 → 24.0.0-rc.0
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/internal.d.ts +0 -1
- package/dist/src/generators/init/init-migration.d.ts +1 -2
- package/dist/src/generators/init/init-migration.js +2 -13
- package/dist/src/generators/init/init.d.ts +0 -1
- package/dist/src/generators/init/init.js +5 -42
- package/dist/src/generators/lint-project/lint-project.d.ts +0 -6
- package/dist/src/generators/lint-project/lint-project.js +11 -34
- package/dist/src/generators/utils/eslint-file.d.ts +2 -5
- package/dist/src/generators/utils/eslint-file.js +3 -5
- package/dist/src/generators/workspace-rule/workspace-rule.js +0 -3
- package/dist/src/generators/workspace-rules-project/workspace-rules-project.d.ts +0 -1
- package/dist/src/migrations/update-23-1-0/convert-to-flat-config.md +9 -9
- package/dist/src/migrations/update-24-0-0/finish-inferred-conversion.md +12 -0
- package/dist/src/migrations/update-24-0-0/remove-deprecated-executors.d.ts +6 -0
- package/dist/src/migrations/update-24-0-0/remove-deprecated-executors.js +10 -0
- package/dist/src/migrations/update-24-0-0/remove-deprecated-executors.md +38 -0
- package/dist/src/migrations/update-24-0-0/replace-set-parser-options-project.d.ts +4 -0
- package/dist/src/migrations/update-24-0-0/replace-set-parser-options-project.js +192 -0
- package/dist/src/migrations/update-24-0-0/replace-set-parser-options-project.md +77 -0
- package/dist/src/utils/config-file.d.ts +0 -2
- package/dist/src/utils/config-file.js +0 -44
- package/executors.json +1 -7
- package/migrations.json +13 -0
- package/package.json +6 -6
- package/dist/src/executors/lint/lint.impl.d.ts +0 -5
- package/dist/src/executors/lint/lint.impl.js +0 -190
- package/dist/src/executors/lint/schema.d.ts +0 -32
- package/dist/src/executors/lint/schema.json +0 -154
- package/dist/src/executors/lint/utility/eslint-utils.d.ts +0 -6
- package/dist/src/executors/lint/utility/eslint-utils.js +0 -106
- package/dist/src/generators/utils/eslint-targets.d.ts +0 -2
- package/dist/src/generators/utils/eslint-targets.js +0 -17
- package/dist/src/utils/deprecation.d.ts +0 -3
- package/dist/src/utils/deprecation.js +0 -15
package/dist/internal.d.ts
CHANGED
|
@@ -4,4 +4,3 @@ export { useFlatConfig } from './src/utils/flat-config';
|
|
|
4
4
|
export { javaScriptOverride, typeScriptOverride, } from './src/generators/init/global-eslint-config';
|
|
5
5
|
export { setupRootEsLint } from './src/generators/lint-project/setup-root-eslint';
|
|
6
6
|
export { getInstalledEslintVersion, typescriptESLintVersion, versions, } from './src/utils/versions';
|
|
7
|
-
export type { Schema } from './src/executors/lint/schema';
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import { GeneratorCallback, ProjectConfiguration,
|
|
1
|
+
import { GeneratorCallback, ProjectConfiguration, Tree } from '@nx/devkit';
|
|
2
2
|
export declare function migrateConfigToMonorepoStyle(projects: ProjectConfiguration[], tree: Tree, unitTestRunner: string, eslintConfigFormat: 'mjs' | 'cjs', keepExistingVersions?: boolean): GeneratorCallback;
|
|
3
|
-
export declare function findLintTarget(project: ProjectConfiguration): TargetConfiguration;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.migrateConfigToMonorepoStyle = migrateConfigToMonorepoStyle;
|
|
4
|
-
exports.findLintTarget = findLintTarget;
|
|
5
4
|
const devkit_1 = require("@nx/devkit");
|
|
6
5
|
const path_1 = require("path");
|
|
7
6
|
const eslint_file_1 = require("../utils/eslint-file");
|
|
@@ -50,14 +49,8 @@ function migrateConfigToMonorepoStyle(projects, tree, unitTestRunner, eslintConf
|
|
|
50
49
|
// update extends in all projects' eslint configs
|
|
51
50
|
projects.forEach((project) => {
|
|
52
51
|
let eslintFile;
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
// If target is configured in project.json, read file from target options.
|
|
56
|
-
eslintFile =
|
|
57
|
-
lintTarget.options?.eslintConfig || (0, eslint_file_1.findEslintFile)(tree, project.root);
|
|
58
|
-
}
|
|
59
|
-
else if ((0, plugin_1.hasEslintPlugin)(tree)) {
|
|
60
|
-
// Otherwise, if `@nx/eslint/plugin` is used, match any of the known config files.
|
|
52
|
+
if ((0, plugin_1.hasEslintPlugin)(tree)) {
|
|
53
|
+
// If `@nx/eslint/plugin` is used, match any of the known config files.
|
|
61
54
|
for (const f of config_file_1.ESLINT_CONFIG_FILENAMES) {
|
|
62
55
|
if (tree.exists((0, devkit_1.joinPathFragments)(project.root, f))) {
|
|
63
56
|
eslintFile = f;
|
|
@@ -80,10 +73,6 @@ function migrateConfigToMonorepoStyle(projects, tree, unitTestRunner, eslintConf
|
|
|
80
73
|
'@nx/eslint-plugin': versions_1.nxVersion,
|
|
81
74
|
}, undefined, keepExistingVersions ?? true);
|
|
82
75
|
}
|
|
83
|
-
function findLintTarget(project) {
|
|
84
|
-
return Object.values(project.targets ?? {}).find((target) => target.executor === '@nx/eslint:lint' ||
|
|
85
|
-
target.executor === '@nx/linter:eslint');
|
|
86
|
-
}
|
|
87
76
|
function migrateEslintFile(projectEslintPath, tree) {
|
|
88
77
|
const baseFile = (0, eslint_file_1.findEslintFile)(tree);
|
|
89
78
|
if ((0, eslint_file_1.isEslintConfigSupported)(tree)) {
|
|
@@ -3,7 +3,6 @@ export interface LinterInitOptions {
|
|
|
3
3
|
skipPackageJson?: boolean;
|
|
4
4
|
keepExistingVersions?: boolean;
|
|
5
5
|
updatePackageScripts?: boolean;
|
|
6
|
-
addPlugin?: boolean;
|
|
7
6
|
eslintConfigFormat?: 'mjs' | 'cjs';
|
|
8
7
|
}
|
|
9
8
|
export declare function initEsLint(tree: Tree, options: LinterInitOptions): Promise<GeneratorCallback>;
|
|
@@ -21,34 +21,6 @@ function updateProductionFileset(tree, format = 'mjs') {
|
|
|
21
21
|
}
|
|
22
22
|
(0, devkit_1.updateNxJson)(tree, nxJson);
|
|
23
23
|
}
|
|
24
|
-
function addTargetDefaults(tree, format) {
|
|
25
|
-
const nxJson = (0, devkit_1.readNxJson)(tree) ?? {};
|
|
26
|
-
// `@nx/eslint:lint` is an executor identifier — match defaults keyed on
|
|
27
|
-
// the executor, not on a target named that string.
|
|
28
|
-
const existing = (0, internal_1.findTargetDefault)(nxJson.targetDefaults, {
|
|
29
|
-
executor: '@nx/eslint:lint',
|
|
30
|
-
});
|
|
31
|
-
const patch = {};
|
|
32
|
-
if (existing?.cache === undefined)
|
|
33
|
-
patch.cache = true;
|
|
34
|
-
if (existing?.inputs === undefined) {
|
|
35
|
-
patch.inputs = [
|
|
36
|
-
'default',
|
|
37
|
-
'^default',
|
|
38
|
-
`{workspaceRoot}/.eslintrc.json`,
|
|
39
|
-
`{workspaceRoot}/.eslintignore`,
|
|
40
|
-
`{workspaceRoot}/eslint.config.${format}`,
|
|
41
|
-
'{workspaceRoot}/tools/eslint-rules/**/*',
|
|
42
|
-
];
|
|
43
|
-
}
|
|
44
|
-
if (Object.keys(patch).length > 0) {
|
|
45
|
-
(0, internal_1.upsertTargetDefault)(tree, nxJson, {
|
|
46
|
-
executor: '@nx/eslint:lint',
|
|
47
|
-
...patch,
|
|
48
|
-
});
|
|
49
|
-
(0, devkit_1.updateNxJson)(tree, nxJson);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
24
|
function updateVsCodeRecommendedExtensions(host) {
|
|
53
25
|
if (!host.exists('.vscode/extensions.json')) {
|
|
54
26
|
return;
|
|
@@ -64,10 +36,6 @@ function updateVsCodeRecommendedExtensions(host) {
|
|
|
64
36
|
}
|
|
65
37
|
async function initEsLint(tree, options) {
|
|
66
38
|
(0, assert_supported_eslint_version_1.assertSupportedEslintVersion)(tree);
|
|
67
|
-
const nxJson = (0, devkit_1.readNxJson)(tree);
|
|
68
|
-
const addPluginDefault = process.env.NX_ADD_PLUGINS !== 'false' &&
|
|
69
|
-
nxJson.useInferencePlugins !== false;
|
|
70
|
-
options.addPlugin ??= addPluginDefault;
|
|
71
39
|
options.eslintConfigFormat ??= 'mjs';
|
|
72
40
|
const hasPlugin = (0, plugin_2.hasEslintPlugin)(tree);
|
|
73
41
|
const rootEslintFile = (0, eslint_file_1.findEslintFile)(tree);
|
|
@@ -89,7 +57,7 @@ async function initEsLint(tree, options) {
|
|
|
89
57
|
'_eslint:lint',
|
|
90
58
|
'_eslint-lint',
|
|
91
59
|
];
|
|
92
|
-
if (rootEslintFile &&
|
|
60
|
+
if (rootEslintFile && !hasPlugin) {
|
|
93
61
|
await (0, internal_1.addPlugin)(tree, graph, '@nx/eslint/plugin', plugin_1.createNodes, {
|
|
94
62
|
targetName: lintTargetNames,
|
|
95
63
|
}, options.updatePackageScripts);
|
|
@@ -100,14 +68,9 @@ async function initEsLint(tree, options) {
|
|
|
100
68
|
}
|
|
101
69
|
updateProductionFileset(tree, options.eslintConfigFormat);
|
|
102
70
|
updateVsCodeRecommendedExtensions(tree);
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
}, options.updatePackageScripts);
|
|
107
|
-
}
|
|
108
|
-
else {
|
|
109
|
-
addTargetDefaults(tree, options.eslintConfigFormat);
|
|
110
|
-
}
|
|
71
|
+
await (0, internal_1.addPlugin)(tree, graph, '@nx/eslint/plugin', plugin_1.createNodes, {
|
|
72
|
+
targetName: lintTargetNames,
|
|
73
|
+
}, options.updatePackageScripts);
|
|
111
74
|
const tasks = [];
|
|
112
75
|
if (!options.skipPackageJson) {
|
|
113
76
|
const { eslintVersion } = (0, versions_1.versions)(tree);
|
|
@@ -120,5 +83,5 @@ async function initEsLint(tree, options) {
|
|
|
120
83
|
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
121
84
|
}
|
|
122
85
|
async function lintInitGenerator(tree, options) {
|
|
123
|
-
return await initEsLint(tree,
|
|
86
|
+
return await initEsLint(tree, options);
|
|
124
87
|
}
|
|
@@ -7,20 +7,14 @@ interface LintProjectOptions {
|
|
|
7
7
|
tsConfigPaths?: string[];
|
|
8
8
|
skipFormat: boolean;
|
|
9
9
|
enableTypedLinting?: boolean;
|
|
10
|
-
/**
|
|
11
|
-
* @deprecated Use `enableTypedLinting` instead. This option will be removed in Nx v24.
|
|
12
|
-
*/
|
|
13
|
-
setParserOptionsProject?: boolean;
|
|
14
10
|
skipPackageJson?: boolean;
|
|
15
11
|
unitTestRunner?: string;
|
|
16
12
|
rootProject?: boolean;
|
|
17
13
|
keepExistingVersions?: boolean;
|
|
18
|
-
addPlugin?: boolean;
|
|
19
14
|
eslintConfigFormat?: 'mjs' | 'cjs';
|
|
20
15
|
/**
|
|
21
16
|
* @internal
|
|
22
17
|
*/
|
|
23
|
-
addExplicitTargets?: boolean;
|
|
24
18
|
addPackageJsonDependencyChecks?: boolean;
|
|
25
19
|
}
|
|
26
20
|
export declare function lintProjectGenerator(tree: Tree, options: LintProjectOptions): Promise<GeneratorCallback>;
|
|
@@ -6,7 +6,6 @@ const devkit_1 = require("@nx/devkit");
|
|
|
6
6
|
const eslint_file_1 = require("../utils/eslint-file");
|
|
7
7
|
const path_1 = require("path");
|
|
8
8
|
const init_1 = require("../init/init");
|
|
9
|
-
const deprecation_1 = require("../../utils/deprecation");
|
|
10
9
|
const init_migration_1 = require("../init/init-migration");
|
|
11
10
|
const flat_config_1 = require("../../utils/flat-config");
|
|
12
11
|
const ast_utils_1 = require("../utils/flat-config/ast-utils");
|
|
@@ -16,18 +15,13 @@ const versions_1 = require("../../utils/versions");
|
|
|
16
15
|
const setup_root_eslint_1 = require("./setup-root-eslint");
|
|
17
16
|
const internal_1 = require("@nx/js/internal");
|
|
18
17
|
function lintProjectGenerator(tree, options) {
|
|
19
|
-
return lintProjectGeneratorInternal(tree,
|
|
18
|
+
return lintProjectGeneratorInternal(tree, options);
|
|
20
19
|
}
|
|
21
20
|
async function lintProjectGeneratorInternal(tree, options) {
|
|
22
|
-
const nxJson = (0, devkit_1.readNxJson)(tree);
|
|
23
21
|
options.eslintConfigFormat ??= 'mjs';
|
|
24
|
-
const addPluginDefault = process.env.NX_ADD_PLUGINS !== 'false' &&
|
|
25
|
-
nxJson.useInferencePlugins !== false;
|
|
26
|
-
options.addPlugin ??= addPluginDefault;
|
|
27
22
|
const tasks = [];
|
|
28
23
|
const initTask = await (0, init_1.lintInitGenerator)(tree, {
|
|
29
24
|
skipPackageJson: options.skipPackageJson,
|
|
30
|
-
addPlugin: options.addPlugin,
|
|
31
25
|
eslintConfigFormat: options.eslintConfigFormat,
|
|
32
26
|
});
|
|
33
27
|
tasks.push(initTask);
|
|
@@ -49,31 +43,15 @@ async function lintProjectGeneratorInternal(tree, options) {
|
|
|
49
43
|
isBuildableLibraryProject(tree, projectConfig)) {
|
|
50
44
|
lintFilePatterns.push(`{projectRoot}/package.json`);
|
|
51
45
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
lintFilePatterns.length &&
|
|
56
|
-
lintFilePatterns.some((p) => !['./src', '{projectRoot}', projectConfig.root].includes(p))) {
|
|
57
|
-
projectConfig.targets ??= {};
|
|
58
|
-
projectConfig.targets['lint'] = {
|
|
59
|
-
command: `eslint ${lintFilePatterns
|
|
60
|
-
.join(' ')
|
|
61
|
-
.replace('{projectRoot}', projectConfig.root)}`,
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
else {
|
|
66
|
-
(0, deprecation_1.warnEslintExecutorGenerating)();
|
|
46
|
+
if (lintFilePatterns &&
|
|
47
|
+
lintFilePatterns.length &&
|
|
48
|
+
lintFilePatterns.some((p) => !['./src', '{projectRoot}', projectConfig.root].includes(p))) {
|
|
67
49
|
projectConfig.targets ??= {};
|
|
68
50
|
projectConfig.targets['lint'] = {
|
|
69
|
-
|
|
51
|
+
command: `eslint ${lintFilePatterns
|
|
52
|
+
.join(' ')
|
|
53
|
+
.replace('{projectRoot}', projectConfig.root)}`,
|
|
70
54
|
};
|
|
71
|
-
if (lintFilePatterns && lintFilePatterns.length) {
|
|
72
|
-
// only add lintFilePatterns if they are explicitly defined
|
|
73
|
-
projectConfig.targets['lint'].options = {
|
|
74
|
-
lintFilePatterns,
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
55
|
}
|
|
78
56
|
// we are adding new project which is not the root project or
|
|
79
57
|
// companion e2e app so we should check if migration to
|
|
@@ -98,7 +76,7 @@ async function lintProjectGeneratorInternal(tree, options) {
|
|
|
98
76
|
if (!options.rootProject || projectConfig.root !== '.') {
|
|
99
77
|
const addDependencyChecks = options.addPackageJsonDependencyChecks ||
|
|
100
78
|
isBuildableLibraryProject(tree, projectConfig);
|
|
101
|
-
createEsLintConfiguration(tree, options, projectConfig,
|
|
79
|
+
createEsLintConfiguration(tree, options, projectConfig, options.enableTypedLinting, options.rootProject, addDependencyChecks);
|
|
102
80
|
if (addDependencyChecks) {
|
|
103
81
|
tasks.push((0, devkit_1.addDependenciesToPackageJson)(tree, {}, { 'jsonc-eslint-parser': versions_1.jsoncEslintParserVersion }, undefined, true));
|
|
104
82
|
}
|
|
@@ -274,10 +252,9 @@ function rootHasEslintLintTarget(targets) {
|
|
|
274
252
|
return false;
|
|
275
253
|
}
|
|
276
254
|
for (const targetConfig of Object.values(targets)) {
|
|
277
|
-
if (
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
targetConfig.options?.command.startsWith('eslint '))) {
|
|
255
|
+
if (targetConfig.executor === 'nx:run-commands' &&
|
|
256
|
+
targetConfig.options?.command &&
|
|
257
|
+
targetConfig.options?.command.startsWith('eslint ')) {
|
|
281
258
|
return true;
|
|
282
259
|
}
|
|
283
260
|
}
|
|
@@ -5,14 +5,11 @@ export declare function isEslintConfigSupported(tree: Tree, projectRoot?: string
|
|
|
5
5
|
export declare function updateRelativePathsInConfig(tree: Tree, sourcePath: string, destinationPath: string): void;
|
|
6
6
|
export declare function determineEslintConfigFormat(content: string): 'mjs' | 'cjs';
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
9
|
-
* (
|
|
10
|
-
* generator whose `enableTypedLinting` schema default is `false` must still
|
|
11
|
-
* honor a user who set the deprecated flag.
|
|
8
|
+
* Plugins this repo installs from npm still import this, and its specs load them.
|
|
9
|
+
* TODO(v24): remove once the root `nx` catalog is on a release whose plugins no longer import it.
|
|
12
10
|
*/
|
|
13
11
|
export declare function isTypedLintingEnabled(options: {
|
|
14
12
|
enableTypedLinting?: boolean;
|
|
15
|
-
setParserOptionsProject?: boolean;
|
|
16
13
|
}): boolean;
|
|
17
14
|
/**
|
|
18
15
|
* What a config says about typed linting.
|
|
@@ -152,13 +152,11 @@ function determineEslintConfigFormat(content) {
|
|
|
152
152
|
return (0, ast_utils_1.isEsmExport)(sourceFile) ? 'mjs' : 'cjs';
|
|
153
153
|
}
|
|
154
154
|
/**
|
|
155
|
-
*
|
|
156
|
-
* (
|
|
157
|
-
* generator whose `enableTypedLinting` schema default is `false` must still
|
|
158
|
-
* honor a user who set the deprecated flag.
|
|
155
|
+
* Plugins this repo installs from npm still import this, and its specs load them.
|
|
156
|
+
* TODO(v24): remove once the root `nx` catalog is on a release whose plugins no longer import it.
|
|
159
157
|
*/
|
|
160
158
|
function isTypedLintingEnabled(options) {
|
|
161
|
-
return !!
|
|
159
|
+
return !!options.enableTypedLinting;
|
|
162
160
|
}
|
|
163
161
|
/**
|
|
164
162
|
* What a config says about typed linting.
|
|
@@ -17,12 +17,9 @@ async function lintWorkspaceRuleGenerator(tree, options) {
|
|
|
17
17
|
// recommended replacement is the separate `@typescript-eslint/rule-tester`
|
|
18
18
|
// package, whose flat-style API works for both flat and eslintrc workspaces.
|
|
19
19
|
const { typescriptESLintVersion } = (0, versions_1.versions)(tree);
|
|
20
|
-
const nxJson = (0, devkit_1.readNxJson)(tree);
|
|
21
20
|
// Ensure that the workspace rules project has been created
|
|
22
21
|
tasks.push(await (0, workspace_rules_project_1.lintWorkspaceRulesProjectGenerator)(tree, {
|
|
23
22
|
skipFormat: true,
|
|
24
|
-
addPlugin: process.env.NX_ADD_PLUGINS !== 'false' &&
|
|
25
|
-
nxJson.useInferencePlugins !== false,
|
|
26
23
|
}));
|
|
27
24
|
tasks.push((0, devkit_1.addDependenciesToPackageJson)(tree, {}, { '@typescript-eslint/rule-tester': typescriptESLintVersion }, undefined, true));
|
|
28
25
|
const ruleDir = (0, devkit_1.joinPathFragments)(workspace_lint_rules_1.workspaceLintPluginDir, options.directory ?? '');
|
|
@@ -3,6 +3,5 @@ export declare const WORKSPACE_RULES_PROJECT_NAME = "eslint-rules";
|
|
|
3
3
|
export declare const WORKSPACE_PLUGIN_DIR = "tools/eslint-rules";
|
|
4
4
|
export interface LintWorkspaceRulesProjectGeneratorOptions {
|
|
5
5
|
skipFormat?: boolean;
|
|
6
|
-
addPlugin?: boolean;
|
|
7
6
|
}
|
|
8
7
|
export declare function lintWorkspaceRulesProjectGenerator(tree: Tree, options?: LintWorkspaceRulesProjectGeneratorOptions): Promise<GeneratorCallback>;
|
|
@@ -34,17 +34,17 @@ The pre-pass does NOT:
|
|
|
34
34
|
- Decide whether a generated `FlatCompat` shim should become flat-native config.
|
|
35
35
|
- Make the workspace pass lint after ESLint v9 changed which rules its preset defaults enable.
|
|
36
36
|
|
|
37
|
-
Everything the pre-pass could not finish is forwarded to you in
|
|
37
|
+
Everything the pre-pass could not finish is forwarded to you in `impl.agentContext`.
|
|
38
38
|
|
|
39
|
-
How to read the
|
|
39
|
+
How to read the `impl` fields of the step's `nx_migrate_prompt` block:
|
|
40
40
|
|
|
41
|
-
-
|
|
42
|
-
-
|
|
41
|
+
- `impl.changes` lists files the pre-pass wrote. Verify the new shape is in place; do not re-apply the same edit. It is empty when the pre-pass made no changes (for example a workspace that was already on flat config).
|
|
42
|
+
- `impl.agentContext` lists detections the pre-pass forwarded because it could not safely complete them. Every entry is pending work. Address each one in the relevant section below.
|
|
43
43
|
|
|
44
44
|
</pre_pass_summary>
|
|
45
45
|
|
|
46
46
|
<handoff_guidance>
|
|
47
|
-
In your handoff `summary` (1 to 3 sentences per the
|
|
47
|
+
In your handoff `summary` (1 to 3 sentences, per the handoff format), name the sections you applied and explicitly call out any you skipped because they did not apply (for example "no JavaScript-based configs and no removed formatters in this workspace").
|
|
48
48
|
</handoff_guidance>
|
|
49
49
|
|
|
50
50
|
## Pre-Migration Checklist
|
|
@@ -87,7 +87,7 @@ If the workspace already uses `eslint.config.*` at the root and in every project
|
|
|
87
87
|
|
|
88
88
|
## 2. Convert JavaScript-based ESLint configs the pre-pass skipped
|
|
89
89
|
|
|
90
|
-
**Search pattern**: `.eslintrc.js` and `.eslintrc.cjs` files (forwarded in
|
|
90
|
+
**Search pattern**: `.eslintrc.js` and `.eslintrc.cjs` files (forwarded in `impl.agentContext`).
|
|
91
91
|
|
|
92
92
|
**What changed**: the pre-pass only converts JSON and YAML eslintrc files. JavaScript-based configs run arbitrary code, so they need manual conversion.
|
|
93
93
|
|
|
@@ -126,7 +126,7 @@ export default [
|
|
|
126
126
|
|
|
127
127
|
## 3. Convert FlatCompat shims to flat-native config where low-risk
|
|
128
128
|
|
|
129
|
-
**Search pattern**: `FlatCompat`, `@eslint/eslintrc`, `compat.extends(`, `compat.config(` in the generated `eslint.config.*` files (listed in
|
|
129
|
+
**Search pattern**: `FlatCompat`, `@eslint/eslintrc`, `compat.extends(`, `compat.config(` in the generated `eslint.config.*` files (listed in `impl.changes`).
|
|
130
130
|
|
|
131
131
|
**What changed**: `FlatCompat` is a runtime shim that adapts eslintrc-style `extends` into flat config. Many plugins now ship native flat presets, which are clearer and avoid the shim.
|
|
132
132
|
|
|
@@ -169,7 +169,7 @@ This is the core requirement of the migration: the workspace must lint cleanly w
|
|
|
169
169
|
|
|
170
170
|
ESLint v9 and typescript-eslint v8 changed which rules their recommended sets enable. A rule the user never configured may now report errors. Disable those rules; do not edit source files to satisfy them.
|
|
171
171
|
|
|
172
|
-
The set of rules the user explicitly configured before the migration is in
|
|
172
|
+
The set of rules the user explicitly configured before the migration is in `impl.agentContext` (the entry that starts with "Passing-state requirement").
|
|
173
173
|
|
|
174
174
|
**Procedure**:
|
|
175
175
|
|
|
@@ -213,7 +213,7 @@ You cannot make lint pass without either editing source files or disabling a rul
|
|
|
213
213
|
|
|
214
214
|
## 5. Fix removed output formatters
|
|
215
215
|
|
|
216
|
-
**Search pattern**: the `format` option on lint targets (forwarded in
|
|
216
|
+
**Search pattern**: the `format` option on lint targets (forwarded in `impl.agentContext`).
|
|
217
217
|
|
|
218
218
|
**What changed**: ESLint v9 removed several built-in output formatters. The built-ins that remain are `stylish`, `html`, `json`, and `json-with-metadata`. Removed: `compact`, `codeframe`, `unix`, `visualstudio`, `table`, `checkstyle`, `jslint-xml`, `junit`, `tap`.
|
|
219
219
|
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# Replace removed @nx/eslint executors with inferred tasks
|
|
2
|
+
|
|
3
|
+
Nx 24 removed `@nx/eslint:lint` (including the old `@nrwl/linter:eslint` name).
|
|
4
|
+
|
|
5
|
+
Before changing anything, check for leftover work: a project target, a package.json target or a `targetDefaults` entry still uses a removed executor, or the advisory context reports a conversion error. If none applies, make no changes and stop. Treat each advisory-context item as pending work.
|
|
6
|
+
|
|
7
|
+
1. Inspect all affected projects and workspace defaults. Repair config-loading errors first. Do not restore executor registrations or install older Nx packages.
|
|
8
|
+
2. Ensure flat ESLint configs load and preserve file patterns, exclusions, rules and output flags. Do not weaken rules to make validation pass.
|
|
9
|
+
3. Register `@nx/eslint/plugin` with options/includes that preserve custom target names and mixed inferred/explicit projects. Replace remaining removed-executor targets, including those in package.json and filtered targetDefaults. Transfer their behavior before removing obsolete defaults. Preserve configurations, dependencies, cache inputs/outputs and environment behavior. Do not silently delete unsupported options or unrelated targets. Migrate old @nrwl aliases too.
|
|
10
|
+
4. Run project graph creation with the daemon and graph cache disabled (`NX_DAEMON=false NX_CACHE_PROJECT_GRAPH=false`), using the workspace package manager. Inspect resolved project targets and verify each migrated entrypoint exists and is inferred (a thin alias to an inferred target is acceptable). Resolve graph errors before completing this migration, even if task validation was skipped. Configs must load for subsequent migrations.
|
|
11
|
+
5. By default run relevant real builds/tests with task cache disabled, including alternate configurations. Honor an existing preference to skip expensive task validation; otherwise offer that option when validation is slow. Skipping expensive tasks never skips conversion or the graph check. Report each skipped task as unverified. Never weaken assertions or change application behavior to make checks pass.
|
|
12
|
+
6. Report converted projects, graph validation, task results and any skipped checks. Unconverted targets or a broken graph mean the migration is incomplete. Investigate task failures and distinguish missing environment prerequisites from conversion regressions; do not claim a working workspace with unresolved regressions.
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = update;
|
|
4
|
+
const internal_1 = require("@nx/devkit/internal");
|
|
5
|
+
function update(tree) {
|
|
6
|
+
return (0, internal_1.migrateRemovedExecutors)(tree, ['@nx/eslint:lint', '@nrwl/linter:eslint'], async (tree, options) => {
|
|
7
|
+
const { convertToInferred } = require('../../generators/convert-to-inferred/convert-to-inferred');
|
|
8
|
+
return convertToInferred(tree, options);
|
|
9
|
+
});
|
|
10
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
#### Convert `@nx/eslint:lint` targets to inferred tasks
|
|
2
|
+
|
|
3
|
+
Nx 24 removes the `@nx/eslint:lint` executor and its `@nrwl/linter:eslint` alias. The migration registers `@nx/eslint/plugin` in `nx.json` and converts the targets that use those executors to inferred tasks. Options the plugin does not infer stay on the target. A target with nothing left to override is removed from project configuration. When several projects share the same remaining options, those options move to a `targetDefaults` entry scoped to the plugin. `targetDefaults` entries keyed by a removed executor are removed once no target uses that executor.
|
|
4
|
+
|
|
5
|
+
The migration lists the targets the converter cannot convert safely. In agentic runs, an AI prompt finishes them and validates the project graph.
|
|
6
|
+
|
|
7
|
+
#### Sample code changes
|
|
8
|
+
|
|
9
|
+
##### Before
|
|
10
|
+
|
|
11
|
+
```json title="myapp/project.json"
|
|
12
|
+
{
|
|
13
|
+
"name": "myapp",
|
|
14
|
+
"targets": {
|
|
15
|
+
"lint": {
|
|
16
|
+
"executor": "@nx/eslint:lint",
|
|
17
|
+
"options": {
|
|
18
|
+
"eslintConfig": "myapp/.eslintrc.json"
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
##### After
|
|
26
|
+
|
|
27
|
+
```json title="nx.json"
|
|
28
|
+
{
|
|
29
|
+
"plugins": [
|
|
30
|
+
{
|
|
31
|
+
"plugin": "@nx/eslint/plugin",
|
|
32
|
+
"options": {
|
|
33
|
+
"targetName": "lint"
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
]
|
|
37
|
+
}
|
|
38
|
+
```
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = update;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
// Generators that declared `setParserOptionsProject` in Nx 23 and still exist in Nx 24.
|
|
6
|
+
const GENERATORS = {
|
|
7
|
+
'@nx/angular': ['add-linting', 'application', 'library'],
|
|
8
|
+
'@nx/cypress': ['configuration'],
|
|
9
|
+
'@nx/detox': ['application'],
|
|
10
|
+
'@nx/expo': ['application', 'library'],
|
|
11
|
+
'@nx/express': ['application'],
|
|
12
|
+
'@nx/js': ['library'],
|
|
13
|
+
'@nx/nest': ['application', 'library'],
|
|
14
|
+
'@nx/next': ['application', 'library'],
|
|
15
|
+
'@nx/node': ['application', 'library'],
|
|
16
|
+
'@nx/nuxt': ['application'],
|
|
17
|
+
'@nx/playwright': ['configuration'],
|
|
18
|
+
'@nx/plugin': ['plugin'],
|
|
19
|
+
'@nx/react': ['application', 'library'],
|
|
20
|
+
'@nx/react-native': ['application', 'library'],
|
|
21
|
+
'@nx/vue': ['application', 'library'],
|
|
22
|
+
'@nx/web': ['application'],
|
|
23
|
+
};
|
|
24
|
+
const REMOVED = 'setParserOptionsProject';
|
|
25
|
+
const REPLACEMENT = 'enableTypedLinting';
|
|
26
|
+
async function update(tree) {
|
|
27
|
+
let changed = false;
|
|
28
|
+
const nxJson = (0, devkit_1.readNxJson)(tree);
|
|
29
|
+
const fromNxJson = new Map();
|
|
30
|
+
if (nxJson && migrateGenerators([nxJson], fromNxJson)[0]) {
|
|
31
|
+
(0, devkit_1.updateNxJson)(tree, nxJson);
|
|
32
|
+
changed = true;
|
|
33
|
+
}
|
|
34
|
+
const angularJson = tree.exists('angular.json')
|
|
35
|
+
? (0, devkit_1.readJson)(tree, 'angular.json')
|
|
36
|
+
: undefined;
|
|
37
|
+
let angularJsonChanged = false;
|
|
38
|
+
for (const [projectName, { root }] of (0, devkit_1.getProjects)(tree)) {
|
|
39
|
+
// Edit each file in place: `updateProjectConfiguration` would write the
|
|
40
|
+
// merged configuration to `project.json` and leave `package.json` as is.
|
|
41
|
+
const packageJsonPath = (0, devkit_1.joinPathFragments)(root, 'package.json');
|
|
42
|
+
const projectJsonPath = (0, devkit_1.joinPathFragments)(root, 'project.json');
|
|
43
|
+
const packageJson = tree.exists(packageJsonPath)
|
|
44
|
+
? (0, devkit_1.readJson)(tree, packageJsonPath)
|
|
45
|
+
: undefined;
|
|
46
|
+
const projectJson = tree.exists(projectJsonPath)
|
|
47
|
+
? (0, devkit_1.readJson)(tree, projectJsonPath)
|
|
48
|
+
: undefined;
|
|
49
|
+
// Nx reads an `angular.json` project's `schematics` as its `generators`.
|
|
50
|
+
const angularJsonProject = angularJson?.projects?.[projectName];
|
|
51
|
+
const angularJsonKey = angularJsonProject?.schematics !== undefined
|
|
52
|
+
? 'schematics'
|
|
53
|
+
: 'generators';
|
|
54
|
+
const angularJsonDefaults = {
|
|
55
|
+
generators: angularJsonProject?.[angularJsonKey],
|
|
56
|
+
};
|
|
57
|
+
// Nx merges `angular.json`, then `package.json`, then `project.json`.
|
|
58
|
+
const [angularJsonProjectChanged, packageJsonChanged, projectJsonChanged] = migrateGenerators([
|
|
59
|
+
angularJsonDefaults,
|
|
60
|
+
isRecord(packageJson?.nx) ? packageJson.nx : {},
|
|
61
|
+
projectJson ?? {},
|
|
62
|
+
], new Map(fromNxJson));
|
|
63
|
+
if (angularJsonProjectChanged) {
|
|
64
|
+
if (!angularJsonDefaults.generators) {
|
|
65
|
+
delete angularJsonProject[angularJsonKey];
|
|
66
|
+
}
|
|
67
|
+
angularJsonChanged = true;
|
|
68
|
+
}
|
|
69
|
+
if (packageJsonChanged) {
|
|
70
|
+
(0, devkit_1.writeJson)(tree, packageJsonPath, packageJson);
|
|
71
|
+
changed = true;
|
|
72
|
+
}
|
|
73
|
+
if (projectJsonChanged) {
|
|
74
|
+
(0, devkit_1.writeJson)(tree, projectJsonPath, projectJson);
|
|
75
|
+
changed = true;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
if (angularJsonChanged) {
|
|
79
|
+
(0, devkit_1.writeJson)(tree, 'angular.json', angularJson);
|
|
80
|
+
changed = true;
|
|
81
|
+
}
|
|
82
|
+
if (!changed) {
|
|
83
|
+
return { skipAgentic: true };
|
|
84
|
+
}
|
|
85
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Rewrites the defaults so the merged `enableTypedLinting` equals the pre-migration
|
|
89
|
+
* `enableTypedLinting || setParserOptionsProject`. `owners` merge in order, a later
|
|
90
|
+
* one taking precedence. `resolutions` holds the layers beneath `owners` and is
|
|
91
|
+
* updated to include them. Returns which owners changed.
|
|
92
|
+
*/
|
|
93
|
+
function migrateGenerators(owners, resolutions) {
|
|
94
|
+
const changed = owners.map(() => false);
|
|
95
|
+
const sources = owners.map((owner) => isRecord(owner.generators) ? owner.generators : undefined);
|
|
96
|
+
for (const [collection, names] of Object.entries(GENERATORS)) {
|
|
97
|
+
for (const name of names) {
|
|
98
|
+
const flatKey = `${collection}:${name}`;
|
|
99
|
+
const beneath = resolutions.get(flatKey) ?? {
|
|
100
|
+
enableTypedLinting: false,
|
|
101
|
+
setParserOptionsProject: false,
|
|
102
|
+
};
|
|
103
|
+
// Nested before flat: the order `getGeneratorDefaults` merges them in.
|
|
104
|
+
// A later owner's nested entry replaces an earlier one's entirely.
|
|
105
|
+
let resolution = beneath;
|
|
106
|
+
for (const [i, generators] of sources.entries()) {
|
|
107
|
+
const nested = generators?.[collection];
|
|
108
|
+
if (!isRecord(nested) || !(name in nested)) {
|
|
109
|
+
continue;
|
|
110
|
+
}
|
|
111
|
+
const result = migrateEntry(nested, name, beneath);
|
|
112
|
+
resolution = result.resolution;
|
|
113
|
+
if (result.changed) {
|
|
114
|
+
changed[i] = true;
|
|
115
|
+
if (isEmpty(nested)) {
|
|
116
|
+
delete generators[collection];
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
// Flat entries merge option by option.
|
|
121
|
+
for (const [i, generators] of sources.entries()) {
|
|
122
|
+
if (!generators) {
|
|
123
|
+
continue;
|
|
124
|
+
}
|
|
125
|
+
const result = migrateEntry(generators, flatKey, resolution);
|
|
126
|
+
resolution = result.resolution;
|
|
127
|
+
if (result.changed) {
|
|
128
|
+
changed[i] = true;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
resolutions.set(flatKey, resolution);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
for (const [i, owner] of owners.entries()) {
|
|
135
|
+
if (changed[i] && isEmpty(owner.generators)) {
|
|
136
|
+
delete owner.generators;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
return changed;
|
|
140
|
+
}
|
|
141
|
+
/** Migrates `container[key]` and removes it when the migration leaves it empty. */
|
|
142
|
+
function migrateEntry(container, key, below) {
|
|
143
|
+
const defaults = container[key];
|
|
144
|
+
if (!isRecord(defaults)) {
|
|
145
|
+
return { resolution: below, changed: false };
|
|
146
|
+
}
|
|
147
|
+
const result = migrateDefaults(defaults, below);
|
|
148
|
+
if (result.changed && isEmpty(defaults)) {
|
|
149
|
+
delete container[key];
|
|
150
|
+
}
|
|
151
|
+
return result;
|
|
152
|
+
}
|
|
153
|
+
function migrateDefaults(defaults, below) {
|
|
154
|
+
const hasRemoved = REMOVED in defaults;
|
|
155
|
+
const hasReplacement = REPLACEMENT in defaults;
|
|
156
|
+
if (!hasRemoved && !hasReplacement) {
|
|
157
|
+
return { resolution: below, changed: false };
|
|
158
|
+
}
|
|
159
|
+
const resolution = {
|
|
160
|
+
enableTypedLinting: hasReplacement
|
|
161
|
+
? toBoolean(defaults[REPLACEMENT])
|
|
162
|
+
: below.enableTypedLinting,
|
|
163
|
+
setParserOptionsProject: hasRemoved
|
|
164
|
+
? toBoolean(defaults[REMOVED])
|
|
165
|
+
: below.setParserOptionsProject,
|
|
166
|
+
};
|
|
167
|
+
const expected = resolution.enableTypedLinting || resolution.setParserOptionsProject;
|
|
168
|
+
// Layers beneath this one are already migrated to their own merged value.
|
|
169
|
+
const migratedWithoutChange = hasReplacement
|
|
170
|
+
? toBoolean(defaults[REPLACEMENT])
|
|
171
|
+
: below.enableTypedLinting || below.setParserOptionsProject;
|
|
172
|
+
let changed = false;
|
|
173
|
+
if (hasRemoved) {
|
|
174
|
+
delete defaults[REMOVED];
|
|
175
|
+
changed = true;
|
|
176
|
+
}
|
|
177
|
+
if (migratedWithoutChange !== expected) {
|
|
178
|
+
defaults[REPLACEMENT] = expected;
|
|
179
|
+
changed = true;
|
|
180
|
+
}
|
|
181
|
+
return { resolution, changed };
|
|
182
|
+
}
|
|
183
|
+
// Mirrors how nx coerces a boolean option: only `true` and `'true'` enable it.
|
|
184
|
+
function toBoolean(value) {
|
|
185
|
+
return value === true || value === 'true';
|
|
186
|
+
}
|
|
187
|
+
function isRecord(value) {
|
|
188
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
189
|
+
}
|
|
190
|
+
function isEmpty(value) {
|
|
191
|
+
return Object.keys(value).length === 0;
|
|
192
|
+
}
|