@nx/eslint 23.0.0-beta.1 → 23.0.0-beta.10
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/package.json +5 -5
- package/src/executors/lint/lint.impl.d.ts.map +1 -1
- package/src/executors/lint/lint.impl.js +2 -0
- package/src/executors/lint/schema.json +1 -0
- package/src/generators/convert-to-flat-config/converters/json-converter.d.ts +1 -0
- package/src/generators/convert-to-flat-config/converters/json-converter.d.ts.map +1 -1
- package/src/generators/convert-to-flat-config/converters/json-converter.js +76 -16
- package/src/generators/convert-to-flat-config/generator.d.ts.map +1 -1
- package/src/generators/convert-to-flat-config/generator.js +94 -20
- package/src/generators/convert-to-flat-config/schema.json +7 -0
- package/src/generators/convert-to-inferred/convert-to-inferred.d.ts.map +1 -1
- package/src/generators/convert-to-inferred/convert-to-inferred.js +4 -5
- package/src/generators/init/init.d.ts.map +1 -1
- package/src/generators/init/init.js +3 -3
- package/src/generators/lint-project/lint-project.d.ts.map +1 -1
- package/src/generators/lint-project/lint-project.js +2 -0
- package/src/generators/utils/eslint-targets.js +4 -4
- package/src/generators/utils/flat-config/ast-utils.d.ts +1 -1
- package/src/generators/utils/flat-config/ast-utils.d.ts.map +1 -1
- package/src/generators/utils/flat-config/ast-utils.js +19 -16
- package/src/generators/workspace-rule/workspace-rule.d.ts.map +1 -1
- package/src/generators/workspace-rule/workspace-rule.js +2 -2
- package/src/plugins/plugin.d.ts.map +1 -1
- package/src/plugins/plugin.js +12 -19
- package/src/utils/deprecation.d.ts +4 -0
- package/src/utils/deprecation.d.ts.map +1 -0
- package/src/utils/deprecation.js +15 -0
- package/src/utils/version-utils.js +5 -5
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.10",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "The ESLint plugin for Nx contains executors, generators and utilities used for linting JavaScript/TypeScript projects within an Nx workspace.",
|
|
6
6
|
"repository": {
|
|
@@ -32,19 +32,19 @@
|
|
|
32
32
|
"generators": "./generators.json",
|
|
33
33
|
"executors": "./executors.json",
|
|
34
34
|
"peerDependencies": {
|
|
35
|
-
"@nx/jest": "23.0.0-beta.
|
|
35
|
+
"@nx/jest": "23.0.0-beta.10",
|
|
36
36
|
"@zkochan/js-yaml": "0.0.7",
|
|
37
37
|
"eslint": "^8.0.0 || ^9.0.0 || ^10.0.0"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@nx/devkit": "23.0.0-beta.
|
|
41
|
-
"@nx/js": "23.0.0-beta.
|
|
40
|
+
"@nx/devkit": "23.0.0-beta.10",
|
|
41
|
+
"@nx/js": "23.0.0-beta.10",
|
|
42
42
|
"semver": "^7.6.3",
|
|
43
43
|
"tslib": "^2.3.0",
|
|
44
44
|
"typescript": "~5.9.2"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"nx": "23.0.0-beta.
|
|
47
|
+
"nx": "23.0.0-beta.10"
|
|
48
48
|
},
|
|
49
49
|
"peerDependenciesMeta": {
|
|
50
50
|
"@nx/jest": {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lint.impl.d.ts","sourceRoot":"","sources":["../../../../../../packages/eslint/src/executors/lint/lint.impl.ts"],"names":[],"mappings":"AAAA,OAAO,EAA6B,KAAK,eAAe,EAAE,MAAM,YAAY,CAAC;AAM7E,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"lint.impl.d.ts","sourceRoot":"","sources":["../../../../../../packages/eslint/src/executors/lint/lint.impl.ts"],"names":[],"mappings":"AAAA,OAAO,EAA6B,KAAK,eAAe,EAAE,MAAM,YAAY,CAAC;AAM7E,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAIvC,wBAA8B,GAAG,CAC/B,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,eAAe,GACvB,OAAO,CAAC;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC,CA0N/B"}
|
|
@@ -7,7 +7,9 @@ const utils_1 = require("nx/src/tasks-runner/utils");
|
|
|
7
7
|
const path_1 = require("path");
|
|
8
8
|
const config_file_1 = require("../../utils/config-file");
|
|
9
9
|
const eslint_utils_1 = require("./utility/eslint-utils");
|
|
10
|
+
const deprecation_1 = require("../../utils/deprecation");
|
|
10
11
|
async function run(options, context) {
|
|
12
|
+
(0, deprecation_1.warnEslintExecutorDeprecation)();
|
|
11
13
|
// hasTypeAwareRules is deprecated and no longer used, delete it so it's not passed to ESLint
|
|
12
14
|
delete options.hasTypeAwareRules;
|
|
13
15
|
const systemRoot = context.root;
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
"description": "ESLint Lint Target.",
|
|
7
7
|
"cli": "nx",
|
|
8
8
|
"type": "object",
|
|
9
|
+
"x-deprecated": "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 plugin. See https://nx.dev/docs/guides/tasks--caching/convert-to-inferred for details.",
|
|
9
10
|
"properties": {
|
|
10
11
|
"eslintConfig": {
|
|
11
12
|
"type": "string",
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Tree } from '@nx/devkit';
|
|
2
2
|
import { ESLint } from 'eslint';
|
|
3
|
+
export declare function renameLegacyEslintrcFile(path: string, format: 'mjs' | 'cjs'): string;
|
|
3
4
|
/**
|
|
4
5
|
* Converts an ESLint JSON config to a flat config.
|
|
5
6
|
* Deletes the original file along with .eslintignore if it exists.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"json-converter.d.ts","sourceRoot":"","sources":["../../../../../../../packages/eslint/src/generators/convert-to-flat-config/converters/json-converter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAS,MAAM,YAAY,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"json-converter.d.ts","sourceRoot":"","sources":["../../../../../../../packages/eslint/src/generators/convert-to-flat-config/converters/json-converter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAS,MAAM,YAAY,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAmBhC,wBAAgB,wBAAwB,CACtC,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,KAAK,GAAG,KAAK,GACpB,MAAM,CAOR;AA0DD;;;GAGG;AACH,wBAAgB,6BAA6B,CAC3C,IAAI,EAAE,IAAI,EACV,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,CAAC,UAAU,EACzB,WAAW,EAAE,MAAM,EAAE,EACrB,MAAM,EAAE,KAAK,GAAG,KAAK,GACpB;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,OAAO,CAAC;IAAC,WAAW,EAAE,OAAO,CAAA;CAAE,CA6PjE"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.renameLegacyEslintrcFile = renameLegacyEslintrcFile;
|
|
3
4
|
exports.convertEslintJsonToFlatConfig = convertEslintJsonToFlatConfig;
|
|
4
5
|
const tslib_1 = require("tslib");
|
|
5
6
|
const devkit_1 = require("@nx/devkit");
|
|
@@ -7,6 +8,57 @@ const ts = tslib_1.__importStar(require("typescript"));
|
|
|
7
8
|
const ast_utils_1 = require("../../utils/flat-config/ast-utils");
|
|
8
9
|
const eslint_file_1 = require("../../utils/eslint-file");
|
|
9
10
|
const path_utils_1 = require("../../utils/flat-config/path-utils");
|
|
11
|
+
// Rewrites legacy `.eslintrc[.base][.json]` / `.eslintignore` filenames to their flat-config
|
|
12
|
+
// counterparts. Used for `extends` local paths, rule option values that embed these filenames,
|
|
13
|
+
// and nx.json / project.json input globs that referenced the deleted files. Accepts
|
|
14
|
+
// extensionless `.eslintrc` since ESLint treats that as JSON by convention.
|
|
15
|
+
function renameLegacyEslintrcFile(path, format) {
|
|
16
|
+
return path
|
|
17
|
+
.replace(/(^|.*?)\.eslintrc(\.base)?(\.json)?$/, `$1eslint$2.config.${format}`)
|
|
18
|
+
.replace(/(^|.*?)\.eslintignore$/, `$1eslint.config.${format}`);
|
|
19
|
+
}
|
|
20
|
+
// In flat config, `@nx/workspace/<rule>` is parsed as plugin `@nx/workspace`, rule `<rule>`.
|
|
21
|
+
// The `@nx` plugin already exposes workspace rules under both `workspace/<rule>` and `workspace-<rule>` keys.
|
|
22
|
+
// Rewriting to `@nx/workspace-<rule>` makes ESLint resolve them via the already-registered `@nx` plugin.
|
|
23
|
+
function renameLegacyWorkspaceRules(rules) {
|
|
24
|
+
const renamed = {};
|
|
25
|
+
for (const [key, value] of Object.entries(rules)) {
|
|
26
|
+
const newKey = key.startsWith('@nx/workspace/')
|
|
27
|
+
? '@nx/workspace-' + key.slice('@nx/workspace/'.length)
|
|
28
|
+
: key;
|
|
29
|
+
renamed[newKey] = value;
|
|
30
|
+
}
|
|
31
|
+
return renamed;
|
|
32
|
+
}
|
|
33
|
+
// Rewrites references to the legacy `.eslintrc[.base].json` / `.eslintignore` that may appear
|
|
34
|
+
// inside rule option values (e.g. `@nx/dependency-checks`'s `ignoredFiles`) to point at the
|
|
35
|
+
// generated flat-config files instead. Without this, rule options keep pointing at files that
|
|
36
|
+
// no longer exist after the conversion.
|
|
37
|
+
function rewriteStaleEslintrcRefs(value, format) {
|
|
38
|
+
if (typeof value === 'string') {
|
|
39
|
+
return renameLegacyEslintrcFile(value, format);
|
|
40
|
+
}
|
|
41
|
+
if (Array.isArray(value)) {
|
|
42
|
+
const mapped = value.map((v) => rewriteStaleEslintrcRefs(v, format));
|
|
43
|
+
// Rewriting may collapse distinct strings (e.g. `.eslintrc.json` and
|
|
44
|
+
// `.eslintrc.base.json`) into identical entries; dedupe string arrays.
|
|
45
|
+
if (mapped.every((v) => typeof v === 'string')) {
|
|
46
|
+
return Array.from(new Set(mapped));
|
|
47
|
+
}
|
|
48
|
+
return mapped;
|
|
49
|
+
}
|
|
50
|
+
if (value && typeof value === 'object') {
|
|
51
|
+
const out = {};
|
|
52
|
+
for (const [k, v] of Object.entries(value)) {
|
|
53
|
+
out[k] = rewriteStaleEslintrcRefs(v, format);
|
|
54
|
+
}
|
|
55
|
+
return out;
|
|
56
|
+
}
|
|
57
|
+
return value;
|
|
58
|
+
}
|
|
59
|
+
function preprocessRules(rules, format) {
|
|
60
|
+
return rewriteStaleEslintrcRefs(renameLegacyWorkspaceRules(rules), format);
|
|
61
|
+
}
|
|
10
62
|
/**
|
|
11
63
|
* Converts an ESLint JSON config to a flat config.
|
|
12
64
|
* Deletes the original file along with .eslintignore if it exists.
|
|
@@ -18,10 +70,17 @@ function convertEslintJsonToFlatConfig(tree, root, config, ignorePaths, format)
|
|
|
18
70
|
let isESLintJSNeeded = false;
|
|
19
71
|
let combinedConfig = [];
|
|
20
72
|
let languageOptions = [];
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
73
|
+
if (config.rules) {
|
|
74
|
+
config.rules = preprocessRules(config.rules, format);
|
|
75
|
+
}
|
|
76
|
+
if (config.overrides) {
|
|
77
|
+
config.overrides = config.overrides.map((override) => override.rules
|
|
78
|
+
? {
|
|
79
|
+
...override,
|
|
80
|
+
rules: preprocessRules(override.rules, format),
|
|
81
|
+
}
|
|
82
|
+
: override);
|
|
83
|
+
}
|
|
25
84
|
if (config.extends) {
|
|
26
85
|
const extendsResult = addExtends(importsMap, exportElements, config, format);
|
|
27
86
|
isFlatCompatNeeded = extendsResult.isFlatCompatNeeded;
|
|
@@ -101,28 +160,30 @@ function convertEslintJsonToFlatConfig(tree, root, config, ignorePaths, format)
|
|
|
101
160
|
if (Object.keys(remainingRest).length > 0 || hasNonEmptyRules) {
|
|
102
161
|
if (remainingOverride.env ||
|
|
103
162
|
remainingOverride.extends ||
|
|
104
|
-
remainingOverride.plugins
|
|
105
|
-
remainingOverride.parser) {
|
|
163
|
+
remainingOverride.plugins) {
|
|
106
164
|
isFlatCompatNeeded = true;
|
|
107
165
|
}
|
|
108
|
-
exportElements.push((0, ast_utils_1.generateFlatOverride)(remainingOverride, format));
|
|
166
|
+
exportElements.push((0, ast_utils_1.generateFlatOverride)(remainingOverride, format, importsMap));
|
|
109
167
|
}
|
|
110
168
|
return;
|
|
111
169
|
}
|
|
112
170
|
}
|
|
113
|
-
if (override.env ||
|
|
114
|
-
override.extends ||
|
|
115
|
-
override.plugins ||
|
|
116
|
-
override.parser) {
|
|
171
|
+
if (override.env || override.extends || override.plugins) {
|
|
117
172
|
isFlatCompatNeeded = true;
|
|
118
173
|
}
|
|
119
|
-
exportElements.push((0, ast_utils_1.generateFlatOverride)(override, format));
|
|
174
|
+
exportElements.push((0, ast_utils_1.generateFlatOverride)(override, format, importsMap));
|
|
120
175
|
});
|
|
121
176
|
}
|
|
122
177
|
if (config.ignorePatterns) {
|
|
123
178
|
const patterns = (Array.isArray(config.ignorePatterns)
|
|
124
179
|
? config.ignorePatterns
|
|
125
|
-
: [config.ignorePatterns]).filter((pattern) =>
|
|
180
|
+
: [config.ignorePatterns]).filter((pattern) =>
|
|
181
|
+
// Drop patterns that are meaningless in flat config. `'**/*'` and
|
|
182
|
+
// `'!**/*'` were eslintrc cascading toggles; `node_modules` is already
|
|
183
|
+
// ignored by default. Real negations like `['dist/**', '!dist/keep.js']`
|
|
184
|
+
// are preserved — flat config still supports un-ignoring within a
|
|
185
|
+
// broader ignores block.
|
|
186
|
+
!['**/*', '!**/*', 'node_modules'].includes(pattern));
|
|
126
187
|
if (patterns.length > 0) {
|
|
127
188
|
exportElements.push((0, ast_utils_1.generateAst)({
|
|
128
189
|
ignores: patterns.map((path) => (0, path_utils_1.mapFilePath)(path)),
|
|
@@ -165,11 +226,10 @@ function addExtends(importsMap, configBlocks, config, format) {
|
|
|
165
226
|
extendsConfig
|
|
166
227
|
.filter((imp) => imp.match(/^\.?(\.\/)/))
|
|
167
228
|
.forEach((imp, index) => {
|
|
168
|
-
if (imp.match(/\.eslintrc(
|
|
229
|
+
if (imp.match(/\.eslintrc(\.base)?(\.json)?$/)) {
|
|
169
230
|
const localName = index ? `baseConfig${index}` : 'baseConfig';
|
|
170
231
|
configBlocks.push((0, ast_utils_1.generateSpreadElement)(localName));
|
|
171
|
-
|
|
172
|
-
importsMap.set(newImport, localName);
|
|
232
|
+
importsMap.set(renameLegacyEslintrcFile(imp, format), localName);
|
|
173
233
|
}
|
|
174
234
|
else {
|
|
175
235
|
eslintrcConfigs.push(imp);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../../../../../../packages/eslint/src/generators/convert-to-flat-config/generator.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,iBAAiB,EASjB,IAAI,EAGL,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../../../../../../packages/eslint/src/generators/convert-to-flat-config/generator.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,iBAAiB,EASjB,IAAI,EAGL,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,kCAAkC,EAAE,MAAM,UAAU,CAAC;AAiB9D,wBAAsB,4BAA4B,CAChD,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,kCAAkC,GAC1C,OAAO,CAAC,IAAI,GAAG,iBAAiB,CAAC,CA8CnC;AAED,eAAe,4BAA4B,CAAC"}
|
|
@@ -28,8 +28,9 @@ async function convertToFlatConfigGenerator(tree, options) {
|
|
|
28
28
|
for (const ignoreFile of eslintIgnoreFiles) {
|
|
29
29
|
tree.delete(ignoreFile);
|
|
30
30
|
}
|
|
31
|
-
// replace references in nx.json
|
|
31
|
+
// replace references in nx.json and project.json files
|
|
32
32
|
updateNxJsonConfig(tree, options.eslintConfigFormat);
|
|
33
|
+
updateProjectConfigsInputs(tree, options.eslintConfigFormat);
|
|
33
34
|
// install missing packages
|
|
34
35
|
if (!options.skipFormat) {
|
|
35
36
|
await (0, devkit_1.formatFiles)(tree);
|
|
@@ -86,35 +87,108 @@ function convertProjectToFlatConfig(tree, project, projectConfig, nxJson, eslint
|
|
|
86
87
|
eslintIgnoreFiles.add(ignorePath);
|
|
87
88
|
}
|
|
88
89
|
}
|
|
89
|
-
//
|
|
90
|
-
//
|
|
90
|
+
// Rewrites input entries that reference legacy `.eslintrc[.base].json` / `.eslintignore`
|
|
91
|
+
// files to their flat-config counterparts, then dedupes so the rewrite doesn't produce
|
|
92
|
+
// duplicates of entries that already pointed at the flat config. Leaves non-string /
|
|
93
|
+
// non-fileset inputs (runtime/env/dependentTasksOutputFiles/etc.) untouched.
|
|
94
|
+
function rewriteLegacyInputs(inputs, format) {
|
|
95
|
+
const seenStrings = new Set();
|
|
96
|
+
const result = [];
|
|
97
|
+
for (const entry of inputs) {
|
|
98
|
+
if (typeof entry === 'string') {
|
|
99
|
+
const rewritten = (0, json_converter_1.renameLegacyEslintrcFile)(entry, format);
|
|
100
|
+
if (seenStrings.has(rewritten))
|
|
101
|
+
continue;
|
|
102
|
+
seenStrings.add(rewritten);
|
|
103
|
+
result.push(rewritten);
|
|
104
|
+
}
|
|
105
|
+
else if ('fileset' in entry) {
|
|
106
|
+
const rewritten = (0, json_converter_1.renameLegacyEslintrcFile)(entry.fileset, format);
|
|
107
|
+
// Preserve the original reference when nothing changed so downstream identity
|
|
108
|
+
// checks (e.g. `inputsEqual`) don't see a spurious mutation.
|
|
109
|
+
result.push(rewritten === entry.fileset ? entry : { ...entry, fileset: rewritten });
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
result.push(entry);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
return result;
|
|
116
|
+
}
|
|
117
|
+
// Adds `value` to `inputs` (after rewriting) when the rewritten set doesn't already contain it.
|
|
118
|
+
function ensureInputPresent(inputs, value, format) {
|
|
119
|
+
const rewritten = rewriteLegacyInputs(inputs, format);
|
|
120
|
+
if (!rewritten.some((entry) => entry === value)) {
|
|
121
|
+
rewritten.push(value);
|
|
122
|
+
}
|
|
123
|
+
return rewritten;
|
|
124
|
+
}
|
|
125
|
+
// Updates nx.json: rewrites stale eslintrc/eslintignore references across all targetDefaults
|
|
126
|
+
// inputs and namedInputs, and ensures lint targets include the new flat config file as an input
|
|
127
|
+
// (and `production` excludes it).
|
|
91
128
|
function updateNxJsonConfig(tree, format) {
|
|
92
|
-
if (tree.exists('nx.json')) {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
129
|
+
if (!tree.exists('nx.json')) {
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
(0, devkit_1.updateJson)(tree, 'nx.json', (json) => {
|
|
133
|
+
if (json.targetDefaults) {
|
|
134
|
+
for (const [name, target] of Object.entries(json.targetDefaults)) {
|
|
135
|
+
if (!target.inputs)
|
|
136
|
+
continue;
|
|
137
|
+
const isLintTarget = name === 'lint' || name === ESLINT_LINT_EXECUTOR;
|
|
138
|
+
target.inputs = isLintTarget
|
|
139
|
+
? ensureInputPresent(target.inputs, `{workspaceRoot}/eslint.config.${format}`, format)
|
|
140
|
+
: rewriteLegacyInputs(target.inputs, format);
|
|
98
141
|
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
json.
|
|
142
|
+
}
|
|
143
|
+
if (json.namedInputs) {
|
|
144
|
+
for (const [name, inputs] of Object.entries(json.namedInputs)) {
|
|
145
|
+
json.namedInputs[name] =
|
|
146
|
+
name === 'production'
|
|
147
|
+
? ensureInputPresent(inputs, `!{projectRoot}/eslint.config.${format}`, format)
|
|
148
|
+
: rewriteLegacyInputs(inputs, format);
|
|
103
149
|
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
150
|
+
}
|
|
151
|
+
return json;
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
// Walks every project's `targets.*.inputs` and `namedInputs.*`, rewriting stale references.
|
|
155
|
+
function updateProjectConfigsInputs(tree, format) {
|
|
156
|
+
for (const [project, projectConfig] of (0, devkit_1.getProjects)(tree)) {
|
|
157
|
+
let changed = false;
|
|
158
|
+
if (projectConfig.targets) {
|
|
159
|
+
for (const target of Object.values(projectConfig.targets)) {
|
|
160
|
+
if (!target.inputs)
|
|
161
|
+
continue;
|
|
162
|
+
const rewritten = rewriteLegacyInputs(target.inputs, format);
|
|
163
|
+
if (!inputsEqual(target.inputs, rewritten)) {
|
|
164
|
+
target.inputs = rewritten;
|
|
165
|
+
changed = true;
|
|
166
|
+
}
|
|
108
167
|
}
|
|
109
|
-
|
|
110
|
-
|
|
168
|
+
}
|
|
169
|
+
if (projectConfig.namedInputs) {
|
|
170
|
+
for (const [name, inputs] of Object.entries(projectConfig.namedInputs)) {
|
|
171
|
+
const rewritten = rewriteLegacyInputs(inputs, format);
|
|
172
|
+
if (!inputsEqual(inputs, rewritten)) {
|
|
173
|
+
projectConfig.namedInputs[name] = rewritten;
|
|
174
|
+
changed = true;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
if (changed) {
|
|
179
|
+
(0, devkit_1.updateProjectConfiguration)(tree, project, projectConfig);
|
|
180
|
+
}
|
|
111
181
|
}
|
|
112
182
|
}
|
|
183
|
+
function inputsEqual(a, b) {
|
|
184
|
+
return a.length === b.length && a.every((entry, i) => entry === b[i]);
|
|
185
|
+
}
|
|
113
186
|
function convertConfigToFlatConfig(tree, root, source, target, format, ignorePath) {
|
|
114
187
|
const ignorePaths = ignorePath
|
|
115
188
|
? [ignorePath, `${root}/.eslintignore`]
|
|
116
189
|
: [`${root}/.eslintignore`];
|
|
117
|
-
|
|
190
|
+
// `.eslintrc` (no extension) is JSON by convention.
|
|
191
|
+
if (source.endsWith('.json') || (0, path_1.basename)(source) === '.eslintrc') {
|
|
118
192
|
const config = (0, devkit_1.readJson)(tree, `${root}/${source}`);
|
|
119
193
|
const conversionResult = (0, json_converter_1.convertEslintJsonToFlatConfig)(tree, root, config, ignorePaths, format);
|
|
120
194
|
return processConvertedConfig(tree, root, source, target, conversionResult);
|
|
@@ -10,6 +10,13 @@
|
|
|
10
10
|
"description": "Skip formatting files.",
|
|
11
11
|
"default": false,
|
|
12
12
|
"x-priority": "internal"
|
|
13
|
+
},
|
|
14
|
+
"eslintConfigFormat": {
|
|
15
|
+
"type": "string",
|
|
16
|
+
"description": "The format of the generated ESLint flat config files.",
|
|
17
|
+
"enum": ["mjs", "cjs"],
|
|
18
|
+
"default": "mjs",
|
|
19
|
+
"x-priority": "internal"
|
|
13
20
|
}
|
|
14
21
|
},
|
|
15
22
|
"additionalProperties": false,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"convert-to-inferred.d.ts","sourceRoot":"","sources":["../../../../../../packages/eslint/src/generators/convert-to-inferred/convert-to-inferred.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"convert-to-inferred.d.ts","sourceRoot":"","sources":["../../../../../../packages/eslint/src/generators/convert-to-inferred/convert-to-inferred.ts"],"names":[],"mappings":"AAKA,OAAO,EAKL,KAAK,IAAI,EACV,MAAM,YAAY,CAAC;AAOpB,UAAU,MAAM;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,wBAAsB,iBAAiB,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,iBA4BlE;AAyJD,eAAe,iBAAiB,CAAC"}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.convertToInferred = convertToInferred;
|
|
4
|
+
const internal_1 = require("@nx/devkit/internal");
|
|
4
5
|
const devkit_1 = require("@nx/devkit");
|
|
5
|
-
const executor_to_plugin_migrator_1 = require("@nx/devkit/src/generators/plugin-migrations/executor-to-plugin-migrator");
|
|
6
|
-
const plugin_migration_utils_1 = require("@nx/devkit/src/generators/plugin-migrations/plugin-migration-utils");
|
|
7
6
|
const posix_1 = require("node:path/posix");
|
|
8
7
|
const utils_1 = require("nx/src/tasks-runner/utils");
|
|
9
8
|
const plugin_1 = require("../../plugins/plugin");
|
|
@@ -11,7 +10,7 @@ const config_file_1 = require("../../utils/config-file");
|
|
|
11
10
|
const target_options_map_1 = require("./lib/target-options-map");
|
|
12
11
|
async function convertToInferred(tree, options) {
|
|
13
12
|
const projectGraph = await (0, devkit_1.createProjectGraphAsync)();
|
|
14
|
-
const migratedProjects = await (0,
|
|
13
|
+
const migratedProjects = await (0, internal_1.migrateProjectExecutorsToPlugin)(tree, projectGraph, '@nx/eslint/plugin', plugin_1.createNodesV2, { targetName: 'lint' }, [
|
|
15
14
|
{
|
|
16
15
|
executors: ['@nx/eslint:lint', '@nrwl/linter:eslint'],
|
|
17
16
|
postTargetTransformer,
|
|
@@ -20,7 +19,7 @@ async function convertToInferred(tree, options) {
|
|
|
20
19
|
},
|
|
21
20
|
], options.project);
|
|
22
21
|
if (migratedProjects.size === 0) {
|
|
23
|
-
throw new
|
|
22
|
+
throw new internal_1.NoTargetsToMigrateError();
|
|
24
23
|
}
|
|
25
24
|
if (!options.skipFormat) {
|
|
26
25
|
await (0, devkit_1.formatFiles)(tree);
|
|
@@ -75,7 +74,7 @@ function postTargetTransformer(target, tree, projectDetails, inferredTargetConfi
|
|
|
75
74
|
}
|
|
76
75
|
}
|
|
77
76
|
if (target.outputs) {
|
|
78
|
-
(0,
|
|
77
|
+
(0, internal_1.processTargetOutputs)(target, [], inferredTargetConfiguration, {
|
|
79
78
|
projectName: projectDetails.projectName,
|
|
80
79
|
projectRoot: projectDetails.root,
|
|
81
80
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../../../../packages/eslint/src/generators/init/init.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../../../../packages/eslint/src/generators/init/init.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,iBAAiB,EAIjB,IAAI,EAGL,MAAM,YAAY,CAAC;AAUpB,MAAM,WAAW,iBAAiB;IAChC,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB,kBAAkB,CAAC,EAAE,KAAK,GAAG,KAAK,CAAC;CACpC;AA+CD,wBAAsB,UAAU,CAC9B,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,iBAAiB,GACzB,OAAO,CAAC,iBAAiB,CAAC,CAwF5B;AAED,wBAAsB,iBAAiB,CACrC,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,iBAAiB,8BAG3B"}
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.initEsLint = initEsLint;
|
|
4
4
|
exports.lintInitGenerator = lintInitGenerator;
|
|
5
|
+
const internal_1 = require("@nx/devkit/internal");
|
|
5
6
|
const devkit_1 = require("@nx/devkit");
|
|
6
|
-
const add_plugin_1 = require("@nx/devkit/src/utils/add-plugin");
|
|
7
7
|
const versions_1 = require("../../utils/versions");
|
|
8
8
|
const eslint_file_1 = require("../utils/eslint-file");
|
|
9
9
|
const plugin_1 = require("../../plugins/plugin");
|
|
@@ -75,7 +75,7 @@ async function initEsLint(tree, options) {
|
|
|
75
75
|
'_eslint-lint',
|
|
76
76
|
];
|
|
77
77
|
if (rootEslintFile && options.addPlugin && !hasPlugin) {
|
|
78
|
-
await (0,
|
|
78
|
+
await (0, internal_1.addPlugin)(tree, graph, '@nx/eslint/plugin', plugin_1.createNodesV2, {
|
|
79
79
|
targetName: lintTargetNames,
|
|
80
80
|
}, options.updatePackageScripts);
|
|
81
81
|
return () => { };
|
|
@@ -86,7 +86,7 @@ async function initEsLint(tree, options) {
|
|
|
86
86
|
updateProductionFileset(tree, options.eslintConfigFormat);
|
|
87
87
|
updateVsCodeRecommendedExtensions(tree);
|
|
88
88
|
if (options.addPlugin) {
|
|
89
|
-
await (0,
|
|
89
|
+
await (0, internal_1.addPlugin)(tree, graph, '@nx/eslint/plugin', plugin_1.createNodesV2, {
|
|
90
90
|
targetName: lintTargetNames,
|
|
91
91
|
}, options.updatePackageScripts);
|
|
92
92
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lint-project.d.ts","sourceRoot":"","sources":["../../../../../../packages/eslint/src/generators/lint-project/lint-project.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,iBAAiB,EAQjB,IAAI,EAIL,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,MAAM,IAAI,UAAU,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"lint-project.d.ts","sourceRoot":"","sources":["../../../../../../packages/eslint/src/generators/lint-project/lint-project.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,iBAAiB,EAQjB,IAAI,EAIL,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,MAAM,IAAI,UAAU,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AA2BnE,UAAU,kBAAkB;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,UAAU,GAAG,UAAU,CAAC;IACjC,kBAAkB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC9B,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB,UAAU,EAAE,OAAO,CAAC;IACpB,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,kBAAkB,CAAC,EAAE,KAAK,GAAG,KAAK,CAAC;IAEnC;;OAEG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,8BAA8B,CAAC,EAAE,OAAO,CAAC;CAC1C;AAED,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,kBAAkB,8BAE3E;AAED,wBAAsB,4BAA4B,CAChD,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,kBAAkB,8BA6I5B"}
|
|
@@ -6,6 +6,7 @@ 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");
|
|
9
10
|
const init_migration_1 = require("../init/init-migration");
|
|
10
11
|
const project_configuration_1 = require("nx/src/generators/utils/project-configuration");
|
|
11
12
|
const flat_config_1 = require("../../utils/flat-config");
|
|
@@ -63,6 +64,7 @@ async function lintProjectGeneratorInternal(tree, options) {
|
|
|
63
64
|
}
|
|
64
65
|
}
|
|
65
66
|
else {
|
|
67
|
+
(0, deprecation_1.warnEslintExecutorGenerating)();
|
|
66
68
|
projectConfig.targets ??= {};
|
|
67
69
|
projectConfig.targets['lint'] = {
|
|
68
70
|
executor: '@nx/eslint:lint',
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getEslintTargets = getEslintTargets;
|
|
4
|
-
const
|
|
4
|
+
const internal_1 = require("@nx/devkit/internal");
|
|
5
5
|
function getEslintTargets(tree) {
|
|
6
6
|
const eslintTargetNames = new Set();
|
|
7
|
-
(0,
|
|
7
|
+
(0, internal_1.forEachExecutorOptions)(tree, '@nx/eslint:lint', (_, __, target) => {
|
|
8
8
|
eslintTargetNames.add(target);
|
|
9
9
|
});
|
|
10
|
-
(0,
|
|
10
|
+
(0, internal_1.forEachExecutorOptions)(tree, '@nx/linter:eslint', (_, __, target) => {
|
|
11
11
|
eslintTargetNames.add(target);
|
|
12
12
|
});
|
|
13
|
-
(0,
|
|
13
|
+
(0, internal_1.forEachExecutorOptions)(tree, '@nrwl/linter:eslint', (_, __, target) => {
|
|
14
14
|
eslintTargetNames.add(target);
|
|
15
15
|
});
|
|
16
16
|
return eslintTargetNames;
|
|
@@ -73,7 +73,7 @@ export declare function overrideNeedsCompat(override: Partial<Linter.ConfigOverr
|
|
|
73
73
|
*/
|
|
74
74
|
export declare function generateFlatOverride(_override: Partial<Linter.ConfigOverride<Linter.RulesRecord>> & {
|
|
75
75
|
ignores?: Linter.FlatConfig['ignores'];
|
|
76
|
-
}, format: 'mjs' | 'cjs'): ts.ObjectLiteralExpression | ts.SpreadElement;
|
|
76
|
+
}, format: 'mjs' | 'cjs', importsMap?: Map<string, string>): ts.ObjectLiteralExpression | ts.SpreadElement;
|
|
77
77
|
export declare function generateFlatPredefinedConfig(predefinedConfigName: string, moduleName?: string, spread?: boolean): ts.ObjectLiteralExpression | ts.SpreadElement | ts.ElementAccessExpression;
|
|
78
78
|
export declare function mapFilePaths<T extends Partial<Linter.ConfigOverride<Linter.RulesRecord>>>(_override: T): T;
|
|
79
79
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ast-utils.d.ts","sourceRoot":"","sources":["../../../../../../../packages/eslint/src/generators/utils/flat-config/ast-utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ast-utils.d.ts","sourceRoot":"","sources":["../../../../../../../packages/eslint/src/generators/utils/flat-config/ast-utils.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC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YD;;GAEG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAC3B,KAAK,EAAE,OAAO,EACd,0BAA0B,CAAC,EAAE;IAC3B,UAAU,EAAE,MAAM,GAAG,MAAM,CAAC;IAC5B,QAAQ,EAAE,CACR,kBAAkB,EAAE,EAAE,CAAC,kBAAkB,EACzC,YAAY,EAAE,MAAM,KACjB,EAAE,CAAC,kBAAkB,CAAC;CAC5B,GACA,CAAC,CAuCH"}
|
|
@@ -1101,7 +1101,7 @@ function overrideNeedsCompat(override) {
|
|
|
1101
1101
|
* Generates an AST object or spread element representing a modern flat config entry,
|
|
1102
1102
|
* based on a given legacy eslintrc JSON override object
|
|
1103
1103
|
*/
|
|
1104
|
-
function generateFlatOverride(_override, format) {
|
|
1104
|
+
function generateFlatOverride(_override, format, importsMap) {
|
|
1105
1105
|
const override = mapFilePaths(_override);
|
|
1106
1106
|
// We do not need the compat tooling for this override
|
|
1107
1107
|
if (!overrideNeedsCompat(override)) {
|
|
@@ -1159,7 +1159,7 @@ function generateFlatOverride(_override, format) {
|
|
|
1159
1159
|
else {
|
|
1160
1160
|
// Change parser to import statement.
|
|
1161
1161
|
return format === 'mjs'
|
|
1162
|
-
? generateESMParserImport(override)
|
|
1162
|
+
? generateESMParserImport(override, importsMap)
|
|
1163
1163
|
: generateCJSParserImport(override);
|
|
1164
1164
|
}
|
|
1165
1165
|
},
|
|
@@ -1215,12 +1215,19 @@ function generateFlatOverride(_override, format) {
|
|
|
1215
1215
|
], undefined, ts.factory.createToken(ts.SyntaxKind.EqualsGreaterThanToken), ts.factory.createParenthesizedExpression(ts.factory.createObjectLiteralExpression(objectLiteralElements, true))),
|
|
1216
1216
|
]));
|
|
1217
1217
|
}
|
|
1218
|
-
function generateESMParserImport(override) {
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1218
|
+
function generateESMParserImport(override, importsMap) {
|
|
1219
|
+
const parser = override['languageOptions']?.['parserOptions']?.parser ??
|
|
1220
|
+
override['languageOptions']?.parser ??
|
|
1221
|
+
override.parser;
|
|
1222
|
+
// Dynamic `await import()` doesn't expose top-level CJS exports (e.g. `parseForESLint`)
|
|
1223
|
+
// because those are nested under `.default`. Use a hoisted static import instead so the
|
|
1224
|
+
// resolved binding matches the parser's module.exports shape.
|
|
1225
|
+
if (importsMap) {
|
|
1226
|
+
const parserName = importsMap.get(parser) ?? (0, devkit_1.names)(parser).propertyName;
|
|
1227
|
+
importsMap.set(parser, parserName);
|
|
1228
|
+
return ts.factory.createPropertyAssignment('parser', ts.factory.createIdentifier(parserName));
|
|
1229
|
+
}
|
|
1230
|
+
return ts.factory.createPropertyAssignment('parser', ts.factory.createAwaitExpression(ts.factory.createCallExpression(ts.factory.createIdentifier('import'), undefined, [ts.factory.createStringLiteral(parser)])));
|
|
1224
1231
|
}
|
|
1225
1232
|
function generateCJSParserImport(override) {
|
|
1226
1233
|
return ts.factory.createPropertyAssignment('parser', ts.factory.createCallExpression(ts.factory.createIdentifier('require'), undefined, [
|
|
@@ -1237,17 +1244,13 @@ function mapFilePaths(_override) {
|
|
|
1237
1244
|
const override = {
|
|
1238
1245
|
..._override,
|
|
1239
1246
|
};
|
|
1247
|
+
// Dedupe after mapping — both source-side duplicates and glob-mapping collisions collapse.
|
|
1248
|
+
const normalize = (value) => Array.from(new Set((Array.isArray(value) ? value : [value]).map(path_utils_1.mapFilePath)));
|
|
1240
1249
|
if (override.files) {
|
|
1241
|
-
override.files =
|
|
1242
|
-
? override.files
|
|
1243
|
-
: [override.files];
|
|
1244
|
-
override.files = override.files.map((file) => (0, path_utils_1.mapFilePath)(file));
|
|
1250
|
+
override.files = normalize(override.files);
|
|
1245
1251
|
}
|
|
1246
1252
|
if (override.excludedFiles) {
|
|
1247
|
-
override.excludedFiles =
|
|
1248
|
-
? override.excludedFiles
|
|
1249
|
-
: [override.excludedFiles];
|
|
1250
|
-
override.excludedFiles = override.excludedFiles.map((file) => (0, path_utils_1.mapFilePath)(file));
|
|
1253
|
+
override.excludedFiles = normalize(override.excludedFiles);
|
|
1251
1254
|
}
|
|
1252
1255
|
return override;
|
|
1253
1256
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workspace-rule.d.ts","sourceRoot":"","sources":["../../../../../../packages/eslint/src/generators/workspace-rule/workspace-rule.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"workspace-rule.d.ts","sourceRoot":"","sources":["../../../../../../packages/eslint/src/generators/workspace-rule/workspace-rule.ts"],"names":[],"mappings":"AACA,OAAO,EAML,iBAAiB,EAKjB,IAAI,EACL,MAAM,YAAY,CAAC;AAQpB,MAAM,WAAW,iCAAiC;IAChD,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,wBAAsB,0BAA0B,CAC9C,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,iCAAiC,8BAiH3C"}
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.lintWorkspaceRuleGenerator = lintWorkspaceRuleGenerator;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
+
const internal_1 = require("@nx/devkit/internal");
|
|
5
6
|
const devkit_1 = require("@nx/devkit");
|
|
6
|
-
const string_utils_1 = require("@nx/devkit/src/utils/string-utils");
|
|
7
7
|
const path_1 = require("path");
|
|
8
8
|
const ts = tslib_1.__importStar(require("typescript"));
|
|
9
9
|
const workspace_lint_rules_1 = require("../../utils/workspace-lint-rules");
|
|
@@ -30,7 +30,7 @@ async function lintWorkspaceRuleGenerator(tree, options) {
|
|
|
30
30
|
name: options.name,
|
|
31
31
|
flatConfig,
|
|
32
32
|
});
|
|
33
|
-
const nameCamelCase = (0,
|
|
33
|
+
const nameCamelCase = (0, internal_1.camelize)(options.name);
|
|
34
34
|
/**
|
|
35
35
|
* Import the new rule into the workspace plugin index.ts and
|
|
36
36
|
* register it ready for use in lint configs.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../../../packages/eslint/src/plugins/plugin.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../../../packages/eslint/src/plugins/plugin.ts"],"names":[],"mappings":"AAIA,OAAO,EAIL,aAAa,EAId,MAAM,YAAY,CAAC;AAuBpB,MAAM,WAAW,mBAAmB;IAClC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;CACvB;AA2GD,eAAO,MAAM,WAAW,EAAE,aAAa,CAAC,mBAAmB,CAoF1D,CAAC;AAEF,eAAO,MAAM,aAAa,oCAAc,CAAC"}
|
package/src/plugins/plugin.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createNodesV2 = exports.createNodes = void 0;
|
|
4
|
+
const internal_1 = require("@nx/devkit/internal");
|
|
4
5
|
const devkit_1 = require("@nx/devkit");
|
|
5
|
-
const calculate_hash_for_create_nodes_1 = require("@nx/devkit/src/utils/calculate-hash-for-create-nodes");
|
|
6
6
|
const js_1 = require("@nx/js");
|
|
7
|
-
const
|
|
7
|
+
const internal_2 = require("@nx/js/src/internal");
|
|
8
8
|
const node_fs_1 = require("node:fs");
|
|
9
9
|
const node_path_1 = require("node:path");
|
|
10
10
|
const posix_1 = require("node:path/posix");
|
|
@@ -32,14 +32,6 @@ const ESLINT_CONFIG_GLOB_V2 = (0, globs_1.combineGlobPatterns)([
|
|
|
32
32
|
...config_file_1.ESLINT_CONFIG_FILENAMES.map((f) => `**/${f}`),
|
|
33
33
|
...PROJECT_CONFIG_FILENAMES.map((f) => `**/${f}`),
|
|
34
34
|
]);
|
|
35
|
-
function readTargetsCache(cachePath) {
|
|
36
|
-
return process.env.NX_CACHE_PROJECT_GRAPH !== 'false' && (0, node_fs_1.existsSync)(cachePath)
|
|
37
|
-
? (0, devkit_1.readJsonFile)(cachePath)
|
|
38
|
-
: {};
|
|
39
|
-
}
|
|
40
|
-
function writeTargetsToCache(cachePath, results) {
|
|
41
|
-
(0, devkit_1.writeJsonFile)(cachePath, results);
|
|
42
|
-
}
|
|
43
35
|
const internalCreateNodesV2 = async (ESLint, configFilePath, options, context, projectRootsByEslintRoots, lintableFilesPerProjectRoot, tsconfigChainsByProjectRoot, projectsCache, hashByRoot, pmc) => {
|
|
44
36
|
const configDir = (0, posix_1.dirname)(configFilePath);
|
|
45
37
|
const eslintVersion = ESLint.version;
|
|
@@ -56,9 +48,10 @@ const internalCreateNodesV2 = async (ESLint, configFilePath, options, context, p
|
|
|
56
48
|
const projects = {};
|
|
57
49
|
await Promise.all(projectRootsByEslintRoots.get(configDir).map(async (projectRoot) => {
|
|
58
50
|
const hash = hashByRoot.get(projectRoot);
|
|
59
|
-
|
|
51
|
+
const cached = projectsCache.get(hash);
|
|
52
|
+
if (cached) {
|
|
60
53
|
// We can reuse the projects in the cache.
|
|
61
|
-
Object.assign(projects,
|
|
54
|
+
Object.assign(projects, cached);
|
|
62
55
|
return;
|
|
63
56
|
}
|
|
64
57
|
let hasNonIgnoredLintableFiles = false;
|
|
@@ -76,18 +69,18 @@ const internalCreateNodesV2 = async (ESLint, configFilePath, options, context, p
|
|
|
76
69
|
}
|
|
77
70
|
if (!hasNonIgnoredLintableFiles) {
|
|
78
71
|
// No lintable files in the project, store in the cache and skip further processing
|
|
79
|
-
projectsCache
|
|
72
|
+
projectsCache.set(hash, {});
|
|
80
73
|
return;
|
|
81
74
|
}
|
|
82
75
|
const project = getProjectUsingESLintConfig(configFilePath, projectRoot, eslintVersion, options, context, pmc, tsconfigChainsByProjectRoot.get(projectRoot) ?? []);
|
|
83
76
|
if (project) {
|
|
84
77
|
projects[projectRoot] = project;
|
|
85
78
|
// Store project into the cache
|
|
86
|
-
projectsCache
|
|
79
|
+
projectsCache.set(hash, { [projectRoot]: project });
|
|
87
80
|
}
|
|
88
81
|
else {
|
|
89
82
|
// No project found, store in the cache
|
|
90
|
-
projectsCache
|
|
83
|
+
projectsCache.set(hash, {});
|
|
91
84
|
}
|
|
92
85
|
}));
|
|
93
86
|
return {
|
|
@@ -101,12 +94,12 @@ exports.createNodes = [
|
|
|
101
94
|
const pmc = (0, devkit_1.getPackageManagerCommand)((0, devkit_1.detectPackageManager)(context.workspaceRoot));
|
|
102
95
|
const optionsHash = (0, file_hasher_1.hashObject)(options);
|
|
103
96
|
const cachePath = (0, posix_1.join)(cache_directory_1.workspaceDataDirectory, `eslint-${optionsHash}.hash`);
|
|
104
|
-
const targetsCache =
|
|
97
|
+
const targetsCache = new internal_1.PluginCache(cachePath);
|
|
105
98
|
const { eslintConfigFiles, projectRoots, projectRootsByEslintRoots } = splitConfigFiles(configFiles);
|
|
106
99
|
const lintableFilesPerProjectRoot = await collectLintableFilesByProjectRoot(projectRoots, options, context);
|
|
107
100
|
const tsconfigChainsByProjectRoot = collectTsconfigChainsByProjectRoot(projectRoots, context.workspaceRoot);
|
|
108
101
|
const lockFilePattern = (0, js_1.getLockFileName)((0, devkit_1.detectPackageManager)(context.workspaceRoot));
|
|
109
|
-
const hashes = await (0,
|
|
102
|
+
const hashes = await (0, internal_1.calculateHashesForCreateNodes)(projectRoots, options, context, projectRoots.map((root) => {
|
|
110
103
|
const parentConfigs = eslintConfigFiles.filter((eslintConfig) => isSubDir(root, (0, posix_1.dirname)(eslintConfig)));
|
|
111
104
|
return [
|
|
112
105
|
...parentConfigs,
|
|
@@ -132,7 +125,7 @@ exports.createNodes = [
|
|
|
132
125
|
return await (0, devkit_1.createNodesFromFiles)((configFile, options, context) => internalCreateNodesV2(ESLint, configFile, options, context, projectRootsByEslintRoots, lintableFilesPerProjectRoot, tsconfigChainsByProjectRoot, targetsCache, hashByRoot, pmc), eslintConfigFiles, options, context);
|
|
133
126
|
}
|
|
134
127
|
finally {
|
|
135
|
-
|
|
128
|
+
targetsCache.writeToDisk();
|
|
136
129
|
}
|
|
137
130
|
},
|
|
138
131
|
];
|
|
@@ -197,7 +190,7 @@ function collectTsconfigChainsByProjectRoot(projectRoots, workspaceRoot) {
|
|
|
197
190
|
continue;
|
|
198
191
|
const outside = [];
|
|
199
192
|
const projectPrefix = `${projectRoot}/`;
|
|
200
|
-
(0,
|
|
193
|
+
(0, internal_2.walkTsconfigExtendsChain)((0, posix_1.join)(workspaceRoot, tsconfigPath), (absolutePath) => {
|
|
201
194
|
const wsRelative = (0, node_path_1.relative)(workspaceRoot, absolutePath)
|
|
202
195
|
.split(node_path_1.sep)
|
|
203
196
|
.join('/');
|
|
@@ -0,0 +1,4 @@
|
|
|
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
|
+
export declare function warnEslintExecutorDeprecation(): void;
|
|
3
|
+
export declare function warnEslintExecutorGenerating(): void;
|
|
4
|
+
//# sourceMappingURL=deprecation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deprecation.d.ts","sourceRoot":"","sources":["../../../../../packages/eslint/src/utils/deprecation.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,mCAAmC,iQACgN,CAAC;AAEjQ,wBAAgB,6BAA6B,IAAI,IAAI,CAEpD;AAED,wBAAgB,4BAA4B,IAAI,IAAI,CAInD"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ESLINT_EXECUTOR_DEPRECATION_MESSAGE = void 0;
|
|
4
|
+
exports.warnEslintExecutorDeprecation = warnEslintExecutorDeprecation;
|
|
5
|
+
exports.warnEslintExecutorGenerating = warnEslintExecutorGenerating;
|
|
6
|
+
const devkit_1 = require("@nx/devkit");
|
|
7
|
+
// TODO(v24): Remove the @nx/eslint:lint executor. The inferred plugin
|
|
8
|
+
// (@nx/eslint/plugin) and the convert-to-inferred generator stay supported.
|
|
9
|
+
exports.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.';
|
|
10
|
+
function warnEslintExecutorDeprecation() {
|
|
11
|
+
devkit_1.logger.warn(exports.ESLINT_EXECUTOR_DEPRECATION_MESSAGE);
|
|
12
|
+
}
|
|
13
|
+
function warnEslintExecutorGenerating() {
|
|
14
|
+
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
|
+
}
|
|
@@ -4,9 +4,9 @@ exports.getInstalledPackageVersion = getInstalledPackageVersion;
|
|
|
4
4
|
exports.getInstalledEslintVersion = getInstalledEslintVersion;
|
|
5
5
|
exports.getTypeScriptEslintVersionToInstall = getTypeScriptEslintVersionToInstall;
|
|
6
6
|
const devkit_1 = require("@nx/devkit");
|
|
7
|
-
const
|
|
7
|
+
const internal_1 = require("@nx/devkit/internal");
|
|
8
8
|
const devkit_internals_1 = require("nx/src/devkit-internals");
|
|
9
|
-
const
|
|
9
|
+
const semver_1 = require("semver");
|
|
10
10
|
const versions_1 = require("./versions");
|
|
11
11
|
function getInstalledPackageVersion(pkgName, tree) {
|
|
12
12
|
try {
|
|
@@ -31,8 +31,8 @@ function getInstalledPackageVersion(pkgName, tree) {
|
|
|
31
31
|
try {
|
|
32
32
|
// try to parse and return the version
|
|
33
33
|
return tree
|
|
34
|
-
? (0,
|
|
35
|
-
: (0,
|
|
34
|
+
? (0, internal_1.checkAndCleanWithSemver)(tree, pkgName, pkgVersionInRootPackageJson)
|
|
35
|
+
: (0, internal_1.checkAndCleanWithSemver)(pkgName, pkgVersionInRootPackageJson);
|
|
36
36
|
}
|
|
37
37
|
catch { }
|
|
38
38
|
// we could not resolve the version
|
|
@@ -43,7 +43,7 @@ function getInstalledEslintVersion(tree) {
|
|
|
43
43
|
}
|
|
44
44
|
function getTypeScriptEslintVersionToInstall(tree) {
|
|
45
45
|
const eslintVersion = getInstalledEslintVersion(tree);
|
|
46
|
-
return eslintVersion && (0,
|
|
46
|
+
return eslintVersion && (0, semver_1.lt)(eslintVersion, '9.0.0')
|
|
47
47
|
? versions_1.typescriptESLintVersion
|
|
48
48
|
: versions_1.eslint9__typescriptESLintVersion;
|
|
49
49
|
}
|