@nx/eslint 0.0.0-pr-26891-1cb1598 → 0.0.0-pr-26898-f4b245f
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/README.md +1 -1
- package/migrations.json +0 -14
- package/package.json +4 -4
- package/src/executors/lint/hasher.d.ts +1 -0
- package/src/executors/lint/hasher.js +1 -1
- package/src/executors/lint/lint.impl.js +1 -1
- package/src/executors/lint/utility/eslint-utils.js +2 -1
- package/src/generators/convert-to-flat-config/converters/json-converter.js +2 -1
- package/src/generators/convert-to-flat-config/generator.js +2 -1
- package/src/generators/convert-to-inferred/convert-to-inferred.js +2 -1
- package/src/generators/init/init-migration.js +3 -2
- package/src/generators/init/init.js +3 -2
- package/src/generators/lint-project/lint-project.js +3 -2
- package/src/generators/lint-project/setup-root-eslint.js +2 -1
- package/src/generators/utils/eslint-file.js +12 -11
- package/src/generators/utils/eslint-targets.js +2 -1
- package/src/generators/utils/flat-config/ast-utils.js +18 -17
- package/src/generators/utils/flat-config/path-utils.js +3 -2
- package/src/generators/utils/plugin.js +2 -1
- package/src/generators/workspace-rule/workspace-rule.js +2 -1
- package/src/generators/workspace-rules-project/workspace-rules-project.js +2 -2
- package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js +1 -1
- package/src/migrations/update-16-8-0-add-ignored-files/update-16-8-0-add-ignored-files.js +1 -1
- package/src/migrations/update-17-0-0-rename-to-eslint/update-17-0-0-rename-to-eslint.js +1 -1
- package/src/migrations/update-17-1-0/update-typescript-eslint.js +1 -1
- package/src/migrations/update-17-2-0/simplify-eslint-patterns.js +1 -1
- package/src/migrations/update-17-2-9/move-options-to-target-defaults.js +1 -1
- package/src/plugins/plugin.js +32 -32
- package/src/utils/config-file.js +4 -4
- package/src/utils/flat-config.js +3 -3
- package/src/utils/resolve-eslint-class.js +2 -1
- package/src/utils/rules-requiring-type-checking.js +3 -2
- package/src/utils/versions.d.ts +1 -1
- package/src/utils/versions.js +1 -1
package/README.md
CHANGED
|
@@ -59,7 +59,7 @@ npx nx@latest init
|
|
|
59
59
|
- [Nx.Dev: Documentation, Guides, Tutorials](https://nx.dev)
|
|
60
60
|
- [Intro to Nx](https://nx.dev/getting-started/intro)
|
|
61
61
|
- [Official Nx YouTube Channel](https://www.youtube.com/@NxDevtools)
|
|
62
|
-
- [Blog Posts About Nx](https://
|
|
62
|
+
- [Blog Posts About Nx](https://blog.nrwl.io/nx/home)
|
|
63
63
|
|
|
64
64
|
<p style="text-align: center;"><a href="https://nx.dev/#learning-materials" target="_blank" rel="noreferrer"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-courses-and-videos.svg"
|
|
65
65
|
width="100%" alt="Nx - Smart Monorepos · Fast CI"></a></p>
|
package/migrations.json
CHANGED
|
@@ -138,20 +138,6 @@
|
|
|
138
138
|
"version": "~8.57.0"
|
|
139
139
|
}
|
|
140
140
|
}
|
|
141
|
-
},
|
|
142
|
-
"19.5.0": {
|
|
143
|
-
"version": "19.5.0-beta.1",
|
|
144
|
-
"packages": {
|
|
145
|
-
"@typescript-eslint/parser": {
|
|
146
|
-
"version": "^7.16.0"
|
|
147
|
-
},
|
|
148
|
-
"@typescript-eslint/eslint-plugin": {
|
|
149
|
-
"version": "^7.16.0"
|
|
150
|
-
},
|
|
151
|
-
"@typescript-eslint/utils": {
|
|
152
|
-
"version": "^7.16.0"
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
141
|
}
|
|
156
142
|
}
|
|
157
143
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/eslint",
|
|
3
|
-
"version": "0.0.0-pr-
|
|
3
|
+
"version": "0.0.0-pr-26898-f4b245f",
|
|
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": {
|
|
@@ -35,12 +35,12 @@
|
|
|
35
35
|
"eslint": "^8.0.0 || ^9.0.0"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@nx/devkit": "0.0.0-pr-
|
|
39
|
-
"@nx/js": "0.0.0-pr-
|
|
38
|
+
"@nx/devkit": "0.0.0-pr-26898-f4b245f",
|
|
39
|
+
"@nx/js": "0.0.0-pr-26898-f4b245f",
|
|
40
40
|
"semver": "^7.5.3",
|
|
41
41
|
"tslib": "^2.3.0",
|
|
42
42
|
"typescript": "~5.4.2",
|
|
43
|
-
"@nx/linter": "0.0.0-pr-
|
|
43
|
+
"@nx/linter": "0.0.0-pr-26898-f4b245f"
|
|
44
44
|
},
|
|
45
45
|
"peerDependenciesMeta": {
|
|
46
46
|
"@zkochan/js-yaml": {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.default = run;
|
|
4
3
|
const devkit_1 = require("@nx/devkit");
|
|
5
4
|
async function run(task, context) {
|
|
6
5
|
const res = await context.hasher.hashTask(task, context.taskGraph, context.env);
|
|
@@ -32,6 +31,7 @@ async function run(task, context) {
|
|
|
32
31
|
},
|
|
33
32
|
};
|
|
34
33
|
}
|
|
34
|
+
exports.default = run;
|
|
35
35
|
function allDeps(taskId, taskGraph, projectGraph) {
|
|
36
36
|
if (!taskGraph.tasks) {
|
|
37
37
|
return [];
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.default = run;
|
|
4
3
|
const devkit_1 = require("@nx/devkit");
|
|
5
4
|
const fs_1 = require("fs");
|
|
6
5
|
const utils_1 = require("nx/src/tasks-runner/utils");
|
|
@@ -144,6 +143,7 @@ Please see https://nx.dev/recipes/tips-n-tricks/eslint for full guidance on how
|
|
|
144
143
|
totals.warnings <= normalizedOptions.maxWarnings)),
|
|
145
144
|
};
|
|
146
145
|
}
|
|
146
|
+
exports.default = run;
|
|
147
147
|
function getTotals(lintResults) {
|
|
148
148
|
let errors = 0;
|
|
149
149
|
let warnings = 0;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.resolveAndInstantiateESLint =
|
|
3
|
+
exports.resolveAndInstantiateESLint = void 0;
|
|
4
4
|
const config_file_1 = require("../../../utils/config-file");
|
|
5
5
|
const resolve_eslint_class_1 = require("../../../utils/resolve-eslint-class");
|
|
6
6
|
async function resolveAndInstantiateESLint(eslintConfigPath, options, useFlatConfig = false) {
|
|
@@ -61,3 +61,4 @@ async function resolveAndInstantiateESLint(eslintConfigPath, options, useFlatCon
|
|
|
61
61
|
eslint,
|
|
62
62
|
};
|
|
63
63
|
}
|
|
64
|
+
exports.resolveAndInstantiateESLint = resolveAndInstantiateESLint;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.convertEslintJsonToFlatConfig =
|
|
3
|
+
exports.convertEslintJsonToFlatConfig = void 0;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
const ts = require("typescript");
|
|
6
6
|
const ast_utils_1 = require("../../utils/flat-config/ast-utils");
|
|
@@ -103,6 +103,7 @@ function convertEslintJsonToFlatConfig(tree, root, config, ignorePaths) {
|
|
|
103
103
|
addESLintJS: isESLintJSNeeded,
|
|
104
104
|
};
|
|
105
105
|
}
|
|
106
|
+
exports.convertEslintJsonToFlatConfig = convertEslintJsonToFlatConfig;
|
|
106
107
|
// add parsed extends to export blocks and add import statements
|
|
107
108
|
function addExtends(importsMap, configBlocks, config) {
|
|
108
109
|
let isFlatCompatNeeded = false;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.convertToFlatConfigGenerator =
|
|
3
|
+
exports.convertToFlatConfigGenerator = void 0;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
const eslint_file_1 = require("../utils/eslint-file");
|
|
6
6
|
const path_1 = require("path");
|
|
@@ -37,6 +37,7 @@ async function convertToFlatConfigGenerator(tree, options) {
|
|
|
37
37
|
return () => (0, devkit_1.installPackagesTask)(tree);
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
|
+
exports.convertToFlatConfigGenerator = convertToFlatConfigGenerator;
|
|
40
41
|
exports.default = convertToFlatConfigGenerator;
|
|
41
42
|
function convertRootToFlatConfig(tree, eslintFile) {
|
|
42
43
|
if (/\.base\.(js|json|yml|yaml)$/.test(eslintFile)) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.convertToInferred =
|
|
3
|
+
exports.convertToInferred = void 0;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
const plugin_1 = require("../../plugins/plugin");
|
|
6
6
|
const executor_to_plugin_migrator_1 = require("@nx/devkit/src/generators/plugin-migrations/executor-to-plugin-migrator");
|
|
@@ -23,6 +23,7 @@ async function convertToInferred(tree, options) {
|
|
|
23
23
|
await (0, devkit_1.formatFiles)(tree);
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
|
+
exports.convertToInferred = convertToInferred;
|
|
26
27
|
function postTargetTransformer(target, tree, projectDetails, inferredTargetConfiguration) {
|
|
27
28
|
if (target.inputs) {
|
|
28
29
|
const inputs = target.inputs.filter((input) => typeof input === 'string' &&
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.migrateConfigToMonorepoStyle =
|
|
4
|
-
exports.findLintTarget = findLintTarget;
|
|
3
|
+
exports.findLintTarget = exports.migrateConfigToMonorepoStyle = void 0;
|
|
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");
|
|
@@ -69,11 +68,13 @@ function migrateConfigToMonorepoStyle(projects, tree, unitTestRunner, keepExisti
|
|
|
69
68
|
'@nx/eslint-plugin': versions_1.nxVersion,
|
|
70
69
|
});
|
|
71
70
|
}
|
|
71
|
+
exports.migrateConfigToMonorepoStyle = migrateConfigToMonorepoStyle;
|
|
72
72
|
function findLintTarget(project) {
|
|
73
73
|
return Object.values(project.targets ?? {}).find((target) => target.executor === '@nx/eslint:lint' ||
|
|
74
74
|
target.executor === '@nx/linter:eslint' ||
|
|
75
75
|
target.executor === '@nrwl/linter:eslint');
|
|
76
76
|
}
|
|
77
|
+
exports.findLintTarget = findLintTarget;
|
|
77
78
|
function migrateEslintFile(projectEslintPath, tree) {
|
|
78
79
|
const baseFile = (0, eslint_file_1.findEslintFile)(tree);
|
|
79
80
|
if ((0, eslint_file_1.isEslintConfigSupported)(tree)) {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.initEsLint =
|
|
4
|
-
exports.lintInitGenerator = lintInitGenerator;
|
|
3
|
+
exports.lintInitGenerator = exports.initEsLint = void 0;
|
|
5
4
|
const devkit_1 = require("@nx/devkit");
|
|
6
5
|
const add_plugin_1 = require("@nx/devkit/src/utils/add-plugin");
|
|
7
6
|
const versions_1 = require("../../utils/versions");
|
|
@@ -76,6 +75,8 @@ async function initEsLint(tree, options) {
|
|
|
76
75
|
}
|
|
77
76
|
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
78
77
|
}
|
|
78
|
+
exports.initEsLint = initEsLint;
|
|
79
79
|
async function lintInitGenerator(tree, options) {
|
|
80
80
|
return await initEsLint(tree, { addPlugin: false, ...options });
|
|
81
81
|
}
|
|
82
|
+
exports.lintInitGenerator = lintInitGenerator;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.lintProjectGenerator =
|
|
4
|
-
exports.lintProjectGeneratorInternal = lintProjectGeneratorInternal;
|
|
3
|
+
exports.lintProjectGeneratorInternal = exports.lintProjectGenerator = void 0;
|
|
5
4
|
const devkit_1 = require("@nx/devkit");
|
|
6
5
|
const eslint_file_1 = require("../utils/eslint-file");
|
|
7
6
|
const path_1 = require("path");
|
|
@@ -16,6 +15,7 @@ const setup_root_eslint_1 = require("./setup-root-eslint");
|
|
|
16
15
|
function lintProjectGenerator(tree, options) {
|
|
17
16
|
return lintProjectGeneratorInternal(tree, { addPlugin: false, ...options });
|
|
18
17
|
}
|
|
18
|
+
exports.lintProjectGenerator = lintProjectGenerator;
|
|
19
19
|
async function lintProjectGeneratorInternal(tree, options) {
|
|
20
20
|
const nxJson = (0, devkit_1.readNxJson)(tree);
|
|
21
21
|
const addPluginDefault = process.env.NX_ADD_PLUGINS !== 'false' &&
|
|
@@ -108,6 +108,7 @@ async function lintProjectGeneratorInternal(tree, options) {
|
|
|
108
108
|
}
|
|
109
109
|
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
110
110
|
}
|
|
111
|
+
exports.lintProjectGeneratorInternal = lintProjectGeneratorInternal;
|
|
111
112
|
function createEsLintConfiguration(tree, options, projectConfig, setParserOptionsProject, rootProject) {
|
|
112
113
|
// we are only extending root for non-standalone projects or their complementary e2e apps
|
|
113
114
|
const extendedRootConfig = rootProject ? undefined : (0, eslint_file_1.findEslintFile)(tree);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.setupRootEsLint =
|
|
3
|
+
exports.setupRootEsLint = void 0;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
const versions_1 = require("../../utils/versions");
|
|
6
6
|
const global_eslint_config_1 = require("../init/global-eslint-config");
|
|
@@ -30,3 +30,4 @@ function setupRootEsLint(tree, options) {
|
|
|
30
30
|
})
|
|
31
31
|
: () => { };
|
|
32
32
|
}
|
|
33
|
+
exports.setupRootEsLint = setupRootEsLint;
|
|
@@ -1,16 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.findEslintFile =
|
|
4
|
-
exports.isEslintConfigSupported = isEslintConfigSupported;
|
|
5
|
-
exports.updateRelativePathsInConfig = updateRelativePathsInConfig;
|
|
6
|
-
exports.addOverrideToLintConfig = addOverrideToLintConfig;
|
|
7
|
-
exports.updateOverrideInLintConfig = updateOverrideInLintConfig;
|
|
8
|
-
exports.lintConfigHasOverride = lintConfigHasOverride;
|
|
9
|
-
exports.replaceOverridesInLintConfig = replaceOverridesInLintConfig;
|
|
10
|
-
exports.addExtendsToLintConfig = addExtendsToLintConfig;
|
|
11
|
-
exports.addPluginsToLintConfig = addPluginsToLintConfig;
|
|
12
|
-
exports.addIgnoresToLintConfig = addIgnoresToLintConfig;
|
|
13
|
-
exports.getPluginImport = getPluginImport;
|
|
3
|
+
exports.getPluginImport = exports.addIgnoresToLintConfig = exports.addPluginsToLintConfig = exports.addExtendsToLintConfig = exports.replaceOverridesInLintConfig = exports.lintConfigHasOverride = exports.updateOverrideInLintConfig = exports.addOverrideToLintConfig = exports.updateRelativePathsInConfig = exports.isEslintConfigSupported = exports.findEslintFile = void 0;
|
|
14
4
|
const devkit_1 = require("@nx/devkit");
|
|
15
5
|
const flat_config_1 = require("../../utils/flat-config");
|
|
16
6
|
const ast_utils_1 = require("./flat-config/ast-utils");
|
|
@@ -31,6 +21,7 @@ function findEslintFile(tree, projectRoot) {
|
|
|
31
21
|
}
|
|
32
22
|
return null;
|
|
33
23
|
}
|
|
24
|
+
exports.findEslintFile = findEslintFile;
|
|
34
25
|
function isEslintConfigSupported(tree, projectRoot = '') {
|
|
35
26
|
const eslintFile = findEslintFile(tree, projectRoot);
|
|
36
27
|
if (!eslintFile) {
|
|
@@ -38,6 +29,7 @@ function isEslintConfigSupported(tree, projectRoot = '') {
|
|
|
38
29
|
}
|
|
39
30
|
return eslintFile.endsWith('.json') || eslintFile.endsWith('.config.js');
|
|
40
31
|
}
|
|
32
|
+
exports.isEslintConfigSupported = isEslintConfigSupported;
|
|
41
33
|
function updateRelativePathsInConfig(tree, sourcePath, destinationPath) {
|
|
42
34
|
if (sourcePath === destinationPath ||
|
|
43
35
|
!isEslintConfigSupported(tree, destinationPath)) {
|
|
@@ -68,6 +60,7 @@ function updateRelativePathsInConfig(tree, sourcePath, destinationPath) {
|
|
|
68
60
|
});
|
|
69
61
|
}
|
|
70
62
|
}
|
|
63
|
+
exports.updateRelativePathsInConfig = updateRelativePathsInConfig;
|
|
71
64
|
function replaceFlatConfigPaths(config, sourceRoot, offset, destinationRoot, tree) {
|
|
72
65
|
let match;
|
|
73
66
|
let newConfig = config;
|
|
@@ -133,6 +126,7 @@ function addOverrideToLintConfig(tree, root, override, options = {
|
|
|
133
126
|
});
|
|
134
127
|
}
|
|
135
128
|
}
|
|
129
|
+
exports.addOverrideToLintConfig = addOverrideToLintConfig;
|
|
136
130
|
function overrideNeedsCompat(override) {
|
|
137
131
|
return (override.env || override.extends || override.plugins || override.parser);
|
|
138
132
|
}
|
|
@@ -167,6 +161,7 @@ function updateOverrideInLintConfig(tree, root, lookup, update) {
|
|
|
167
161
|
});
|
|
168
162
|
}
|
|
169
163
|
}
|
|
164
|
+
exports.updateOverrideInLintConfig = updateOverrideInLintConfig;
|
|
170
165
|
function lintConfigHasOverride(tree, root, lookup, checkBaseConfig = false) {
|
|
171
166
|
if (!isEslintConfigSupported(tree, root)) {
|
|
172
167
|
return false;
|
|
@@ -182,6 +177,7 @@ function lintConfigHasOverride(tree, root, lookup, checkBaseConfig = false) {
|
|
|
182
177
|
return (0, devkit_1.readJson)(tree, fileName).overrides?.some(lookup) || false;
|
|
183
178
|
}
|
|
184
179
|
}
|
|
180
|
+
exports.lintConfigHasOverride = lintConfigHasOverride;
|
|
185
181
|
function replaceOverridesInLintConfig(tree, root, overrides) {
|
|
186
182
|
if ((0, flat_config_1.useFlatConfig)(tree)) {
|
|
187
183
|
const fileName = (0, devkit_1.joinPathFragments)(root, (0, flat_config_1.flatConfigEslintFilename)(tree));
|
|
@@ -205,6 +201,7 @@ function replaceOverridesInLintConfig(tree, root, overrides) {
|
|
|
205
201
|
});
|
|
206
202
|
}
|
|
207
203
|
}
|
|
204
|
+
exports.replaceOverridesInLintConfig = replaceOverridesInLintConfig;
|
|
208
205
|
function addExtendsToLintConfig(tree, root, plugin) {
|
|
209
206
|
const plugins = Array.isArray(plugin) ? plugin : [plugin];
|
|
210
207
|
if ((0, flat_config_1.useFlatConfig)(tree)) {
|
|
@@ -228,6 +225,7 @@ function addExtendsToLintConfig(tree, root, plugin) {
|
|
|
228
225
|
});
|
|
229
226
|
}
|
|
230
227
|
}
|
|
228
|
+
exports.addExtendsToLintConfig = addExtendsToLintConfig;
|
|
231
229
|
function addPluginsToLintConfig(tree, root, plugin) {
|
|
232
230
|
const plugins = Array.isArray(plugin) ? plugin : [plugin];
|
|
233
231
|
if ((0, flat_config_1.useFlatConfig)(tree)) {
|
|
@@ -253,6 +251,7 @@ function addPluginsToLintConfig(tree, root, plugin) {
|
|
|
253
251
|
});
|
|
254
252
|
}
|
|
255
253
|
}
|
|
254
|
+
exports.addPluginsToLintConfig = addPluginsToLintConfig;
|
|
256
255
|
function addIgnoresToLintConfig(tree, root, ignorePatterns) {
|
|
257
256
|
if ((0, flat_config_1.useFlatConfig)(tree)) {
|
|
258
257
|
const fileName = (0, devkit_1.joinPathFragments)(root, (0, flat_config_1.flatConfigEslintFilename)(tree));
|
|
@@ -273,6 +272,7 @@ function addIgnoresToLintConfig(tree, root, ignorePatterns) {
|
|
|
273
272
|
});
|
|
274
273
|
}
|
|
275
274
|
}
|
|
275
|
+
exports.addIgnoresToLintConfig = addIgnoresToLintConfig;
|
|
276
276
|
function getPluginImport(pluginName) {
|
|
277
277
|
if (pluginName.includes('eslint-plugin-')) {
|
|
278
278
|
return pluginName;
|
|
@@ -286,3 +286,4 @@ function getPluginImport(pluginName) {
|
|
|
286
286
|
const [scope, name] = pluginName.split('/');
|
|
287
287
|
return `${scope}/eslint-plugin-${name}`;
|
|
288
288
|
}
|
|
289
|
+
exports.getPluginImport = getPluginImport;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getEslintTargets =
|
|
3
|
+
exports.getEslintTargets = void 0;
|
|
4
4
|
const executor_options_utils_1 = require("@nx/devkit/src/generators/executor-options-utils");
|
|
5
5
|
function getEslintTargets(tree) {
|
|
6
6
|
const eslintTargetNames = new Set();
|
|
@@ -15,3 +15,4 @@ function getEslintTargets(tree) {
|
|
|
15
15
|
});
|
|
16
16
|
return eslintTargetNames;
|
|
17
17
|
}
|
|
18
|
+
exports.getEslintTargets = getEslintTargets;
|
|
@@ -1,22 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.removeOverridesFromLintConfig =
|
|
4
|
-
exports.hasOverride = hasOverride;
|
|
5
|
-
exports.replaceOverride = replaceOverride;
|
|
6
|
-
exports.addImportToFlatConfig = addImportToFlatConfig;
|
|
7
|
-
exports.addBlockToFlatConfigExport = addBlockToFlatConfigExport;
|
|
8
|
-
exports.removePlugin = removePlugin;
|
|
9
|
-
exports.removeCompatExtends = removeCompatExtends;
|
|
10
|
-
exports.addPluginsToExportsBlock = addPluginsToExportsBlock;
|
|
11
|
-
exports.addCompatToFlatConfig = addCompatToFlatConfig;
|
|
12
|
-
exports.createNodeList = createNodeList;
|
|
13
|
-
exports.generateSpreadElement = generateSpreadElement;
|
|
14
|
-
exports.generatePluginExtendsElement = generatePluginExtendsElement;
|
|
15
|
-
exports.stringifyNodeList = stringifyNodeList;
|
|
16
|
-
exports.generateRequire = generateRequire;
|
|
17
|
-
exports.generateFlatOverride = generateFlatOverride;
|
|
18
|
-
exports.mapFilePaths = mapFilePaths;
|
|
19
|
-
exports.generateAst = generateAst;
|
|
3
|
+
exports.generateAst = exports.mapFilePaths = exports.generateFlatOverride = exports.generateRequire = exports.stringifyNodeList = exports.generatePluginExtendsElement = exports.generateSpreadElement = exports.createNodeList = exports.addCompatToFlatConfig = exports.addPluginsToExportsBlock = exports.removeCompatExtends = exports.removePlugin = exports.addBlockToFlatConfigExport = exports.addImportToFlatConfig = exports.replaceOverride = exports.hasOverride = exports.removeOverridesFromLintConfig = void 0;
|
|
20
4
|
const devkit_1 = require("@nx/devkit");
|
|
21
5
|
const ts = require("typescript");
|
|
22
6
|
const path_utils_1 = require("./path-utils");
|
|
@@ -47,6 +31,7 @@ function removeOverridesFromLintConfig(content) {
|
|
|
47
31
|
});
|
|
48
32
|
return (0, devkit_1.applyChangesToString)(content, changes);
|
|
49
33
|
}
|
|
34
|
+
exports.removeOverridesFromLintConfig = removeOverridesFromLintConfig;
|
|
50
35
|
function findAllBlocks(source) {
|
|
51
36
|
return ts.forEachChild(source, function analyze(node) {
|
|
52
37
|
if (ts.isExpressionStatement(node) &&
|
|
@@ -97,6 +82,7 @@ function hasOverride(content, lookup) {
|
|
|
97
82
|
}
|
|
98
83
|
return false;
|
|
99
84
|
}
|
|
85
|
+
exports.hasOverride = hasOverride;
|
|
100
86
|
function parseTextToJson(text) {
|
|
101
87
|
return (0, devkit_1.parseJson)(text
|
|
102
88
|
// ensure property names have double quotes so that JSON.parse works
|
|
@@ -152,6 +138,7 @@ function replaceOverride(content, root, lookup, update) {
|
|
|
152
138
|
});
|
|
153
139
|
return (0, devkit_1.applyChangesToString)(content, changes);
|
|
154
140
|
}
|
|
141
|
+
exports.replaceOverride = replaceOverride;
|
|
155
142
|
/**
|
|
156
143
|
* Adding require statement to the top of the file
|
|
157
144
|
*/
|
|
@@ -226,6 +213,7 @@ function addImportToFlatConfig(content, variable, imp) {
|
|
|
226
213
|
},
|
|
227
214
|
]);
|
|
228
215
|
}
|
|
216
|
+
exports.addImportToFlatConfig = addImportToFlatConfig;
|
|
229
217
|
/**
|
|
230
218
|
* Injects new ts.expression to the end of the module.exports array.
|
|
231
219
|
*/
|
|
@@ -266,6 +254,7 @@ function addBlockToFlatConfigExport(content, config, options = {
|
|
|
266
254
|
]);
|
|
267
255
|
}
|
|
268
256
|
}
|
|
257
|
+
exports.addBlockToFlatConfigExport = addBlockToFlatConfigExport;
|
|
269
258
|
function removePlugin(content, pluginName, pluginImport) {
|
|
270
259
|
const source = ts.createSourceFile('', content, ts.ScriptTarget.Latest, true, ts.ScriptKind.JS);
|
|
271
260
|
const changes = [];
|
|
@@ -376,6 +365,7 @@ function removePlugin(content, pluginName, pluginImport) {
|
|
|
376
365
|
});
|
|
377
366
|
return (0, devkit_1.applyChangesToString)(content, changes);
|
|
378
367
|
}
|
|
368
|
+
exports.removePlugin = removePlugin;
|
|
379
369
|
function removeCompatExtends(content, compatExtends) {
|
|
380
370
|
const source = ts.createSourceFile('', content, ts.ScriptTarget.Latest, true, ts.ScriptKind.JS);
|
|
381
371
|
const changes = [];
|
|
@@ -411,6 +401,7 @@ function removeCompatExtends(content, compatExtends) {
|
|
|
411
401
|
});
|
|
412
402
|
return (0, devkit_1.applyChangesToString)(content, changes);
|
|
413
403
|
}
|
|
404
|
+
exports.removeCompatExtends = removeCompatExtends;
|
|
414
405
|
/**
|
|
415
406
|
* Add plugins block to the top of the export blocks
|
|
416
407
|
*/
|
|
@@ -424,6 +415,7 @@ function addPluginsToExportsBlock(content, plugins) {
|
|
|
424
415
|
insertAtTheEnd: false,
|
|
425
416
|
});
|
|
426
417
|
}
|
|
418
|
+
exports.addPluginsToExportsBlock = addPluginsToExportsBlock;
|
|
427
419
|
/**
|
|
428
420
|
* Adds compat if missing to flat config
|
|
429
421
|
*/
|
|
@@ -443,6 +435,7 @@ function addCompatToFlatConfig(content) {
|
|
|
443
435
|
},
|
|
444
436
|
]);
|
|
445
437
|
}
|
|
438
|
+
exports.addCompatToFlatConfig = addCompatToFlatConfig;
|
|
446
439
|
const DEFAULT_FLAT_CONFIG = `
|
|
447
440
|
const compat = new FlatCompat({
|
|
448
441
|
baseDirectory: __dirname,
|
|
@@ -474,12 +467,15 @@ function createNodeList(importsMap, exportElements, isFlatCompatNeeded) {
|
|
|
474
467
|
ts.factory.createExpressionStatement(ts.factory.createBinaryExpression(ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier('module'), ts.factory.createIdentifier('exports')), ts.factory.createToken(ts.SyntaxKind.EqualsToken), ts.factory.createArrayLiteralExpression(exportElements, true))),
|
|
475
468
|
]);
|
|
476
469
|
}
|
|
470
|
+
exports.createNodeList = createNodeList;
|
|
477
471
|
function generateSpreadElement(name) {
|
|
478
472
|
return ts.factory.createSpreadElement(ts.factory.createIdentifier(name));
|
|
479
473
|
}
|
|
474
|
+
exports.generateSpreadElement = generateSpreadElement;
|
|
480
475
|
function generatePluginExtendsElement(plugins) {
|
|
481
476
|
return ts.factory.createSpreadElement(ts.factory.createCallExpression(ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier('compat'), ts.factory.createIdentifier('extends')), undefined, plugins.map((plugin) => ts.factory.createStringLiteral(plugin))));
|
|
482
477
|
}
|
|
478
|
+
exports.generatePluginExtendsElement = generatePluginExtendsElement;
|
|
483
479
|
/**
|
|
484
480
|
* Stringifies TS nodes to file content string
|
|
485
481
|
*/
|
|
@@ -493,6 +489,7 @@ function stringifyNodeList(nodes) {
|
|
|
493
489
|
// add new line before module.exports = ...
|
|
494
490
|
.replace(/module\.exports/, '\nmodule.exports'));
|
|
495
491
|
}
|
|
492
|
+
exports.stringifyNodeList = stringifyNodeList;
|
|
496
493
|
/**
|
|
497
494
|
* generates AST require statement
|
|
498
495
|
*/
|
|
@@ -501,6 +498,7 @@ function generateRequire(variableName, imp) {
|
|
|
501
498
|
ts.factory.createVariableDeclaration(variableName, undefined, undefined, ts.factory.createCallExpression(ts.factory.createIdentifier('require'), undefined, [ts.factory.createStringLiteral(imp)])),
|
|
502
499
|
], ts.NodeFlags.Const));
|
|
503
500
|
}
|
|
501
|
+
exports.generateRequire = generateRequire;
|
|
504
502
|
/**
|
|
505
503
|
* Generates AST object or spread element based on JSON override object
|
|
506
504
|
*/
|
|
@@ -543,6 +541,7 @@ function generateFlatOverride(override) {
|
|
|
543
541
|
], undefined, ts.factory.createToken(ts.SyntaxKind.EqualsGreaterThanToken), ts.factory.createParenthesizedExpression(ts.factory.createObjectLiteralExpression(objectLiteralElements, true))),
|
|
544
542
|
]));
|
|
545
543
|
}
|
|
544
|
+
exports.generateFlatOverride = generateFlatOverride;
|
|
546
545
|
function mapFilePaths(override) {
|
|
547
546
|
if (override.files) {
|
|
548
547
|
override.files = Array.isArray(override.files)
|
|
@@ -557,6 +556,7 @@ function mapFilePaths(override) {
|
|
|
557
556
|
override.excludedFiles = override.excludedFiles.map((file) => (0, path_utils_1.mapFilePath)(file));
|
|
558
557
|
}
|
|
559
558
|
}
|
|
559
|
+
exports.mapFilePaths = mapFilePaths;
|
|
560
560
|
function addTSObjectProperty(elements, key, value) {
|
|
561
561
|
if (value) {
|
|
562
562
|
elements.push(ts.factory.createPropertyAssignment(key, generateAst(value)));
|
|
@@ -591,6 +591,7 @@ function generateAst(input) {
|
|
|
591
591
|
// since we are parsing JSON, this should never happen
|
|
592
592
|
throw new Error(`Unknown type: ${typeof input} `);
|
|
593
593
|
}
|
|
594
|
+
exports.generateAst = generateAst;
|
|
594
595
|
function isValidKey(key) {
|
|
595
596
|
return /^[a-zA-Z0-9_]+$/.test(key);
|
|
596
597
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.updateFiles =
|
|
4
|
-
exports.mapFilePath = mapFilePath;
|
|
3
|
+
exports.mapFilePath = exports.updateFiles = void 0;
|
|
5
4
|
const devkit_1 = require("@nx/devkit");
|
|
6
5
|
function updateFiles(override) {
|
|
7
6
|
if (override.files) {
|
|
@@ -12,6 +11,7 @@ function updateFiles(override) {
|
|
|
12
11
|
}
|
|
13
12
|
return override;
|
|
14
13
|
}
|
|
14
|
+
exports.updateFiles = updateFiles;
|
|
15
15
|
function mapFilePath(filePath) {
|
|
16
16
|
if (filePath.startsWith('!')) {
|
|
17
17
|
const fileWithoutBang = filePath.slice(1);
|
|
@@ -25,3 +25,4 @@ function mapFilePath(filePath) {
|
|
|
25
25
|
}
|
|
26
26
|
return filePath;
|
|
27
27
|
}
|
|
28
|
+
exports.mapFilePath = mapFilePath;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.hasEslintPlugin =
|
|
3
|
+
exports.hasEslintPlugin = void 0;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
function hasEslintPlugin(tree) {
|
|
6
6
|
const nxJson = (0, devkit_1.readNxJson)(tree);
|
|
@@ -8,3 +8,4 @@ function hasEslintPlugin(tree) {
|
|
|
8
8
|
? p === '@nx/eslint/plugin'
|
|
9
9
|
: p.plugin === '@nx/eslint/plugin');
|
|
10
10
|
}
|
|
11
|
+
exports.hasEslintPlugin = hasEslintPlugin;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.lintWorkspaceRuleGenerator =
|
|
3
|
+
exports.lintWorkspaceRuleGenerator = void 0;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
const string_utils_1 = require("@nx/devkit/src/utils/string-utils");
|
|
6
6
|
const path_1 = require("path");
|
|
@@ -75,3 +75,4 @@ async function lintWorkspaceRuleGenerator(tree, options) {
|
|
|
75
75
|
`);
|
|
76
76
|
return projectGeneratorCallback;
|
|
77
77
|
}
|
|
78
|
+
exports.lintWorkspaceRuleGenerator = lintWorkspaceRuleGenerator;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.WORKSPACE_PLUGIN_DIR = exports.WORKSPACE_RULES_PROJECT_NAME = void 0;
|
|
4
|
-
exports.lintWorkspaceRulesProjectGenerator = lintWorkspaceRulesProjectGenerator;
|
|
3
|
+
exports.lintWorkspaceRulesProjectGenerator = exports.WORKSPACE_PLUGIN_DIR = exports.WORKSPACE_RULES_PROJECT_NAME = void 0;
|
|
5
4
|
const devkit_1 = require("@nx/devkit");
|
|
6
5
|
const js_1 = require("@nx/js");
|
|
7
6
|
const add_swc_dependencies_1 = require("@nx/js/src/utils/swc/add-swc-dependencies");
|
|
@@ -80,3 +79,4 @@ async function lintWorkspaceRulesProjectGenerator(tree, options = {}) {
|
|
|
80
79
|
}
|
|
81
80
|
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
82
81
|
}
|
|
82
|
+
exports.lintWorkspaceRulesProjectGenerator = lintWorkspaceRulesProjectGenerator;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.default = replacePackage;
|
|
4
3
|
const devkit_1 = require("@nx/devkit");
|
|
5
4
|
const replace_package_1 = require("@nx/devkit/src/utils/replace-package");
|
|
6
5
|
async function replacePackage(tree) {
|
|
7
6
|
await (0, replace_package_1.replaceNrwlPackageWithNxPackage)(tree, '@nrwl/linter', '@nx/linter');
|
|
8
7
|
await (0, devkit_1.formatFiles)(tree);
|
|
9
8
|
}
|
|
9
|
+
exports.default = replacePackage;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.default = update;
|
|
4
3
|
const devkit_1 = require("@nx/devkit");
|
|
5
4
|
const executor_options_utils_1 = require("@nx/devkit/src/generators/executor-options-utils");
|
|
6
5
|
const eslint_file_1 = require("../../generators/utils/eslint-file");
|
|
@@ -42,3 +41,4 @@ function update(tree) {
|
|
|
42
41
|
(0, executor_options_utils_1.forEachExecutorOptions)(tree, '@nx/esbuild:esbuild', addIgnorePattern('{projectRoot}/esbuild.config.{js,ts,mjs,mts}'));
|
|
43
42
|
(0, executor_options_utils_1.forEachExecutorOptions)(tree, '@nx/rollup:rollup', addIgnorePattern('{projectRoot}/rollup.config.{js,ts,mjs,mts}'));
|
|
44
43
|
}
|
|
44
|
+
exports.default = update;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.default = replacePackage;
|
|
4
3
|
const devkit_1 = require("@nx/devkit");
|
|
5
4
|
const replace_package_1 = require("@nx/devkit/src/utils/replace-package");
|
|
6
5
|
async function replacePackage(tree) {
|
|
@@ -10,6 +9,7 @@ async function replacePackage(tree) {
|
|
|
10
9
|
updateProjectExecutor(tree);
|
|
11
10
|
await (0, devkit_1.formatFiles)(tree);
|
|
12
11
|
}
|
|
12
|
+
exports.default = replacePackage;
|
|
13
13
|
function updateNxJsonExecutor(tree) {
|
|
14
14
|
if (!tree.exists('nx.json')) {
|
|
15
15
|
return;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.default = update;
|
|
4
3
|
const devkit_1 = require("@nx/devkit");
|
|
5
4
|
const versions_1 = require("../../utils/versions");
|
|
6
5
|
const path_1 = require("path");
|
|
@@ -72,3 +71,4 @@ async function update(tree) {
|
|
|
72
71
|
updateRecommended(tree);
|
|
73
72
|
await (0, devkit_1.formatFiles)(tree);
|
|
74
73
|
}
|
|
74
|
+
exports.default = update;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.default = update;
|
|
4
3
|
const devkit_1 = require("@nx/devkit");
|
|
5
4
|
async function update(tree) {
|
|
6
5
|
const projects = (0, devkit_1.getProjects)(tree);
|
|
@@ -38,6 +37,7 @@ async function update(tree) {
|
|
|
38
37
|
}
|
|
39
38
|
await (0, devkit_1.formatFiles)(tree);
|
|
40
39
|
}
|
|
40
|
+
exports.default = update;
|
|
41
41
|
function getLintRoot({ root, sourceRoot }) {
|
|
42
42
|
if (root === '' || root === '.') {
|
|
43
43
|
return sourceRoot || './src';
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.default = update;
|
|
4
3
|
const devkit_1 = require("@nx/devkit");
|
|
5
4
|
const executor_options_utils_1 = require("@nx/devkit/src/generators/executor-options-utils");
|
|
6
5
|
const eslint_file_1 = require("../../generators/utils/eslint-file");
|
|
@@ -93,6 +92,7 @@ async function update(tree) {
|
|
|
93
92
|
(0, devkit_1.updateNxJson)(tree, nxJson);
|
|
94
93
|
await (0, devkit_1.formatFiles)(tree);
|
|
95
94
|
}
|
|
95
|
+
exports.default = update;
|
|
96
96
|
function isTargetDefaultUsed(targetDefault, targetDefaults, projects, projectMap) {
|
|
97
97
|
for (const p of Object.values(projects)) {
|
|
98
98
|
for (const targetName in p.data?.targets ?? {}) {
|
package/src/plugins/plugin.js
CHANGED
|
@@ -4,7 +4,7 @@ exports.createNodes = exports.createNodesV2 = void 0;
|
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
const calculate_hash_for_create_nodes_1 = require("@nx/devkit/src/utils/calculate-hash-for-create-nodes");
|
|
6
6
|
const node_fs_1 = require("node:fs");
|
|
7
|
-
const
|
|
7
|
+
const node_path_1 = require("node:path");
|
|
8
8
|
const file_hasher_1 = require("nx/src/hasher/file-hasher");
|
|
9
9
|
const cache_directory_1 = require("nx/src/utils/cache-directory");
|
|
10
10
|
const globs_1 = require("nx/src/utils/globs");
|
|
@@ -30,7 +30,7 @@ function writeTargetsToCache(cachePath, results) {
|
|
|
30
30
|
}
|
|
31
31
|
const internalCreateNodes = async (configFilePath, options, context, projectsCache) => {
|
|
32
32
|
options = normalizeOptions(options);
|
|
33
|
-
const configDir = (0,
|
|
33
|
+
const configDir = (0, node_path_1.dirname)(configFilePath);
|
|
34
34
|
// Ensure that configFiles are set, e2e-run fails due to them being undefined in CI (does not occur locally)
|
|
35
35
|
// TODO(JamesHenry): Further troubleshoot this in CI
|
|
36
36
|
context.configFiles = context.configFiles ?? [];
|
|
@@ -38,14 +38,14 @@ const internalCreateNodes = async (configFilePath, options, context, projectsCac
|
|
|
38
38
|
// list of globs to exclude from child projects
|
|
39
39
|
const nestedEslintRootPatterns = [];
|
|
40
40
|
for (const configFile of context.configFiles) {
|
|
41
|
-
const eslintRootDir = (0,
|
|
41
|
+
const eslintRootDir = (0, node_path_1.dirname)(configFile);
|
|
42
42
|
if (eslintRootDir !== configDir && isSubDir(configDir, eslintRootDir)) {
|
|
43
43
|
nestedEslintRootPatterns.push(`${eslintRootDir}/**/*`);
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
|
-
const projectFiles = await (0, workspace_context_1.globWithWorkspaceContext)(context.workspaceRoot, ['project.json', 'package.json', '**/project.json', '**/package.json'].map((f) => (0,
|
|
46
|
+
const projectFiles = await (0, workspace_context_1.globWithWorkspaceContext)(context.workspaceRoot, ['project.json', 'package.json', '**/project.json', '**/package.json'].map((f) => (0, node_path_1.join)(configDir, f)), nestedEslintRootPatterns.length ? nestedEslintRootPatterns : undefined);
|
|
47
47
|
// dedupe and sort project roots by depth for more efficient traversal
|
|
48
|
-
const dedupedProjectRoots = Array.from(new Set(projectFiles.map((f) => (0,
|
|
48
|
+
const dedupedProjectRoots = Array.from(new Set(projectFiles.map((f) => (0, node_path_1.dirname)(f)))).sort((a, b) => (a !== b && isSubDir(a, b) ? -1 : 1));
|
|
49
49
|
const excludePatterns = dedupedProjectRoots.map((root) => `${root}/**/*`);
|
|
50
50
|
const ESLint = await (0, resolve_eslint_class_1.resolveESLintClass)((0, config_file_1.isFlatConfig)(configFilePath));
|
|
51
51
|
const eslintVersion = ESLint.version;
|
|
@@ -54,22 +54,22 @@ const internalCreateNodes = async (configFilePath, options, context, projectsCac
|
|
|
54
54
|
// anything after is either a nested project or a sibling project, can be excluded
|
|
55
55
|
const nestedProjectRootPatterns = excludePatterns.slice(index + 1);
|
|
56
56
|
// Ignore project roots where the project does not contain any lintable files
|
|
57
|
-
const lintableFiles = await (0, workspace_context_1.globWithWorkspaceContext)(context.workspaceRoot, [(0,
|
|
57
|
+
const lintableFiles = await (0, workspace_context_1.globWithWorkspaceContext)(context.workspaceRoot, [(0, node_path_1.join)(childProjectRoot, `**/*.{${options.extensions.join(',')}}`)],
|
|
58
58
|
// exclude nested eslint roots and nested project roots
|
|
59
59
|
[...nestedEslintRootPatterns, ...nestedProjectRootPatterns]);
|
|
60
|
-
const parentConfigs = context.configFiles.filter((eslintConfig) => isSubDir(childProjectRoot, (0,
|
|
61
|
-
const hash = await (0, calculate_hash_for_create_nodes_1.calculateHashForCreateNodes)(childProjectRoot, options, context, [...parentConfigs, (0,
|
|
60
|
+
const parentConfigs = context.configFiles.filter((eslintConfig) => isSubDir(childProjectRoot, (0, node_path_1.dirname)(eslintConfig)));
|
|
61
|
+
const hash = await (0, calculate_hash_for_create_nodes_1.calculateHashForCreateNodes)(childProjectRoot, options, context, [...parentConfigs, (0, node_path_1.join)(childProjectRoot, '.eslintignore')]);
|
|
62
62
|
if (projectsCache[hash]) {
|
|
63
63
|
// We can reuse the projects in the cache.
|
|
64
64
|
Object.assign(projects, projectsCache[hash]);
|
|
65
65
|
return;
|
|
66
66
|
}
|
|
67
67
|
const eslint = new ESLint({
|
|
68
|
-
cwd: (0,
|
|
68
|
+
cwd: (0, node_path_1.join)(context.workspaceRoot, childProjectRoot),
|
|
69
69
|
});
|
|
70
70
|
let hasNonIgnoredLintableFiles = false;
|
|
71
71
|
for (const file of lintableFiles) {
|
|
72
|
-
if (!(await eslint.isPathIgnored((0,
|
|
72
|
+
if (!(await eslint.isPathIgnored((0, node_path_1.join)(context.workspaceRoot, file)))) {
|
|
73
73
|
hasNonIgnoredLintableFiles = true;
|
|
74
74
|
break;
|
|
75
75
|
}
|
|
@@ -96,17 +96,17 @@ const internalCreateNodes = async (configFilePath, options, context, projectsCac
|
|
|
96
96
|
};
|
|
97
97
|
let collectingLintableFilesPromise;
|
|
98
98
|
const internalCreateNodesV2 = async (configFilePath, options, context, eslintConfigFiles, allProjectRoots, projectRootsByEslintRoots, lintableFilesPerProjectRoot, projectsCache) => {
|
|
99
|
-
const configDir = (0,
|
|
99
|
+
const configDir = (0, node_path_1.dirname)(configFilePath);
|
|
100
100
|
const ESLint = await (0, resolve_eslint_class_1.resolveESLintClass)((0, config_file_1.isFlatConfig)(configFilePath));
|
|
101
101
|
const eslintVersion = ESLint.version;
|
|
102
102
|
const projects = {};
|
|
103
103
|
await Promise.all(projectRootsByEslintRoots.get(configDir).map(async (projectRoot) => {
|
|
104
|
-
const parentConfigs = eslintConfigFiles.filter((eslintConfig) => isSubDir(projectRoot, (0,
|
|
104
|
+
const parentConfigs = eslintConfigFiles.filter((eslintConfig) => isSubDir(projectRoot, (0, node_path_1.dirname)(eslintConfig)));
|
|
105
105
|
const hash = await (0, calculate_hash_for_create_nodes_1.calculateHashForCreateNodes)(projectRoot, options, {
|
|
106
106
|
configFiles: eslintConfigFiles,
|
|
107
107
|
nxJsonConfiguration: context.nxJsonConfiguration,
|
|
108
108
|
workspaceRoot: context.workspaceRoot,
|
|
109
|
-
}, [...parentConfigs, (0,
|
|
109
|
+
}, [...parentConfigs, (0, node_path_1.join)(projectRoot, '.eslintignore')]);
|
|
110
110
|
if (projectsCache[hash]) {
|
|
111
111
|
// We can reuse the projects in the cache.
|
|
112
112
|
Object.assign(projects, projectsCache[hash]);
|
|
@@ -118,11 +118,11 @@ const internalCreateNodesV2 = async (configFilePath, options, context, eslintCon
|
|
|
118
118
|
collectingLintableFilesPromise = null;
|
|
119
119
|
}
|
|
120
120
|
const eslint = new ESLint({
|
|
121
|
-
cwd: (0,
|
|
121
|
+
cwd: (0, node_path_1.join)(context.workspaceRoot, projectRoot),
|
|
122
122
|
});
|
|
123
123
|
let hasNonIgnoredLintableFiles = false;
|
|
124
124
|
for (const file of lintableFilesPerProjectRoot.get(projectRoot) ?? []) {
|
|
125
|
-
if (!(await eslint.isPathIgnored((0,
|
|
125
|
+
if (!(await eslint.isPathIgnored((0, node_path_1.join)(context.workspaceRoot, file)))) {
|
|
126
126
|
hasNonIgnoredLintableFiles = true;
|
|
127
127
|
break;
|
|
128
128
|
}
|
|
@@ -152,7 +152,7 @@ exports.createNodesV2 = [
|
|
|
152
152
|
async (configFiles, options, context) => {
|
|
153
153
|
options = normalizeOptions(options);
|
|
154
154
|
const optionsHash = (0, file_hasher_1.hashObject)(options);
|
|
155
|
-
const cachePath = (0,
|
|
155
|
+
const cachePath = (0, node_path_1.join)(cache_directory_1.workspaceDataDirectory, `eslint-${optionsHash}.hash`);
|
|
156
156
|
const targetsCache = readTargetsCache(cachePath);
|
|
157
157
|
const { eslintConfigFiles, projectRoots, projectRootsByEslintRoots } = splitConfigFiles(configFiles);
|
|
158
158
|
const lintableFilesPerProjectRoot = new Map();
|
|
@@ -175,8 +175,8 @@ function splitConfigFiles(configFiles) {
|
|
|
175
175
|
const eslintConfigFiles = [];
|
|
176
176
|
const projectRoots = new Set();
|
|
177
177
|
for (const configFile of configFiles) {
|
|
178
|
-
if (PROJECT_CONFIG_FILENAMES.includes((0,
|
|
179
|
-
projectRoots.add((0,
|
|
178
|
+
if (PROJECT_CONFIG_FILENAMES.includes((0, node_path_1.basename)(configFile))) {
|
|
179
|
+
projectRoots.add((0, node_path_1.dirname)(configFile));
|
|
180
180
|
}
|
|
181
181
|
else {
|
|
182
182
|
eslintConfigFiles.push(configFile);
|
|
@@ -193,7 +193,7 @@ function splitConfigFiles(configFiles) {
|
|
|
193
193
|
function groupProjectRootsByEslintRoots(eslintConfigFiles, projectRoots) {
|
|
194
194
|
const projectRootsByEslintRoots = new Map();
|
|
195
195
|
for (const eslintConfig of eslintConfigFiles) {
|
|
196
|
-
projectRootsByEslintRoots.set((0,
|
|
196
|
+
projectRootsByEslintRoots.set((0, node_path_1.dirname)(eslintConfig), []);
|
|
197
197
|
}
|
|
198
198
|
for (const projectRoot of projectRoots) {
|
|
199
199
|
const eslintRoot = getRootForDirectory(projectRoot, projectRootsByEslintRoots);
|
|
@@ -211,19 +211,19 @@ async function collectLintableFilesByProjectRoot(lintableFilesPerProjectRoot, pr
|
|
|
211
211
|
lintableFilesPerProjectRoot.set(projectRoot, []);
|
|
212
212
|
}
|
|
213
213
|
for (const file of lintableFiles) {
|
|
214
|
-
const projectRoot = getRootForDirectory((0,
|
|
214
|
+
const projectRoot = getRootForDirectory((0, node_path_1.dirname)(file), lintableFilesPerProjectRoot);
|
|
215
215
|
if (projectRoot) {
|
|
216
216
|
lintableFilesPerProjectRoot.get(projectRoot).push(file);
|
|
217
217
|
}
|
|
218
218
|
}
|
|
219
219
|
}
|
|
220
220
|
function getRootForDirectory(directory, roots) {
|
|
221
|
-
let currentPath = (0,
|
|
222
|
-
while (currentPath !== (0,
|
|
221
|
+
let currentPath = (0, node_path_1.normalize)(directory);
|
|
222
|
+
while (currentPath !== (0, node_path_1.dirname)(currentPath)) {
|
|
223
223
|
if (roots.has(currentPath)) {
|
|
224
224
|
return currentPath;
|
|
225
225
|
}
|
|
226
|
-
currentPath = (0,
|
|
226
|
+
currentPath = (0, node_path_1.dirname)(currentPath);
|
|
227
227
|
}
|
|
228
228
|
return roots.has(currentPath) ? currentPath : null;
|
|
229
229
|
}
|
|
@@ -232,15 +232,15 @@ function getProjectUsingESLintConfig(configFilePath, projectRoot, eslintVersion,
|
|
|
232
232
|
config_file_1.baseEsLintConfigFile,
|
|
233
233
|
config_file_1.baseEsLintFlatConfigFile,
|
|
234
234
|
...config_file_1.ESLINT_CONFIG_FILENAMES,
|
|
235
|
-
].find((f) => (0, node_fs_1.existsSync)((0,
|
|
235
|
+
].find((f) => (0, node_fs_1.existsSync)((0, node_path_1.join)(context.workspaceRoot, f)));
|
|
236
236
|
// Add a lint target for each child project without an eslint config, with the root level config as an input
|
|
237
237
|
let standaloneSrcPath;
|
|
238
238
|
if (projectRoot === '.' &&
|
|
239
|
-
(0, node_fs_1.existsSync)((0,
|
|
240
|
-
if ((0, node_fs_1.existsSync)((0,
|
|
239
|
+
(0, node_fs_1.existsSync)((0, node_path_1.join)(context.workspaceRoot, projectRoot, 'package.json'))) {
|
|
240
|
+
if ((0, node_fs_1.existsSync)((0, node_path_1.join)(context.workspaceRoot, projectRoot, 'src'))) {
|
|
241
241
|
standaloneSrcPath = 'src';
|
|
242
242
|
}
|
|
243
|
-
else if ((0, node_fs_1.existsSync)((0,
|
|
243
|
+
else if ((0, node_fs_1.existsSync)((0, node_path_1.join)(context.workspaceRoot, projectRoot, 'lib'))) {
|
|
244
244
|
standaloneSrcPath = 'lib';
|
|
245
245
|
}
|
|
246
246
|
}
|
|
@@ -269,7 +269,7 @@ function buildEslintTargets(eslintConfigs, eslintVersion, projectRoot, workspace
|
|
|
269
269
|
// Certain lint rules can be impacted by changes to dependencies
|
|
270
270
|
'^default',
|
|
271
271
|
...eslintConfigs.map((config) => `{workspaceRoot}/${config}`.replace(`{workspaceRoot}/${projectRoot}`, isRootProject ? '{projectRoot}/' : '{projectRoot}')),
|
|
272
|
-
...((0, node_fs_1.existsSync)((0,
|
|
272
|
+
...((0, node_fs_1.existsSync)((0, node_path_1.join)(workspaceRoot, projectRoot, '.eslintignore'))
|
|
273
273
|
? ['{projectRoot}/.eslintignore']
|
|
274
274
|
: []),
|
|
275
275
|
'{workspaceRoot}/tools/eslint-rules/**/*',
|
|
@@ -323,10 +323,10 @@ function isSubDir(parent, child) {
|
|
|
323
323
|
if (parent === '.') {
|
|
324
324
|
return true;
|
|
325
325
|
}
|
|
326
|
-
parent = (0,
|
|
327
|
-
child = (0,
|
|
328
|
-
if (!parent.endsWith(
|
|
329
|
-
parent +=
|
|
326
|
+
parent = (0, node_path_1.normalize)(parent);
|
|
327
|
+
child = (0, node_path_1.normalize)(child);
|
|
328
|
+
if (!parent.endsWith(node_path_1.sep)) {
|
|
329
|
+
parent += node_path_1.sep;
|
|
330
330
|
}
|
|
331
331
|
return child.startsWith(parent);
|
|
332
332
|
}
|
package/src/utils/config-file.js
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.baseEsLintFlatConfigFile = exports.baseEsLintConfigFile = exports.ESLINT_CONFIG_FILENAMES = exports.ESLINT_OLD_CONFIG_FILENAMES = exports.ESLINT_FLAT_CONFIG_FILENAMES = void 0;
|
|
4
|
-
exports.isFlatConfig = isFlatConfig;
|
|
5
|
-
exports.findFlatConfigFile = findFlatConfigFile;
|
|
6
|
-
exports.findOldConfigFile = findOldConfigFile;
|
|
3
|
+
exports.findOldConfigFile = exports.findFlatConfigFile = exports.isFlatConfig = exports.baseEsLintFlatConfigFile = exports.baseEsLintConfigFile = exports.ESLINT_CONFIG_FILENAMES = exports.ESLINT_OLD_CONFIG_FILENAMES = exports.ESLINT_FLAT_CONFIG_FILENAMES = void 0;
|
|
7
4
|
const fs_1 = require("fs");
|
|
8
5
|
const path_1 = require("path");
|
|
9
6
|
const flat_config_1 = require("./flat-config");
|
|
@@ -26,6 +23,7 @@ function isFlatConfig(configFilePath) {
|
|
|
26
23
|
const configFileName = (0, path_1.basename)(configFilePath);
|
|
27
24
|
return exports.ESLINT_FLAT_CONFIG_FILENAMES.includes(configFileName);
|
|
28
25
|
}
|
|
26
|
+
exports.isFlatConfig = isFlatConfig;
|
|
29
27
|
// https://eslint.org/docs/latest/use/configure/configuration-files#configuration-file-resolution
|
|
30
28
|
function findFlatConfigFile(directory, workspaceRoot) {
|
|
31
29
|
let currentDir = (0, path_1.resolve)(workspaceRoot, directory);
|
|
@@ -42,6 +40,7 @@ function findFlatConfigFile(directory, workspaceRoot) {
|
|
|
42
40
|
}
|
|
43
41
|
return null;
|
|
44
42
|
}
|
|
43
|
+
exports.findFlatConfigFile = findFlatConfigFile;
|
|
45
44
|
function findOldConfigFile(filePathOrDirectory, workspaceRoot) {
|
|
46
45
|
let currentDir = (0, path_1.resolve)(workspaceRoot, filePathOrDirectory);
|
|
47
46
|
if (!(0, fs_1.statSync)(currentDir).isDirectory()) {
|
|
@@ -59,6 +58,7 @@ function findOldConfigFile(filePathOrDirectory, workspaceRoot) {
|
|
|
59
58
|
}
|
|
60
59
|
return null;
|
|
61
60
|
}
|
|
61
|
+
exports.findOldConfigFile = findOldConfigFile;
|
|
62
62
|
function getConfigFileInDirectory(directory, candidateFileNames) {
|
|
63
63
|
for (const filename of candidateFileNames) {
|
|
64
64
|
const filePath = (0, path_1.join)(directory, filename);
|
package/src/utils/flat-config.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.eslintFlatConfigFilenames = void 0;
|
|
4
|
-
exports.flatConfigEslintFilename = flatConfigEslintFilename;
|
|
5
|
-
exports.useFlatConfig = useFlatConfig;
|
|
3
|
+
exports.useFlatConfig = exports.flatConfigEslintFilename = exports.eslintFlatConfigFilenames = void 0;
|
|
6
4
|
// todo: add support for eslint.config.mjs,
|
|
7
5
|
exports.eslintFlatConfigFilenames = [
|
|
8
6
|
'eslint.config.js',
|
|
@@ -16,6 +14,7 @@ function flatConfigEslintFilename(tree) {
|
|
|
16
14
|
}
|
|
17
15
|
throw new Error('Could not find flat config file');
|
|
18
16
|
}
|
|
17
|
+
exports.flatConfigEslintFilename = flatConfigEslintFilename;
|
|
19
18
|
function useFlatConfig(tree) {
|
|
20
19
|
try {
|
|
21
20
|
return !!flatConfigEslintFilename(tree);
|
|
@@ -24,3 +23,4 @@ function useFlatConfig(tree) {
|
|
|
24
23
|
return false;
|
|
25
24
|
}
|
|
26
25
|
}
|
|
26
|
+
exports.useFlatConfig = useFlatConfig;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.resolveESLintClass =
|
|
3
|
+
exports.resolveESLintClass = void 0;
|
|
4
4
|
async function resolveESLintClass(useFlatConfig = false) {
|
|
5
5
|
try {
|
|
6
6
|
// In eslint 8.57.0 (the final v8 version), a dedicated API was added for resolving the correct ESLint class.
|
|
@@ -20,3 +20,4 @@ async function resolveESLintClass(useFlatConfig = false) {
|
|
|
20
20
|
throw new Error('Unable to find ESLint. Ensure ESLint is installed.');
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
|
+
exports.resolveESLintClass = resolveESLintClass;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.hasRulesRequiringTypeChecking =
|
|
4
|
-
exports.removeParserOptionsProjectIfNotRequired = removeParserOptionsProjectIfNotRequired;
|
|
3
|
+
exports.removeParserOptionsProjectIfNotRequired = exports.hasRulesRequiringTypeChecking = void 0;
|
|
5
4
|
// Cache the resolved rules from node_modules
|
|
6
5
|
let knownRulesRequiringTypeChecking = null;
|
|
7
6
|
function resolveKnownRulesRequiringTypeChecking() {
|
|
@@ -38,6 +37,7 @@ function hasRulesRequiringTypeChecking(eslintConfig) {
|
|
|
38
37
|
const allRulesInConfig = getAllRulesInConfig(eslintConfig);
|
|
39
38
|
return allRulesInConfig.some((rule) => knownRulesRequiringTypeChecking.includes(rule));
|
|
40
39
|
}
|
|
40
|
+
exports.hasRulesRequiringTypeChecking = hasRulesRequiringTypeChecking;
|
|
41
41
|
function removeParserOptionsProjectIfNotRequired(json) {
|
|
42
42
|
// At least one rule requiring type-checking is in use, do not migrate the config
|
|
43
43
|
if (hasRulesRequiringTypeChecking(json)) {
|
|
@@ -46,6 +46,7 @@ function removeParserOptionsProjectIfNotRequired(json) {
|
|
|
46
46
|
removeProjectParserOptionFromConfig(json);
|
|
47
47
|
return json;
|
|
48
48
|
}
|
|
49
|
+
exports.removeParserOptionsProjectIfNotRequired = removeParserOptionsProjectIfNotRequired;
|
|
49
50
|
function determineEnabledRules(rules) {
|
|
50
51
|
return Object.entries(rules)
|
|
51
52
|
.filter(([key, value]) => {
|
package/src/utils/versions.d.ts
CHANGED
|
@@ -2,4 +2,4 @@ export declare const nxVersion: any;
|
|
|
2
2
|
export declare const eslintVersion = "~8.57.0";
|
|
3
3
|
export declare const eslintrcVersion = "^2.1.1";
|
|
4
4
|
export declare const eslintConfigPrettierVersion = "^9.0.0";
|
|
5
|
-
export declare const typescriptESLintVersion = "^7.
|
|
5
|
+
export declare const typescriptESLintVersion = "^7.3.0";
|
package/src/utils/versions.js
CHANGED
|
@@ -5,4 +5,4 @@ exports.nxVersion = require('../../package.json').version;
|
|
|
5
5
|
exports.eslintVersion = '~8.57.0';
|
|
6
6
|
exports.eslintrcVersion = '^2.1.1';
|
|
7
7
|
exports.eslintConfigPrettierVersion = '^9.0.0';
|
|
8
|
-
exports.typescriptESLintVersion = '^7.
|
|
8
|
+
exports.typescriptESLintVersion = '^7.3.0';
|