@nx/eslint 21.0.0-beta.8 → 21.0.0-beta.9
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 +0 -81
- package/package.json +3 -3
- package/src/migrations/update-17-0-0-rename-to-eslint/update-17-0-0-rename-to-eslint.d.ts +0 -2
- package/src/migrations/update-17-0-0-rename-to-eslint/update-17-0-0-rename-to-eslint.js +0 -47
- package/src/migrations/update-17-1-0/update-typescript-eslint.d.ts +0 -2
- package/src/migrations/update-17-1-0/update-typescript-eslint.js +0 -74
- package/src/migrations/update-17-2-0/simplify-eslint-patterns.d.ts +0 -2
- package/src/migrations/update-17-2-0/simplify-eslint-patterns.js +0 -46
- package/src/migrations/update-17-2-9/move-options-to-target-defaults.d.ts +0 -2
- package/src/migrations/update-17-2-9/move-options-to-target-defaults.js +0 -107
package/migrations.json
CHANGED
@@ -1,25 +1,5 @@
|
|
1
1
|
{
|
2
2
|
"generators": {
|
3
|
-
"update-17-0-0-rename-to-eslint": {
|
4
|
-
"version": "17.0.0-beta.7",
|
5
|
-
"description": "update-17-0-0-rename-to-eslint",
|
6
|
-
"implementation": "./src/migrations/update-17-0-0-rename-to-eslint/update-17-0-0-rename-to-eslint"
|
7
|
-
},
|
8
|
-
"update-typescript-eslint": {
|
9
|
-
"version": "17.1.0-beta.1",
|
10
|
-
"description": "Updates for @typescript-utils/utils v6.9.1+",
|
11
|
-
"implementation": "./src/migrations/update-17-1-0/update-typescript-eslint"
|
12
|
-
},
|
13
|
-
"simplify-eslint-patterns": {
|
14
|
-
"version": "17.2.0-beta.0",
|
15
|
-
"description": "Simplify eslintFilePatterns",
|
16
|
-
"implementation": "./src/migrations/update-17-2-0/simplify-eslint-patterns"
|
17
|
-
},
|
18
|
-
"move-options-to-target-defaults": {
|
19
|
-
"version": "17.2.9",
|
20
|
-
"description": "Move executor options to target defaults",
|
21
|
-
"implementation": "./src/migrations/update-17-2-9/move-options-to-target-defaults"
|
22
|
-
},
|
23
3
|
"update-typescript-eslint-v8.13.0": {
|
24
4
|
"version": "20.2.0-beta.5",
|
25
5
|
"description": "Update TypeScript ESLint packages to v8.13.0 if they are already on v8",
|
@@ -32,67 +12,6 @@
|
|
32
12
|
}
|
33
13
|
},
|
34
14
|
"packageJsonUpdates": {
|
35
|
-
"17.0.0": {
|
36
|
-
"version": "17.0.0-rc.2",
|
37
|
-
"packages": {
|
38
|
-
"eslint-config-prettier": {
|
39
|
-
"version": "^9.0.0"
|
40
|
-
}
|
41
|
-
}
|
42
|
-
},
|
43
|
-
"17.1.0": {
|
44
|
-
"version": "17.1.0-beta.1",
|
45
|
-
"packages": {
|
46
|
-
"@typescript-eslint/parser": {
|
47
|
-
"version": "^6.9.1"
|
48
|
-
},
|
49
|
-
"@typescript-eslint/eslint-plugin": {
|
50
|
-
"version": "^6.9.1"
|
51
|
-
},
|
52
|
-
"@typescript-eslint/utils": {
|
53
|
-
"version": "^6.9.1"
|
54
|
-
}
|
55
|
-
}
|
56
|
-
},
|
57
|
-
"17.2.0": {
|
58
|
-
"version": "17.2.0-beta.2",
|
59
|
-
"packages": {
|
60
|
-
"eslint": {
|
61
|
-
"version": "~8.48.0"
|
62
|
-
}
|
63
|
-
}
|
64
|
-
},
|
65
|
-
"17.3.0": {
|
66
|
-
"version": "17.3.0-beta.0",
|
67
|
-
"packages": {
|
68
|
-
"@typescript-eslint/parser": {
|
69
|
-
"version": "^6.13.2"
|
70
|
-
},
|
71
|
-
"@typescript-eslint/eslint-plugin": {
|
72
|
-
"version": "^6.13.2"
|
73
|
-
},
|
74
|
-
"@typescript-eslint/utils": {
|
75
|
-
"version": "^6.13.2"
|
76
|
-
}
|
77
|
-
}
|
78
|
-
},
|
79
|
-
"18.2.0": {
|
80
|
-
"version": "18.2.0-beta.0",
|
81
|
-
"packages": {
|
82
|
-
"@typescript-eslint/parser": {
|
83
|
-
"version": "^7.3.0"
|
84
|
-
},
|
85
|
-
"@typescript-eslint/eslint-plugin": {
|
86
|
-
"version": "^7.3.0"
|
87
|
-
},
|
88
|
-
"@typescript-eslint/utils": {
|
89
|
-
"version": "^7.3.0"
|
90
|
-
},
|
91
|
-
"eslint": {
|
92
|
-
"version": "~8.57.0"
|
93
|
-
}
|
94
|
-
}
|
95
|
-
},
|
96
15
|
"19.5.0": {
|
97
16
|
"version": "19.5.0-beta.1",
|
98
17
|
"packages": {
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@nx/eslint",
|
3
|
-
"version": "21.0.0-beta.
|
3
|
+
"version": "21.0.0-beta.9",
|
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,8 +35,8 @@
|
|
35
35
|
"eslint": "^8.0.0 || ^9.0.0"
|
36
36
|
},
|
37
37
|
"dependencies": {
|
38
|
-
"@nx/devkit": "21.0.0-beta.
|
39
|
-
"@nx/js": "21.0.0-beta.
|
38
|
+
"@nx/devkit": "21.0.0-beta.9",
|
39
|
+
"@nx/js": "21.0.0-beta.9",
|
40
40
|
"semver": "^7.5.3",
|
41
41
|
"tslib": "^2.3.0",
|
42
42
|
"typescript": "~5.7.2"
|
@@ -1,47 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.default = replacePackage;
|
4
|
-
const devkit_1 = require("@nx/devkit");
|
5
|
-
const replace_package_1 = require("@nx/devkit/src/utils/replace-package");
|
6
|
-
async function replacePackage(tree) {
|
7
|
-
await (0, replace_package_1.replaceNrwlPackageWithNxPackage)(tree, '@nx/linter', '@nx/eslint');
|
8
|
-
// executor name change from :eslint to :lint
|
9
|
-
updateNxJsonExecutor(tree);
|
10
|
-
updateProjectExecutor(tree);
|
11
|
-
await (0, devkit_1.formatFiles)(tree);
|
12
|
-
}
|
13
|
-
function updateNxJsonExecutor(tree) {
|
14
|
-
if (!tree.exists('nx.json')) {
|
15
|
-
return;
|
16
|
-
}
|
17
|
-
const nxJson = (0, devkit_1.readNxJson)(tree);
|
18
|
-
let needsUpdate = false;
|
19
|
-
for (const [targetName, targetConfig] of Object.entries(nxJson.targetDefaults ?? {})) {
|
20
|
-
// this will be in a broken state after the package is globally renamed
|
21
|
-
if (targetConfig.executor !== '@nx/eslint:eslint') {
|
22
|
-
continue;
|
23
|
-
}
|
24
|
-
needsUpdate = true;
|
25
|
-
nxJson.targetDefaults[targetName].executor = '@nx/eslint:lint';
|
26
|
-
}
|
27
|
-
if (needsUpdate) {
|
28
|
-
(0, devkit_1.updateNxJson)(tree, nxJson);
|
29
|
-
}
|
30
|
-
}
|
31
|
-
function updateProjectExecutor(tree) {
|
32
|
-
const projects = (0, devkit_1.getProjects)(tree);
|
33
|
-
for (const [projectName, projectConfiguration] of projects) {
|
34
|
-
let needsUpdate = false;
|
35
|
-
for (const [targetName, targetConfig] of Object.entries(projectConfiguration.targets ?? {})) {
|
36
|
-
// this will be in a broken state after the package is globally renamed
|
37
|
-
if (targetConfig.executor !== '@nx/eslint:eslint') {
|
38
|
-
continue;
|
39
|
-
}
|
40
|
-
needsUpdate = true;
|
41
|
-
projectConfiguration.targets[targetName].executor = '@nx/eslint:lint';
|
42
|
-
}
|
43
|
-
if (needsUpdate) {
|
44
|
-
(0, devkit_1.updateProjectConfiguration)(tree, projectName, projectConfiguration);
|
45
|
-
}
|
46
|
-
}
|
47
|
-
}
|
@@ -1,74 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.default = update;
|
4
|
-
const devkit_1 = require("@nx/devkit");
|
5
|
-
const versions_1 = require("../../utils/versions");
|
6
|
-
const path_1 = require("path");
|
7
|
-
const typescript_1 = require("typescript");
|
8
|
-
function updateJestConfig(tree) {
|
9
|
-
const jestConfigPath = 'tools/eslint-rules/jest.config.ts';
|
10
|
-
if (tree.exists(jestConfigPath)) {
|
11
|
-
const { removePropertyFromJestConfig } = (0, devkit_1.ensurePackage)('@nx/jest', versions_1.nxVersion);
|
12
|
-
removePropertyFromJestConfig(tree, jestConfigPath, [
|
13
|
-
'moduleNameMapper',
|
14
|
-
'@eslint/eslintrc',
|
15
|
-
]);
|
16
|
-
}
|
17
|
-
}
|
18
|
-
function updateTsConfigs(tree) {
|
19
|
-
const tsConfigPath = 'tools/eslint-rules/tsconfig.json';
|
20
|
-
if (tree.exists(tsConfigPath)) {
|
21
|
-
(0, devkit_1.updateJson)(tree, tsConfigPath, (tsConfig) => {
|
22
|
-
tsConfig.compilerOptions ??= {};
|
23
|
-
tsConfig.compilerOptions.moduleResolution = 'node16';
|
24
|
-
tsConfig.compilerOptions.module = 'node16';
|
25
|
-
return tsConfig;
|
26
|
-
});
|
27
|
-
}
|
28
|
-
const tsConfigSpec = 'tools/eslint-rules/tsconfig.spec.json';
|
29
|
-
if (tree.exists(tsConfigSpec)) {
|
30
|
-
(0, devkit_1.updateJson)(tree, tsConfigSpec, (tsConfigSpec) => {
|
31
|
-
delete tsConfigSpec.compilerOptions?.module;
|
32
|
-
delete tsConfigSpec.compilerOptions?.moduleResolution;
|
33
|
-
return tsConfigSpec;
|
34
|
-
});
|
35
|
-
}
|
36
|
-
}
|
37
|
-
function updateRecommended(tree) {
|
38
|
-
(0, devkit_1.visitNotIgnoredFiles)(tree, 'tools/eslint-rules', (path) => {
|
39
|
-
if ((0, path_1.extname)(path) !== '.ts') {
|
40
|
-
return;
|
41
|
-
}
|
42
|
-
const contents = tree.read(path, 'utf-8');
|
43
|
-
const sourceFile = (0, typescript_1.createSourceFile)(path, contents, typescript_1.ScriptTarget.ESNext, true);
|
44
|
-
const changes = [];
|
45
|
-
const visit = (node) => {
|
46
|
-
if ((0, typescript_1.isPropertyAssignment)(node) &&
|
47
|
-
(0, typescript_1.isIdentifier)(node.name) &&
|
48
|
-
node.name.text === 'recommended' &&
|
49
|
-
(0, typescript_1.isStringLiteral)(node.initializer)) {
|
50
|
-
changes.push({
|
51
|
-
type: devkit_1.ChangeType.Delete,
|
52
|
-
start: node.initializer.getStart(sourceFile),
|
53
|
-
length: node.initializer.getWidth(sourceFile),
|
54
|
-
});
|
55
|
-
changes.push({
|
56
|
-
type: devkit_1.ChangeType.Insert,
|
57
|
-
index: node.initializer.getStart(sourceFile),
|
58
|
-
text: "'recommended'",
|
59
|
-
});
|
60
|
-
}
|
61
|
-
else {
|
62
|
-
(0, typescript_1.forEachChild)(node, visit);
|
63
|
-
}
|
64
|
-
};
|
65
|
-
(0, typescript_1.forEachChild)(sourceFile, visit);
|
66
|
-
tree.write(path, (0, devkit_1.applyChangesToString)(contents, changes));
|
67
|
-
});
|
68
|
-
}
|
69
|
-
async function update(tree) {
|
70
|
-
updateJestConfig(tree);
|
71
|
-
updateTsConfigs(tree);
|
72
|
-
updateRecommended(tree);
|
73
|
-
await (0, devkit_1.formatFiles)(tree);
|
74
|
-
}
|
@@ -1,46 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.default = update;
|
4
|
-
const devkit_1 = require("@nx/devkit");
|
5
|
-
async function update(tree) {
|
6
|
-
const projects = (0, devkit_1.getProjects)(tree);
|
7
|
-
for (const [projectName, projectConfiguration] of projects) {
|
8
|
-
let needsUpdate = false;
|
9
|
-
for (const [targetName, targetConfig] of Object.entries(projectConfiguration.targets ?? {})) {
|
10
|
-
if (targetConfig.executor !== '@nx/eslint:lint') {
|
11
|
-
continue;
|
12
|
-
}
|
13
|
-
needsUpdate = true;
|
14
|
-
if (projectConfiguration.targets[targetName].options?.lintFilePatterns) {
|
15
|
-
const rootPattern = getLintRoot(projectConfiguration);
|
16
|
-
const nonRootPatterns = projectConfiguration.targets[targetName].options.lintFilePatterns.filter((p) => !p.startsWith(rootPattern) && !p.startsWith('{projectRoot}'));
|
17
|
-
if (nonRootPatterns.length === 0 &&
|
18
|
-
rootPattern === projectConfiguration.root) {
|
19
|
-
// delete the lintFilePatterns option if it's the only option and matches the root of the project
|
20
|
-
delete projectConfiguration.targets[targetName].options
|
21
|
-
.lintFilePatterns;
|
22
|
-
if (Object.keys(projectConfiguration.targets[targetName].options)
|
23
|
-
.length === 0) {
|
24
|
-
delete projectConfiguration.targets[targetName].options;
|
25
|
-
}
|
26
|
-
}
|
27
|
-
else {
|
28
|
-
projectConfiguration.targets[targetName].options.lintFilePatterns = [
|
29
|
-
rootPattern,
|
30
|
-
...nonRootPatterns,
|
31
|
-
];
|
32
|
-
}
|
33
|
-
}
|
34
|
-
}
|
35
|
-
if (needsUpdate) {
|
36
|
-
(0, devkit_1.updateProjectConfiguration)(tree, projectName, projectConfiguration);
|
37
|
-
}
|
38
|
-
}
|
39
|
-
await (0, devkit_1.formatFiles)(tree);
|
40
|
-
}
|
41
|
-
function getLintRoot({ root, sourceRoot }) {
|
42
|
-
if (root === '' || root === '.') {
|
43
|
-
return sourceRoot || './src';
|
44
|
-
}
|
45
|
-
return root;
|
46
|
-
}
|
@@ -1,107 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.default = update;
|
4
|
-
const devkit_1 = require("@nx/devkit");
|
5
|
-
const executor_options_utils_1 = require("@nx/devkit/src/generators/executor-options-utils");
|
6
|
-
const eslint_file_1 = require("../../generators/utils/eslint-file");
|
7
|
-
const project_configuration_utils_1 = require("nx/src/project-graph/utils/project-configuration-utils");
|
8
|
-
async function update(tree) {
|
9
|
-
const nxJson = (0, devkit_1.readNxJson)(tree);
|
10
|
-
// Don't override anything if there are already target defaults for eslint
|
11
|
-
if (nxJson.targetDefaults?.['@nx/eslint:lint']) {
|
12
|
-
return;
|
13
|
-
}
|
14
|
-
nxJson.targetDefaults ??= {};
|
15
|
-
const graph = await (0, devkit_1.createProjectGraphAsync)();
|
16
|
-
const lintTargets = new Set();
|
17
|
-
(0, executor_options_utils_1.forEachExecutorOptionsInGraph)(graph, '@nx/eslint:lint', (value, proj, targetName) => {
|
18
|
-
lintTargets.add(targetName);
|
19
|
-
});
|
20
|
-
// Workspace does not use eslint?
|
21
|
-
if (lintTargets.size === 0) {
|
22
|
-
return;
|
23
|
-
}
|
24
|
-
const lintDefaults = (nxJson.targetDefaults['@nx/eslint:lint'] = {});
|
25
|
-
// All eslint targets have the same name
|
26
|
-
if (lintTargets.size === 1) {
|
27
|
-
const targetName = Array.from(lintTargets)[0];
|
28
|
-
if (nxJson.targetDefaults[targetName]) {
|
29
|
-
Object.assign(lintDefaults, nxJson.targetDefaults[targetName]);
|
30
|
-
}
|
31
|
-
}
|
32
|
-
lintDefaults.cache ??= true;
|
33
|
-
if (!lintDefaults.inputs) {
|
34
|
-
const eslintConfig = (0, eslint_file_1.findEslintFile)(tree);
|
35
|
-
lintDefaults.inputs = [
|
36
|
-
'default',
|
37
|
-
...(eslintConfig ? [`{workspaceRoot}/${eslintConfig}`] : []),
|
38
|
-
'{workspaceRoot}/tools/eslint-rules/**/*',
|
39
|
-
];
|
40
|
-
}
|
41
|
-
// Cleanup old target defaults
|
42
|
-
const projects = graph.nodes;
|
43
|
-
const projectMap = (0, devkit_1.getProjects)(tree);
|
44
|
-
for (const [targetDefaultKey, targetDefault] of Object.entries(nxJson.targetDefaults)) {
|
45
|
-
if (!isTargetDefaultUsed(targetDefault, nxJson.targetDefaults, projects, projectMap)) {
|
46
|
-
delete nxJson.targetDefaults[targetDefaultKey];
|
47
|
-
}
|
48
|
-
}
|
49
|
-
let addOutputs = false;
|
50
|
-
(0, executor_options_utils_1.forEachExecutorOptions)(tree, '@nx/eslint:lint', (options, proj, targetName, configuration) => {
|
51
|
-
const projConfig = projectMap.get(proj);
|
52
|
-
// modify lint file patterns
|
53
|
-
if (options.lintFilePatterns) {
|
54
|
-
const projectRootRegex = new RegExp(`^${projConfig.root}/`);
|
55
|
-
projConfig.targets[targetName].options.lintFilePatterns =
|
56
|
-
options.lintFilePatterns
|
57
|
-
.filter((filePattern) => filePattern !== '{projectRoot}' &&
|
58
|
-
filePattern !== projConfig.root)
|
59
|
-
.map((filePattern) => filePattern.replace(projectRootRegex, '{projectRoot}/'));
|
60
|
-
// remove lintFilePatterns if empty
|
61
|
-
if (projConfig.targets[targetName].options.lintFilePatterns.length === 0) {
|
62
|
-
delete projConfig.targets[targetName].options.lintFilePatterns;
|
63
|
-
}
|
64
|
-
}
|
65
|
-
// remove inputs if they are not bringing any new inputs
|
66
|
-
if (projConfig.targets[targetName].inputs &&
|
67
|
-
projConfig.targets[targetName].inputs.every((i) => lintDefaults.inputs.includes(i))) {
|
68
|
-
delete projConfig.targets[targetName].inputs;
|
69
|
-
}
|
70
|
-
// remove obsolete eslint config definition, unless it's a custom one
|
71
|
-
const projectEslintConfig = (0, eslint_file_1.findEslintFile)(tree, projConfig.root);
|
72
|
-
if (options.eslintConfig === `${projConfig.root}/${projectEslintConfig}` ||
|
73
|
-
options.eslintConfig === `{projectRoot}/${projectEslintConfig}`) {
|
74
|
-
delete projConfig.targets[targetName].options.eslintConfig;
|
75
|
-
}
|
76
|
-
// remove options if empty
|
77
|
-
if (Object.keys(projConfig.targets[targetName]?.options ?? {}).length === 0) {
|
78
|
-
delete projConfig.targets[targetName].options;
|
79
|
-
}
|
80
|
-
// track output
|
81
|
-
if (options.outputFile) {
|
82
|
-
addOutputs = true;
|
83
|
-
}
|
84
|
-
if (projConfig.targets[targetName].outputs?.length === 1 &&
|
85
|
-
projConfig.targets[targetName].outputs[0] === '{options.outputFile}') {
|
86
|
-
delete projConfig.targets[targetName].outputs;
|
87
|
-
}
|
88
|
-
(0, devkit_1.updateProjectConfiguration)(tree, proj, projConfig);
|
89
|
-
});
|
90
|
-
if (addOutputs) {
|
91
|
-
lintDefaults.outputs = ['{options.outputFile}'];
|
92
|
-
}
|
93
|
-
(0, devkit_1.updateNxJson)(tree, nxJson);
|
94
|
-
await (0, devkit_1.formatFiles)(tree);
|
95
|
-
}
|
96
|
-
function isTargetDefaultUsed(targetDefault, targetDefaults, projects, projectMap) {
|
97
|
-
for (const p of Object.values(projects)) {
|
98
|
-
for (const targetName in p.data?.targets ?? {}) {
|
99
|
-
if ((0, project_configuration_utils_1.readTargetDefaultsForTarget)(targetName, targetDefaults,
|
100
|
-
// It might seem like we should use the graph here too but we don't want to pass an executor which was processed in the graph
|
101
|
-
projectMap.get(p.name)?.targets?.[targetName]?.executor) === targetDefault) {
|
102
|
-
return true;
|
103
|
-
}
|
104
|
-
}
|
105
|
-
}
|
106
|
-
return false;
|
107
|
-
}
|