@nx/eslint 19.4.3 → 19.5.0-beta.1
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/migrations.json +14 -0
- package/package.json +4 -4
- package/src/executors/lint/hasher.d.ts +0 -1
- 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 +1 -2
- package/src/generators/convert-to-flat-config/converters/json-converter.js +1 -2
- package/src/generators/convert-to-flat-config/generator.js +1 -2
- package/src/generators/convert-to-inferred/convert-to-inferred.js +1 -2
- package/src/generators/init/init-migration.js +2 -3
- package/src/generators/init/init.js +2 -3
- package/src/generators/lint-project/lint-project.js +2 -3
- package/src/generators/lint-project/setup-root-eslint.js +1 -2
- package/src/generators/utils/eslint-file.js +11 -12
- package/src/generators/utils/eslint-targets.js +1 -2
- package/src/generators/utils/flat-config/ast-utils.js +17 -18
- package/src/generators/utils/flat-config/path-utils.js +2 -3
- package/src/generators/utils/plugin.js +1 -2
- package/src/generators/workspace-rule/workspace-rule.js +1 -2
- 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/utils/config-file.js +4 -4
- package/src/utils/flat-config.js +3 -3
- package/src/utils/resolve-eslint-class.js +1 -2
- package/src/utils/rules-requiring-type-checking.js +2 -3
- package/src/utils/versions.d.ts +1 -1
- package/src/utils/versions.js +1 -1
package/migrations.json
CHANGED
@@ -138,6 +138,20 @@
|
|
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
|
+
}
|
141
155
|
}
|
142
156
|
}
|
143
157
|
}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@nx/eslint",
|
3
|
-
"version": "19.
|
3
|
+
"version": "19.5.0-beta.1",
|
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": "19.
|
39
|
-
"@nx/js": "19.
|
38
|
+
"@nx/devkit": "19.5.0-beta.1",
|
39
|
+
"@nx/js": "19.5.0-beta.1",
|
40
40
|
"semver": "^7.5.3",
|
41
41
|
"tslib": "^2.3.0",
|
42
42
|
"typescript": "~5.4.2",
|
43
|
-
"@nx/linter": "19.
|
43
|
+
"@nx/linter": "19.5.0-beta.1"
|
44
44
|
},
|
45
45
|
"peerDependenciesMeta": {
|
46
46
|
"@zkochan/js-yaml": {
|
@@ -1,5 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.default = run;
|
3
4
|
const devkit_1 = require("@nx/devkit");
|
4
5
|
async function run(task, context) {
|
5
6
|
const res = await context.hasher.hashTask(task, context.taskGraph, context.env);
|
@@ -31,7 +32,6 @@ async function run(task, context) {
|
|
31
32
|
},
|
32
33
|
};
|
33
34
|
}
|
34
|
-
exports.default = run;
|
35
35
|
function allDeps(taskId, taskGraph, projectGraph) {
|
36
36
|
if (!taskGraph.tasks) {
|
37
37
|
return [];
|
@@ -1,5 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.default = run;
|
3
4
|
const devkit_1 = require("@nx/devkit");
|
4
5
|
const fs_1 = require("fs");
|
5
6
|
const utils_1 = require("nx/src/tasks-runner/utils");
|
@@ -143,7 +144,6 @@ Please see https://nx.dev/recipes/tips-n-tricks/eslint for full guidance on how
|
|
143
144
|
totals.warnings <= normalizedOptions.maxWarnings)),
|
144
145
|
};
|
145
146
|
}
|
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 = resolveAndInstantiateESLint;
|
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,4 +61,3 @@ 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 = convertEslintJsonToFlatConfig;
|
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,7 +103,6 @@ function convertEslintJsonToFlatConfig(tree, root, config, ignorePaths) {
|
|
103
103
|
addESLintJS: isESLintJSNeeded,
|
104
104
|
};
|
105
105
|
}
|
106
|
-
exports.convertEslintJsonToFlatConfig = convertEslintJsonToFlatConfig;
|
107
106
|
// add parsed extends to export blocks and add import statements
|
108
107
|
function addExtends(importsMap, configBlocks, config) {
|
109
108
|
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 = convertToFlatConfigGenerator;
|
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,7 +37,6 @@ async function convertToFlatConfigGenerator(tree, options) {
|
|
37
37
|
return () => (0, devkit_1.installPackagesTask)(tree);
|
38
38
|
}
|
39
39
|
}
|
40
|
-
exports.convertToFlatConfigGenerator = convertToFlatConfigGenerator;
|
41
40
|
exports.default = convertToFlatConfigGenerator;
|
42
41
|
function convertRootToFlatConfig(tree, eslintFile) {
|
43
42
|
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 = convertToInferred;
|
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,7 +23,6 @@ async function convertToInferred(tree, options) {
|
|
23
23
|
await (0, devkit_1.formatFiles)(tree);
|
24
24
|
}
|
25
25
|
}
|
26
|
-
exports.convertToInferred = convertToInferred;
|
27
26
|
function postTargetTransformer(target, tree, projectDetails, inferredTargetConfiguration) {
|
28
27
|
if (target.inputs) {
|
29
28
|
const inputs = target.inputs.filter((input) => typeof input === 'string' &&
|
@@ -1,6 +1,7 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.
|
3
|
+
exports.migrateConfigToMonorepoStyle = migrateConfigToMonorepoStyle;
|
4
|
+
exports.findLintTarget = findLintTarget;
|
4
5
|
const devkit_1 = require("@nx/devkit");
|
5
6
|
const path_1 = require("path");
|
6
7
|
const eslint_file_1 = require("../utils/eslint-file");
|
@@ -68,13 +69,11 @@ function migrateConfigToMonorepoStyle(projects, tree, unitTestRunner, keepExisti
|
|
68
69
|
'@nx/eslint-plugin': versions_1.nxVersion,
|
69
70
|
});
|
70
71
|
}
|
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;
|
78
77
|
function migrateEslintFile(projectEslintPath, tree) {
|
79
78
|
const baseFile = (0, eslint_file_1.findEslintFile)(tree);
|
80
79
|
if ((0, eslint_file_1.isEslintConfigSupported)(tree)) {
|
@@ -1,6 +1,7 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.
|
3
|
+
exports.initEsLint = initEsLint;
|
4
|
+
exports.lintInitGenerator = lintInitGenerator;
|
4
5
|
const devkit_1 = require("@nx/devkit");
|
5
6
|
const add_plugin_1 = require("@nx/devkit/src/utils/add-plugin");
|
6
7
|
const versions_1 = require("../../utils/versions");
|
@@ -75,8 +76,6 @@ async function initEsLint(tree, options) {
|
|
75
76
|
}
|
76
77
|
return (0, devkit_1.runTasksInSerial)(...tasks);
|
77
78
|
}
|
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,6 +1,7 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.
|
3
|
+
exports.lintProjectGenerator = lintProjectGenerator;
|
4
|
+
exports.lintProjectGeneratorInternal = lintProjectGeneratorInternal;
|
4
5
|
const devkit_1 = require("@nx/devkit");
|
5
6
|
const eslint_file_1 = require("../utils/eslint-file");
|
6
7
|
const path_1 = require("path");
|
@@ -15,7 +16,6 @@ const setup_root_eslint_1 = require("./setup-root-eslint");
|
|
15
16
|
function lintProjectGenerator(tree, options) {
|
16
17
|
return lintProjectGeneratorInternal(tree, { addPlugin: false, ...options });
|
17
18
|
}
|
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,7 +108,6 @@ async function lintProjectGeneratorInternal(tree, options) {
|
|
108
108
|
}
|
109
109
|
return (0, devkit_1.runTasksInSerial)(...tasks);
|
110
110
|
}
|
111
|
-
exports.lintProjectGeneratorInternal = lintProjectGeneratorInternal;
|
112
111
|
function createEsLintConfiguration(tree, options, projectConfig, setParserOptionsProject, rootProject) {
|
113
112
|
// we are only extending root for non-standalone projects or their complementary e2e apps
|
114
113
|
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 = setupRootEsLint;
|
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,4 +30,3 @@ function setupRootEsLint(tree, options) {
|
|
30
30
|
})
|
31
31
|
: () => { };
|
32
32
|
}
|
33
|
-
exports.setupRootEsLint = setupRootEsLint;
|
@@ -1,6 +1,16 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.
|
3
|
+
exports.findEslintFile = 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;
|
4
14
|
const devkit_1 = require("@nx/devkit");
|
5
15
|
const flat_config_1 = require("../../utils/flat-config");
|
6
16
|
const ast_utils_1 = require("./flat-config/ast-utils");
|
@@ -21,7 +31,6 @@ function findEslintFile(tree, projectRoot) {
|
|
21
31
|
}
|
22
32
|
return null;
|
23
33
|
}
|
24
|
-
exports.findEslintFile = findEslintFile;
|
25
34
|
function isEslintConfigSupported(tree, projectRoot = '') {
|
26
35
|
const eslintFile = findEslintFile(tree, projectRoot);
|
27
36
|
if (!eslintFile) {
|
@@ -29,7 +38,6 @@ function isEslintConfigSupported(tree, projectRoot = '') {
|
|
29
38
|
}
|
30
39
|
return eslintFile.endsWith('.json') || eslintFile.endsWith('.config.js');
|
31
40
|
}
|
32
|
-
exports.isEslintConfigSupported = isEslintConfigSupported;
|
33
41
|
function updateRelativePathsInConfig(tree, sourcePath, destinationPath) {
|
34
42
|
if (sourcePath === destinationPath ||
|
35
43
|
!isEslintConfigSupported(tree, destinationPath)) {
|
@@ -60,7 +68,6 @@ function updateRelativePathsInConfig(tree, sourcePath, destinationPath) {
|
|
60
68
|
});
|
61
69
|
}
|
62
70
|
}
|
63
|
-
exports.updateRelativePathsInConfig = updateRelativePathsInConfig;
|
64
71
|
function replaceFlatConfigPaths(config, sourceRoot, offset, destinationRoot, tree) {
|
65
72
|
let match;
|
66
73
|
let newConfig = config;
|
@@ -126,7 +133,6 @@ function addOverrideToLintConfig(tree, root, override, options = {
|
|
126
133
|
});
|
127
134
|
}
|
128
135
|
}
|
129
|
-
exports.addOverrideToLintConfig = addOverrideToLintConfig;
|
130
136
|
function overrideNeedsCompat(override) {
|
131
137
|
return (override.env || override.extends || override.plugins || override.parser);
|
132
138
|
}
|
@@ -161,7 +167,6 @@ function updateOverrideInLintConfig(tree, root, lookup, update) {
|
|
161
167
|
});
|
162
168
|
}
|
163
169
|
}
|
164
|
-
exports.updateOverrideInLintConfig = updateOverrideInLintConfig;
|
165
170
|
function lintConfigHasOverride(tree, root, lookup, checkBaseConfig = false) {
|
166
171
|
if (!isEslintConfigSupported(tree, root)) {
|
167
172
|
return false;
|
@@ -177,7 +182,6 @@ function lintConfigHasOverride(tree, root, lookup, checkBaseConfig = false) {
|
|
177
182
|
return (0, devkit_1.readJson)(tree, fileName).overrides?.some(lookup) || false;
|
178
183
|
}
|
179
184
|
}
|
180
|
-
exports.lintConfigHasOverride = lintConfigHasOverride;
|
181
185
|
function replaceOverridesInLintConfig(tree, root, overrides) {
|
182
186
|
if ((0, flat_config_1.useFlatConfig)(tree)) {
|
183
187
|
const fileName = (0, devkit_1.joinPathFragments)(root, (0, flat_config_1.flatConfigEslintFilename)(tree));
|
@@ -201,7 +205,6 @@ function replaceOverridesInLintConfig(tree, root, overrides) {
|
|
201
205
|
});
|
202
206
|
}
|
203
207
|
}
|
204
|
-
exports.replaceOverridesInLintConfig = replaceOverridesInLintConfig;
|
205
208
|
function addExtendsToLintConfig(tree, root, plugin) {
|
206
209
|
const plugins = Array.isArray(plugin) ? plugin : [plugin];
|
207
210
|
if ((0, flat_config_1.useFlatConfig)(tree)) {
|
@@ -225,7 +228,6 @@ function addExtendsToLintConfig(tree, root, plugin) {
|
|
225
228
|
});
|
226
229
|
}
|
227
230
|
}
|
228
|
-
exports.addExtendsToLintConfig = addExtendsToLintConfig;
|
229
231
|
function addPluginsToLintConfig(tree, root, plugin) {
|
230
232
|
const plugins = Array.isArray(plugin) ? plugin : [plugin];
|
231
233
|
if ((0, flat_config_1.useFlatConfig)(tree)) {
|
@@ -251,7 +253,6 @@ function addPluginsToLintConfig(tree, root, plugin) {
|
|
251
253
|
});
|
252
254
|
}
|
253
255
|
}
|
254
|
-
exports.addPluginsToLintConfig = addPluginsToLintConfig;
|
255
256
|
function addIgnoresToLintConfig(tree, root, ignorePatterns) {
|
256
257
|
if ((0, flat_config_1.useFlatConfig)(tree)) {
|
257
258
|
const fileName = (0, devkit_1.joinPathFragments)(root, (0, flat_config_1.flatConfigEslintFilename)(tree));
|
@@ -272,7 +273,6 @@ function addIgnoresToLintConfig(tree, root, ignorePatterns) {
|
|
272
273
|
});
|
273
274
|
}
|
274
275
|
}
|
275
|
-
exports.addIgnoresToLintConfig = addIgnoresToLintConfig;
|
276
276
|
function getPluginImport(pluginName) {
|
277
277
|
if (pluginName.includes('eslint-plugin-')) {
|
278
278
|
return pluginName;
|
@@ -286,4 +286,3 @@ 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 = getEslintTargets;
|
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,4 +15,3 @@ function getEslintTargets(tree) {
|
|
15
15
|
});
|
16
16
|
return eslintTargetNames;
|
17
17
|
}
|
18
|
-
exports.getEslintTargets = getEslintTargets;
|
@@ -1,6 +1,22 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.
|
3
|
+
exports.removeOverridesFromLintConfig = 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;
|
4
20
|
const devkit_1 = require("@nx/devkit");
|
5
21
|
const ts = require("typescript");
|
6
22
|
const path_utils_1 = require("./path-utils");
|
@@ -31,7 +47,6 @@ function removeOverridesFromLintConfig(content) {
|
|
31
47
|
});
|
32
48
|
return (0, devkit_1.applyChangesToString)(content, changes);
|
33
49
|
}
|
34
|
-
exports.removeOverridesFromLintConfig = removeOverridesFromLintConfig;
|
35
50
|
function findAllBlocks(source) {
|
36
51
|
return ts.forEachChild(source, function analyze(node) {
|
37
52
|
if (ts.isExpressionStatement(node) &&
|
@@ -82,7 +97,6 @@ function hasOverride(content, lookup) {
|
|
82
97
|
}
|
83
98
|
return false;
|
84
99
|
}
|
85
|
-
exports.hasOverride = hasOverride;
|
86
100
|
function parseTextToJson(text) {
|
87
101
|
return (0, devkit_1.parseJson)(text
|
88
102
|
// ensure property names have double quotes so that JSON.parse works
|
@@ -138,7 +152,6 @@ function replaceOverride(content, root, lookup, update) {
|
|
138
152
|
});
|
139
153
|
return (0, devkit_1.applyChangesToString)(content, changes);
|
140
154
|
}
|
141
|
-
exports.replaceOverride = replaceOverride;
|
142
155
|
/**
|
143
156
|
* Adding require statement to the top of the file
|
144
157
|
*/
|
@@ -213,7 +226,6 @@ function addImportToFlatConfig(content, variable, imp) {
|
|
213
226
|
},
|
214
227
|
]);
|
215
228
|
}
|
216
|
-
exports.addImportToFlatConfig = addImportToFlatConfig;
|
217
229
|
/**
|
218
230
|
* Injects new ts.expression to the end of the module.exports array.
|
219
231
|
*/
|
@@ -254,7 +266,6 @@ function addBlockToFlatConfigExport(content, config, options = {
|
|
254
266
|
]);
|
255
267
|
}
|
256
268
|
}
|
257
|
-
exports.addBlockToFlatConfigExport = addBlockToFlatConfigExport;
|
258
269
|
function removePlugin(content, pluginName, pluginImport) {
|
259
270
|
const source = ts.createSourceFile('', content, ts.ScriptTarget.Latest, true, ts.ScriptKind.JS);
|
260
271
|
const changes = [];
|
@@ -365,7 +376,6 @@ function removePlugin(content, pluginName, pluginImport) {
|
|
365
376
|
});
|
366
377
|
return (0, devkit_1.applyChangesToString)(content, changes);
|
367
378
|
}
|
368
|
-
exports.removePlugin = removePlugin;
|
369
379
|
function removeCompatExtends(content, compatExtends) {
|
370
380
|
const source = ts.createSourceFile('', content, ts.ScriptTarget.Latest, true, ts.ScriptKind.JS);
|
371
381
|
const changes = [];
|
@@ -401,7 +411,6 @@ function removeCompatExtends(content, compatExtends) {
|
|
401
411
|
});
|
402
412
|
return (0, devkit_1.applyChangesToString)(content, changes);
|
403
413
|
}
|
404
|
-
exports.removeCompatExtends = removeCompatExtends;
|
405
414
|
/**
|
406
415
|
* Add plugins block to the top of the export blocks
|
407
416
|
*/
|
@@ -415,7 +424,6 @@ function addPluginsToExportsBlock(content, plugins) {
|
|
415
424
|
insertAtTheEnd: false,
|
416
425
|
});
|
417
426
|
}
|
418
|
-
exports.addPluginsToExportsBlock = addPluginsToExportsBlock;
|
419
427
|
/**
|
420
428
|
* Adds compat if missing to flat config
|
421
429
|
*/
|
@@ -435,7 +443,6 @@ function addCompatToFlatConfig(content) {
|
|
435
443
|
},
|
436
444
|
]);
|
437
445
|
}
|
438
|
-
exports.addCompatToFlatConfig = addCompatToFlatConfig;
|
439
446
|
const DEFAULT_FLAT_CONFIG = `
|
440
447
|
const compat = new FlatCompat({
|
441
448
|
baseDirectory: __dirname,
|
@@ -467,15 +474,12 @@ function createNodeList(importsMap, exportElements, isFlatCompatNeeded) {
|
|
467
474
|
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))),
|
468
475
|
]);
|
469
476
|
}
|
470
|
-
exports.createNodeList = createNodeList;
|
471
477
|
function generateSpreadElement(name) {
|
472
478
|
return ts.factory.createSpreadElement(ts.factory.createIdentifier(name));
|
473
479
|
}
|
474
|
-
exports.generateSpreadElement = generateSpreadElement;
|
475
480
|
function generatePluginExtendsElement(plugins) {
|
476
481
|
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))));
|
477
482
|
}
|
478
|
-
exports.generatePluginExtendsElement = generatePluginExtendsElement;
|
479
483
|
/**
|
480
484
|
* Stringifies TS nodes to file content string
|
481
485
|
*/
|
@@ -489,7 +493,6 @@ function stringifyNodeList(nodes) {
|
|
489
493
|
// add new line before module.exports = ...
|
490
494
|
.replace(/module\.exports/, '\nmodule.exports'));
|
491
495
|
}
|
492
|
-
exports.stringifyNodeList = stringifyNodeList;
|
493
496
|
/**
|
494
497
|
* generates AST require statement
|
495
498
|
*/
|
@@ -498,7 +501,6 @@ function generateRequire(variableName, imp) {
|
|
498
501
|
ts.factory.createVariableDeclaration(variableName, undefined, undefined, ts.factory.createCallExpression(ts.factory.createIdentifier('require'), undefined, [ts.factory.createStringLiteral(imp)])),
|
499
502
|
], ts.NodeFlags.Const));
|
500
503
|
}
|
501
|
-
exports.generateRequire = generateRequire;
|
502
504
|
/**
|
503
505
|
* Generates AST object or spread element based on JSON override object
|
504
506
|
*/
|
@@ -541,7 +543,6 @@ function generateFlatOverride(override) {
|
|
541
543
|
], undefined, ts.factory.createToken(ts.SyntaxKind.EqualsGreaterThanToken), ts.factory.createParenthesizedExpression(ts.factory.createObjectLiteralExpression(objectLiteralElements, true))),
|
542
544
|
]));
|
543
545
|
}
|
544
|
-
exports.generateFlatOverride = generateFlatOverride;
|
545
546
|
function mapFilePaths(override) {
|
546
547
|
if (override.files) {
|
547
548
|
override.files = Array.isArray(override.files)
|
@@ -556,7 +557,6 @@ function mapFilePaths(override) {
|
|
556
557
|
override.excludedFiles = override.excludedFiles.map((file) => (0, path_utils_1.mapFilePath)(file));
|
557
558
|
}
|
558
559
|
}
|
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,7 +591,6 @@ 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;
|
595
594
|
function isValidKey(key) {
|
596
595
|
return /^[a-zA-Z0-9_]+$/.test(key);
|
597
596
|
}
|
@@ -1,6 +1,7 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.
|
3
|
+
exports.updateFiles = updateFiles;
|
4
|
+
exports.mapFilePath = mapFilePath;
|
4
5
|
const devkit_1 = require("@nx/devkit");
|
5
6
|
function updateFiles(override) {
|
6
7
|
if (override.files) {
|
@@ -11,7 +12,6 @@ function updateFiles(override) {
|
|
11
12
|
}
|
12
13
|
return override;
|
13
14
|
}
|
14
|
-
exports.updateFiles = updateFiles;
|
15
15
|
function mapFilePath(filePath) {
|
16
16
|
if (filePath.startsWith('!')) {
|
17
17
|
const fileWithoutBang = filePath.slice(1);
|
@@ -25,4 +25,3 @@ 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 = hasEslintPlugin;
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
5
5
|
function hasEslintPlugin(tree) {
|
6
6
|
const nxJson = (0, devkit_1.readNxJson)(tree);
|
@@ -8,4 +8,3 @@ 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 = lintWorkspaceRuleGenerator;
|
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,4 +75,3 @@ async function lintWorkspaceRuleGenerator(tree, options) {
|
|
75
75
|
`);
|
76
76
|
return projectGeneratorCallback;
|
77
77
|
}
|
78
|
-
exports.lintWorkspaceRuleGenerator = lintWorkspaceRuleGenerator;
|
@@ -1,6 +1,7 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.
|
3
|
+
exports.WORKSPACE_PLUGIN_DIR = exports.WORKSPACE_RULES_PROJECT_NAME = void 0;
|
4
|
+
exports.lintWorkspaceRulesProjectGenerator = lintWorkspaceRulesProjectGenerator;
|
4
5
|
const devkit_1 = require("@nx/devkit");
|
5
6
|
const js_1 = require("@nx/js");
|
6
7
|
const add_swc_dependencies_1 = require("@nx/js/src/utils/swc/add-swc-dependencies");
|
@@ -79,4 +80,3 @@ async function lintWorkspaceRulesProjectGenerator(tree, options = {}) {
|
|
79
80
|
}
|
80
81
|
return (0, devkit_1.runTasksInSerial)(...tasks);
|
81
82
|
}
|
82
|
-
exports.lintWorkspaceRulesProjectGenerator = lintWorkspaceRulesProjectGenerator;
|
@@ -1,9 +1,9 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.default = replacePackage;
|
3
4
|
const devkit_1 = require("@nx/devkit");
|
4
5
|
const replace_package_1 = require("@nx/devkit/src/utils/replace-package");
|
5
6
|
async function replacePackage(tree) {
|
6
7
|
await (0, replace_package_1.replaceNrwlPackageWithNxPackage)(tree, '@nrwl/linter', '@nx/linter');
|
7
8
|
await (0, devkit_1.formatFiles)(tree);
|
8
9
|
}
|
9
|
-
exports.default = replacePackage;
|
@@ -1,5 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.default = update;
|
3
4
|
const devkit_1 = require("@nx/devkit");
|
4
5
|
const executor_options_utils_1 = require("@nx/devkit/src/generators/executor-options-utils");
|
5
6
|
const eslint_file_1 = require("../../generators/utils/eslint-file");
|
@@ -41,4 +42,3 @@ function update(tree) {
|
|
41
42
|
(0, executor_options_utils_1.forEachExecutorOptions)(tree, '@nx/esbuild:esbuild', addIgnorePattern('{projectRoot}/esbuild.config.{js,ts,mjs,mts}'));
|
42
43
|
(0, executor_options_utils_1.forEachExecutorOptions)(tree, '@nx/rollup:rollup', addIgnorePattern('{projectRoot}/rollup.config.{js,ts,mjs,mts}'));
|
43
44
|
}
|
44
|
-
exports.default = update;
|
@@ -1,5 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.default = replacePackage;
|
3
4
|
const devkit_1 = require("@nx/devkit");
|
4
5
|
const replace_package_1 = require("@nx/devkit/src/utils/replace-package");
|
5
6
|
async function replacePackage(tree) {
|
@@ -9,7 +10,6 @@ async function replacePackage(tree) {
|
|
9
10
|
updateProjectExecutor(tree);
|
10
11
|
await (0, devkit_1.formatFiles)(tree);
|
11
12
|
}
|
12
|
-
exports.default = replacePackage;
|
13
13
|
function updateNxJsonExecutor(tree) {
|
14
14
|
if (!tree.exists('nx.json')) {
|
15
15
|
return;
|
@@ -1,5 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.default = update;
|
3
4
|
const devkit_1 = require("@nx/devkit");
|
4
5
|
const versions_1 = require("../../utils/versions");
|
5
6
|
const path_1 = require("path");
|
@@ -71,4 +72,3 @@ async function update(tree) {
|
|
71
72
|
updateRecommended(tree);
|
72
73
|
await (0, devkit_1.formatFiles)(tree);
|
73
74
|
}
|
74
|
-
exports.default = update;
|
@@ -1,5 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.default = update;
|
3
4
|
const devkit_1 = require("@nx/devkit");
|
4
5
|
async function update(tree) {
|
5
6
|
const projects = (0, devkit_1.getProjects)(tree);
|
@@ -37,7 +38,6 @@ async function update(tree) {
|
|
37
38
|
}
|
38
39
|
await (0, devkit_1.formatFiles)(tree);
|
39
40
|
}
|
40
|
-
exports.default = update;
|
41
41
|
function getLintRoot({ root, sourceRoot }) {
|
42
42
|
if (root === '' || root === '.') {
|
43
43
|
return sourceRoot || './src';
|
@@ -1,5 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.default = update;
|
3
4
|
const devkit_1 = require("@nx/devkit");
|
4
5
|
const executor_options_utils_1 = require("@nx/devkit/src/generators/executor-options-utils");
|
5
6
|
const eslint_file_1 = require("../../generators/utils/eslint-file");
|
@@ -92,7 +93,6 @@ async function update(tree) {
|
|
92
93
|
(0, devkit_1.updateNxJson)(tree, nxJson);
|
93
94
|
await (0, devkit_1.formatFiles)(tree);
|
94
95
|
}
|
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/utils/config-file.js
CHANGED
@@ -1,6 +1,9 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.
|
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;
|
4
7
|
const fs_1 = require("fs");
|
5
8
|
const path_1 = require("path");
|
6
9
|
const flat_config_1 = require("./flat-config");
|
@@ -23,7 +26,6 @@ function isFlatConfig(configFilePath) {
|
|
23
26
|
const configFileName = (0, path_1.basename)(configFilePath);
|
24
27
|
return exports.ESLINT_FLAT_CONFIG_FILENAMES.includes(configFileName);
|
25
28
|
}
|
26
|
-
exports.isFlatConfig = isFlatConfig;
|
27
29
|
// https://eslint.org/docs/latest/use/configure/configuration-files#configuration-file-resolution
|
28
30
|
function findFlatConfigFile(directory, workspaceRoot) {
|
29
31
|
let currentDir = (0, path_1.resolve)(workspaceRoot, directory);
|
@@ -40,7 +42,6 @@ function findFlatConfigFile(directory, workspaceRoot) {
|
|
40
42
|
}
|
41
43
|
return null;
|
42
44
|
}
|
43
|
-
exports.findFlatConfigFile = findFlatConfigFile;
|
44
45
|
function findOldConfigFile(filePathOrDirectory, workspaceRoot) {
|
45
46
|
let currentDir = (0, path_1.resolve)(workspaceRoot, filePathOrDirectory);
|
46
47
|
if (!(0, fs_1.statSync)(currentDir).isDirectory()) {
|
@@ -58,7 +59,6 @@ function findOldConfigFile(filePathOrDirectory, workspaceRoot) {
|
|
58
59
|
}
|
59
60
|
return null;
|
60
61
|
}
|
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,6 +1,8 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.
|
3
|
+
exports.eslintFlatConfigFilenames = void 0;
|
4
|
+
exports.flatConfigEslintFilename = flatConfigEslintFilename;
|
5
|
+
exports.useFlatConfig = useFlatConfig;
|
4
6
|
// todo: add support for eslint.config.mjs,
|
5
7
|
exports.eslintFlatConfigFilenames = [
|
6
8
|
'eslint.config.js',
|
@@ -14,7 +16,6 @@ function flatConfigEslintFilename(tree) {
|
|
14
16
|
}
|
15
17
|
throw new Error('Could not find flat config file');
|
16
18
|
}
|
17
|
-
exports.flatConfigEslintFilename = flatConfigEslintFilename;
|
18
19
|
function useFlatConfig(tree) {
|
19
20
|
try {
|
20
21
|
return !!flatConfigEslintFilename(tree);
|
@@ -23,4 +24,3 @@ function useFlatConfig(tree) {
|
|
23
24
|
return false;
|
24
25
|
}
|
25
26
|
}
|
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 = resolveESLintClass;
|
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,4 +20,3 @@ 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,6 +1,7 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.
|
3
|
+
exports.hasRulesRequiringTypeChecking = hasRulesRequiringTypeChecking;
|
4
|
+
exports.removeParserOptionsProjectIfNotRequired = removeParserOptionsProjectIfNotRequired;
|
4
5
|
// Cache the resolved rules from node_modules
|
5
6
|
let knownRulesRequiringTypeChecking = null;
|
6
7
|
function resolveKnownRulesRequiringTypeChecking() {
|
@@ -37,7 +38,6 @@ function hasRulesRequiringTypeChecking(eslintConfig) {
|
|
37
38
|
const allRulesInConfig = getAllRulesInConfig(eslintConfig);
|
38
39
|
return allRulesInConfig.some((rule) => knownRulesRequiringTypeChecking.includes(rule));
|
39
40
|
}
|
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,7 +46,6 @@ function removeParserOptionsProjectIfNotRequired(json) {
|
|
46
46
|
removeProjectParserOptionFromConfig(json);
|
47
47
|
return json;
|
48
48
|
}
|
49
|
-
exports.removeParserOptionsProjectIfNotRequired = removeParserOptionsProjectIfNotRequired;
|
50
49
|
function determineEnabledRules(rules) {
|
51
50
|
return Object.entries(rules)
|
52
51
|
.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.16.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.16.0';
|