@nx/eslint 19.2.0-beta.4 → 19.2.0-beta.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@nx/eslint",
|
3
|
-
"version": "19.2.0-beta.
|
3
|
+
"version": "19.2.0-beta.5",
|
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.2.0-beta.
|
39
|
-
"@nx/js": "19.2.0-beta.
|
38
|
+
"@nx/devkit": "19.2.0-beta.5",
|
39
|
+
"@nx/js": "19.2.0-beta.5",
|
40
40
|
"semver": "^7.5.3",
|
41
41
|
"tslib": "^2.3.0",
|
42
42
|
"typescript": "~5.4.2",
|
43
|
-
"@nx/linter": "19.2.0-beta.
|
43
|
+
"@nx/linter": "19.2.0-beta.5"
|
44
44
|
},
|
45
45
|
"peerDependenciesMeta": {
|
46
46
|
"@zkochan/js-yaml": {
|
@@ -8,8 +8,8 @@ const target_options_map_1 = require("./lib/target-options-map");
|
|
8
8
|
const utils_1 = require("nx/src/tasks-runner/utils");
|
9
9
|
async function convertToInferred(tree, options) {
|
10
10
|
const projectGraph = await (0, devkit_1.createProjectGraphAsync)();
|
11
|
-
const migratedProjectsModern = await (0, executor_to_plugin_migrator_1.
|
12
|
-
const migratedProjectsLegacy = await (0, executor_to_plugin_migrator_1.
|
11
|
+
const migratedProjectsModern = await (0, executor_to_plugin_migrator_1.migrateExecutorToPluginV1)(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.migrateExecutorToPluginV1)(tree, projectGraph, '@nrwl/linter:eslint', '@nx/eslint/plugin', (targetName) => ({ targetName }), postTargetTransformer, plugin_1.createNodes, options.project);
|
13
13
|
const migratedProjects = migratedProjectsModern.size + migratedProjectsLegacy.size;
|
14
14
|
if (migratedProjects === 0) {
|
15
15
|
throw new Error('Could not find any targets to migrate.');
|
@@ -21,14 +21,14 @@ async function convertToInferred(tree, options) {
|
|
21
21
|
exports.convertToInferred = convertToInferred;
|
22
22
|
function postTargetTransformer(target, tree, projectDetails) {
|
23
23
|
if (target.inputs) {
|
24
|
-
|
24
|
+
const inputs = target.inputs.filter((input) => typeof input === 'string' &&
|
25
25
|
![
|
26
26
|
'default',
|
27
27
|
'{workspaceRoot}/.eslintrc.json',
|
28
28
|
'{workspaceRoot}/.eslintignore',
|
29
29
|
'{workspaceRoot}/eslint.config.js',
|
30
30
|
].includes(input));
|
31
|
-
if (
|
31
|
+
if (inputs.length === 0) {
|
32
32
|
delete target.inputs;
|
33
33
|
}
|
34
34
|
}
|
@@ -16,6 +16,7 @@ interface LintProjectOptions {
|
|
16
16
|
* @internal
|
17
17
|
*/
|
18
18
|
addExplicitTargets?: boolean;
|
19
|
+
addPackageJsonDependencyChecks?: boolean;
|
19
20
|
}
|
20
21
|
export declare function lintProjectGenerator(tree: Tree, options: LintProjectOptions): Promise<GeneratorCallback>;
|
21
22
|
export declare function lintProjectGeneratorInternal(tree: Tree, options: LintProjectOptions): Promise<GeneratorCallback>;
|
@@ -89,7 +89,7 @@ async function lintProjectGeneratorInternal(tree, options) {
|
|
89
89
|
// additionally, the companion e2e app would have `rootProject: true`
|
90
90
|
// so we need to check for the root path as well
|
91
91
|
if (!options.rootProject || projectConfig.root !== '.') {
|
92
|
-
createEsLintConfiguration(tree, projectConfig, options.setParserOptionsProject, options.rootProject);
|
92
|
+
createEsLintConfiguration(tree, options, projectConfig, options.setParserOptionsProject, options.rootProject);
|
93
93
|
}
|
94
94
|
// Buildable libs need source analysis enabled for linting `package.json`.
|
95
95
|
if (isBuildableLibraryProject(projectConfig) &&
|
@@ -108,7 +108,7 @@ async function lintProjectGeneratorInternal(tree, options) {
|
|
108
108
|
return (0, devkit_1.runTasksInSerial)(...tasks);
|
109
109
|
}
|
110
110
|
exports.lintProjectGeneratorInternal = lintProjectGeneratorInternal;
|
111
|
-
function createEsLintConfiguration(tree, projectConfig, setParserOptionsProject, rootProject) {
|
111
|
+
function createEsLintConfiguration(tree, options, projectConfig, setParserOptionsProject, rootProject) {
|
112
112
|
// we are only extending root for non-standalone projects or their complementary e2e apps
|
113
113
|
const extendedRootConfig = rootProject ? undefined : (0, eslint_file_1.findEslintFile)(tree);
|
114
114
|
const pathToRootConfig = extendedRootConfig
|
@@ -151,7 +151,8 @@ function createEsLintConfiguration(tree, projectConfig, setParserOptionsProject,
|
|
151
151
|
rules: {},
|
152
152
|
},
|
153
153
|
];
|
154
|
-
if (
|
154
|
+
if (options.addPackageJsonDependencyChecks ||
|
155
|
+
isBuildableLibraryProject(projectConfig)) {
|
155
156
|
overrides.push({
|
156
157
|
files: ['*.json'],
|
157
158
|
parser: 'jsonc-eslint-parser',
|
package/src/plugins/plugin.js
CHANGED
@@ -76,11 +76,17 @@ function getProjectsUsingESLintConfig(configFilePath, childProjectRoots, eslintV
|
|
76
76
|
].find((f) => (0, node_fs_1.existsSync)((0, node_path_1.join)(context.workspaceRoot, f)));
|
77
77
|
// Add a lint target for each child project without an eslint config, with the root level config as an input
|
78
78
|
for (const projectRoot of childProjectRoots) {
|
79
|
-
|
80
|
-
|
81
|
-
(0, node_fs_1.existsSync)((0, node_path_1.join)(context.workspaceRoot, projectRoot, '
|
82
|
-
(0, node_fs_1.existsSync)((0, node_path_1.join)(context.workspaceRoot, projectRoot, '
|
83
|
-
|
79
|
+
let standaloneSrcPath;
|
80
|
+
if (projectRoot === '.' &&
|
81
|
+
(0, node_fs_1.existsSync)((0, node_path_1.join)(context.workspaceRoot, projectRoot, 'package.json'))) {
|
82
|
+
if ((0, node_fs_1.existsSync)((0, node_path_1.join)(context.workspaceRoot, projectRoot, 'src'))) {
|
83
|
+
standaloneSrcPath = 'src';
|
84
|
+
}
|
85
|
+
else if ((0, node_fs_1.existsSync)((0, node_path_1.join)(context.workspaceRoot, projectRoot, 'lib'))) {
|
86
|
+
standaloneSrcPath = 'lib';
|
87
|
+
}
|
88
|
+
}
|
89
|
+
if (projectRoot === '.' && !standaloneSrcPath) {
|
84
90
|
continue;
|
85
91
|
}
|
86
92
|
const eslintConfigs = [configFilePath];
|
@@ -88,16 +94,16 @@ function getProjectsUsingESLintConfig(configFilePath, childProjectRoots, eslintV
|
|
88
94
|
eslintConfigs.unshift(rootEslintConfig);
|
89
95
|
}
|
90
96
|
projects[projectRoot] = {
|
91
|
-
targets: buildEslintTargets(eslintConfigs, eslintVersion, projectRoot, context.workspaceRoot, options,
|
97
|
+
targets: buildEslintTargets(eslintConfigs, eslintVersion, projectRoot, context.workspaceRoot, options, standaloneSrcPath),
|
92
98
|
};
|
93
99
|
}
|
94
100
|
return projects;
|
95
101
|
}
|
96
|
-
function buildEslintTargets(eslintConfigs, eslintVersion, projectRoot, workspaceRoot, options,
|
102
|
+
function buildEslintTargets(eslintConfigs, eslintVersion, projectRoot, workspaceRoot, options, standaloneSrcPath) {
|
97
103
|
const isRootProject = projectRoot === '.';
|
98
104
|
const targets = {};
|
99
105
|
const targetConfig = {
|
100
|
-
command: `eslint ${isRootProject &&
|
106
|
+
command: `eslint ${isRootProject && standaloneSrcPath ? `./${standaloneSrcPath}` : '.'}`,
|
101
107
|
cache: true,
|
102
108
|
options: {
|
103
109
|
cwd: projectRoot,
|