@nx/eslint 19.0.0-canary.20240503-dbad02a → 19.0.0-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/generators.json +5 -0
- package/package.json +4 -4
- package/src/generators/convert-to-inferred/convert-to-inferred.d.ts +7 -0
- package/src/generators/convert-to-inferred/convert-to-inferred.js +80 -0
- package/src/generators/convert-to-inferred/lib/target-options-map.d.ts +16 -0
- package/src/generators/convert-to-inferred/lib/target-options-map.js +19 -0
- package/src/generators/convert-to-inferred/schema.json +19 -0
package/generators.json
CHANGED
@@ -23,6 +23,11 @@
|
|
23
23
|
"factory": "./src/generators/convert-to-flat-config/generator",
|
24
24
|
"schema": "./src/generators/convert-to-flat-config/schema.json",
|
25
25
|
"description": "Convert an Nx workspace's ESLint configs to use Flat Config."
|
26
|
+
},
|
27
|
+
"convert-to-inferred": {
|
28
|
+
"factory": "./src/generators/convert-to-inferred/convert-to-inferred",
|
29
|
+
"schema": "./src/generators/convert-to-inferred/schema.json",
|
30
|
+
"description": "Convert existing ESLint project(s) using `@nx/eslint:lint` executor to use `@nx/eslint/plugin`."
|
26
31
|
}
|
27
32
|
}
|
28
33
|
}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@nx/eslint",
|
3
|
-
"version": "19.0.0-
|
3
|
+
"version": "19.0.0-rc.0",
|
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": {
|
@@ -33,12 +33,12 @@
|
|
33
33
|
"js-yaml": "4.1.0"
|
34
34
|
},
|
35
35
|
"dependencies": {
|
36
|
-
"@nx/devkit": "19.0.0-
|
37
|
-
"@nx/js": "19.0.0-
|
36
|
+
"@nx/devkit": "19.0.0-rc.0",
|
37
|
+
"@nx/js": "19.0.0-rc.0",
|
38
38
|
"eslint": "^8.0.0",
|
39
39
|
"tslib": "^2.3.0",
|
40
40
|
"typescript": "~5.4.2",
|
41
|
-
"@nx/linter": "19.0.0-
|
41
|
+
"@nx/linter": "19.0.0-rc.0"
|
42
42
|
},
|
43
43
|
"peerDependenciesMeta": {
|
44
44
|
"js-yaml": {
|
@@ -0,0 +1,80 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.convertToInferred = void 0;
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
5
|
+
const plugin_1 = require("../../plugins/plugin");
|
6
|
+
const executor_to_plugin_migrator_1 = require("@nx/devkit/src/generators/plugin-migrations/executor-to-plugin-migrator");
|
7
|
+
const target_options_map_1 = require("./lib/target-options-map");
|
8
|
+
const utils_1 = require("nx/src/tasks-runner/utils");
|
9
|
+
async function convertToInferred(tree, options) {
|
10
|
+
const projectGraph = await (0, devkit_1.createProjectGraphAsync)();
|
11
|
+
const migratedProjectsModern = await (0, executor_to_plugin_migrator_1.migrateExecutorToPlugin)(tree, projectGraph, '@nx/eslint:lint', '@nx/eslint/plugin', (targetName) => ({ targetName }), postTargetTransformer, plugin_1.createNodes, options.project);
|
12
|
+
const migratedProjectsLegacy = await (0, executor_to_plugin_migrator_1.migrateExecutorToPlugin)(tree, projectGraph, '@nrwl/linter:eslint', '@nx/eslint/plugin', (targetName) => ({ targetName }), postTargetTransformer, plugin_1.createNodes, options.project);
|
13
|
+
const migratedProjects = migratedProjectsModern.size + migratedProjectsLegacy.size;
|
14
|
+
if (migratedProjects === 0) {
|
15
|
+
throw new Error('Could not find any targets to migrate.');
|
16
|
+
}
|
17
|
+
if (!options.skipFormat) {
|
18
|
+
await (0, devkit_1.formatFiles)(tree);
|
19
|
+
}
|
20
|
+
}
|
21
|
+
exports.convertToInferred = convertToInferred;
|
22
|
+
function postTargetTransformer(target, tree, projectDetails) {
|
23
|
+
if (target.inputs) {
|
24
|
+
target.inputs = target.inputs.filter((input) => typeof input === 'string' &&
|
25
|
+
![
|
26
|
+
'default',
|
27
|
+
'{workspaceRoot}/.eslintrc.json',
|
28
|
+
'{workspaceRoot}/.eslintignore',
|
29
|
+
'{workspaceRoot}/eslint.config.js',
|
30
|
+
].includes(input));
|
31
|
+
if (target.inputs.length === 0) {
|
32
|
+
delete target.inputs;
|
33
|
+
}
|
34
|
+
}
|
35
|
+
if (target.options) {
|
36
|
+
if ('eslintConfig' in target.options) {
|
37
|
+
delete target.options.eslintConfig;
|
38
|
+
}
|
39
|
+
if ('force' in target.options) {
|
40
|
+
delete target.options.force;
|
41
|
+
}
|
42
|
+
if ('silent' in target.options) {
|
43
|
+
delete target.options.silent;
|
44
|
+
}
|
45
|
+
if ('hasTypeAwareRules' in target.options) {
|
46
|
+
delete target.options.hasTypeAwareRules;
|
47
|
+
}
|
48
|
+
if ('errorOnUnmatchedPattern' in target.options) {
|
49
|
+
if (!target.options.errorOnUnmatchedPattern) {
|
50
|
+
target.options['no-error-on-unmatched-pattern'] = true;
|
51
|
+
}
|
52
|
+
delete target.options.errorOnUnmatchedPattern;
|
53
|
+
}
|
54
|
+
if ('outputFile' in target.options) {
|
55
|
+
target.outputs ??= [];
|
56
|
+
target.outputs.push(target.options.outputFile);
|
57
|
+
}
|
58
|
+
for (const key in target_options_map_1.targetOptionsToCliMap) {
|
59
|
+
if (target.options[key]) {
|
60
|
+
target.options[target_options_map_1.targetOptionsToCliMap[key]] = target.options[key];
|
61
|
+
delete target.options[key];
|
62
|
+
}
|
63
|
+
}
|
64
|
+
if ('lintFilePatterns' in target.options) {
|
65
|
+
const normalizedLintFilePatterns = target.options.lintFilePatterns.map((pattern) => {
|
66
|
+
return (0, utils_1.interpolate)(pattern, {
|
67
|
+
workspaceRoot: '',
|
68
|
+
projectRoot: projectDetails.root,
|
69
|
+
projectName: projectDetails.projectName,
|
70
|
+
});
|
71
|
+
});
|
72
|
+
target.options.args = normalizedLintFilePatterns.map((pattern) => pattern.startsWith(projectDetails.root)
|
73
|
+
? pattern.replace(new RegExp(`^${projectDetails.root}/`), './')
|
74
|
+
: pattern);
|
75
|
+
delete target.options.lintFilePatterns;
|
76
|
+
}
|
77
|
+
}
|
78
|
+
return target;
|
79
|
+
}
|
80
|
+
exports.default = convertToInferred;
|
@@ -0,0 +1,16 @@
|
|
1
|
+
export declare const targetOptionsToCliMap: {
|
2
|
+
fix: string;
|
3
|
+
format: string;
|
4
|
+
cache: string;
|
5
|
+
cacheLocation: string;
|
6
|
+
cacheStrategy: string;
|
7
|
+
noEslintrc: string;
|
8
|
+
outputFile: string;
|
9
|
+
maxWarnings: string;
|
10
|
+
quiet: string;
|
11
|
+
ignorePath: string;
|
12
|
+
rulesdir: string;
|
13
|
+
resolvePluginsRelativeTo: string;
|
14
|
+
reportUnusedDisableDirectives: string;
|
15
|
+
printConfig: string;
|
16
|
+
};
|
@@ -0,0 +1,19 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.targetOptionsToCliMap = void 0;
|
4
|
+
exports.targetOptionsToCliMap = {
|
5
|
+
fix: 'fix',
|
6
|
+
format: 'format',
|
7
|
+
cache: 'cache',
|
8
|
+
cacheLocation: 'cache-location',
|
9
|
+
cacheStrategy: 'cache-strategy',
|
10
|
+
noEslintrc: 'no-eslintrc',
|
11
|
+
outputFile: 'output-file',
|
12
|
+
maxWarnings: 'max-warnings',
|
13
|
+
quiet: 'quiet',
|
14
|
+
ignorePath: 'ignore-path',
|
15
|
+
rulesdir: 'rulesdir',
|
16
|
+
resolvePluginsRelativeTo: 'resolve-plugins-relative-to',
|
17
|
+
reportUnusedDisableDirectives: 'report-unused-disable-directives',
|
18
|
+
printConfig: 'print-config',
|
19
|
+
};
|
@@ -0,0 +1,19 @@
|
|
1
|
+
{
|
2
|
+
"$schema": "https://json-schema.org/schema",
|
3
|
+
"$id": "NxEslintConvertToInferred",
|
4
|
+
"description": "Convert existing Eslint project(s) using `@nx/eslint:lint` executor to use `@nx/eslint/plugin`. Defaults to migrating all projects. Pass '--project' to migrate only one target.",
|
5
|
+
"title": "Convert Eslint project from executor to plugin",
|
6
|
+
"type": "object",
|
7
|
+
"properties": {
|
8
|
+
"project": {
|
9
|
+
"type": "string",
|
10
|
+
"description": "The project to convert from using the `@nx/eslint:lint` executor to use `@nx/eslint/plugin`.",
|
11
|
+
"x-priority": "important"
|
12
|
+
},
|
13
|
+
"skipFormat": {
|
14
|
+
"type": "boolean",
|
15
|
+
"description": "Whether to format files at the end of the migration.",
|
16
|
+
"default": false
|
17
|
+
}
|
18
|
+
}
|
19
|
+
}
|