@nx/eslint 19.0.5 → 19.0.6
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.0.
|
3
|
+
"version": "19.0.6",
|
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": {
|
@@ -15,7 +15,7 @@
|
|
15
15
|
"ESLint",
|
16
16
|
"CLI"
|
17
17
|
],
|
18
|
-
"main": "./index
|
18
|
+
"main": "./index",
|
19
19
|
"typings": "./index.d.ts",
|
20
20
|
"author": "Victor Savkin",
|
21
21
|
"license": "MIT",
|
@@ -33,12 +33,12 @@
|
|
33
33
|
"js-yaml": "npm:@zkochan/js-yaml@0.0.7"
|
34
34
|
},
|
35
35
|
"dependencies": {
|
36
|
-
"@nx/devkit": "19.0.
|
37
|
-
"@nx/js": "19.0.
|
38
|
-
"eslint": "^8.0.0",
|
36
|
+
"@nx/devkit": "19.0.6",
|
37
|
+
"@nx/js": "19.0.6",
|
38
|
+
"eslint": "^8.0.0 || ^9.0.0",
|
39
39
|
"tslib": "^2.3.0",
|
40
40
|
"typescript": "~5.4.2",
|
41
|
-
"@nx/linter": "19.0.
|
41
|
+
"@nx/linter": "19.0.6"
|
42
42
|
},
|
43
43
|
"peerDependenciesMeta": {
|
44
44
|
"js-yaml": {
|
@@ -1,26 +1,14 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.resolveAndInstantiateESLint = void 0;
|
4
|
-
|
5
|
-
try {
|
6
|
-
if (!useFlatConfig) {
|
7
|
-
return (await Promise.resolve().then(() => require('eslint'))).ESLint;
|
8
|
-
}
|
9
|
-
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
10
|
-
const { FlatESLint } = require('eslint/use-at-your-own-risk');
|
11
|
-
return FlatESLint;
|
12
|
-
}
|
13
|
-
catch {
|
14
|
-
throw new Error('Unable to find ESLint. Ensure ESLint is installed.');
|
15
|
-
}
|
16
|
-
}
|
4
|
+
const resolve_eslint_class_1 = require("../../../utils/resolve-eslint-class");
|
17
5
|
async function resolveAndInstantiateESLint(eslintConfigPath, options, useFlatConfig = false) {
|
18
6
|
if (useFlatConfig &&
|
19
7
|
eslintConfigPath &&
|
20
8
|
!eslintConfigPath?.endsWith('eslint.config.js')) {
|
21
9
|
throw new Error('When using the new Flat Config with ESLint, all configs must be named eslint.config.js and .eslintrc files may not be used. See https://eslint.org/docs/latest/use/configure/configuration-files-new');
|
22
10
|
}
|
23
|
-
const ESLint = await resolveESLintClass(useFlatConfig);
|
11
|
+
const ESLint = await (0, resolve_eslint_class_1.resolveESLintClass)(useFlatConfig);
|
24
12
|
const eslintOptions = {
|
25
13
|
overrideConfigFile: eslintConfigPath,
|
26
14
|
fix: !!options.fix,
|
package/src/plugins/plugin.js
CHANGED
@@ -6,6 +6,7 @@ const node_path_1 = require("node:path");
|
|
6
6
|
const globs_1 = require("nx/src/utils/globs");
|
7
7
|
const workspace_context_1 = require("nx/src/utils/workspace-context");
|
8
8
|
const config_file_1 = require("../utils/config-file");
|
9
|
+
const resolve_eslint_class_1 = require("../utils/resolve-eslint-class");
|
9
10
|
const DEFAULT_EXTENSIONS = ['ts', 'tsx', 'js', 'jsx', 'html', 'vue'];
|
10
11
|
exports.createNodes = [
|
11
12
|
(0, globs_1.combineGlobPatterns)([
|
@@ -39,7 +40,7 @@ exports.createNodes = [
|
|
39
40
|
// dedupe and sort project roots by depth for more efficient traversal
|
40
41
|
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));
|
41
42
|
const excludePatterns = dedupedProjectRoots.map((root) => `${root}/**/*`);
|
42
|
-
const ESLint = resolveESLintClass((0, config_file_1.isFlatConfig)(configFilePath));
|
43
|
+
const ESLint = await (0, resolve_eslint_class_1.resolveESLintClass)((0, config_file_1.isFlatConfig)(configFilePath));
|
43
44
|
const childProjectRoots = new Set();
|
44
45
|
await Promise.all(dedupedProjectRoots.map(async (childProjectRoot, index) => {
|
45
46
|
// anything after is either a nested project or a sibling project, can be excluded
|
@@ -112,11 +113,11 @@ function buildEslintTargets(eslintConfigs, projectRoot, workspaceRoot, options,
|
|
112
113
|
],
|
113
114
|
outputs: ['{options.outputFile}'],
|
114
115
|
};
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
}
|
116
|
+
// Always set the environment variable to ensure that the ESLint CLI can run on eslint v8 and v9
|
117
|
+
const useFlatConfig = eslintConfigs.some((config) => (0, config_file_1.isFlatConfig)(config));
|
118
|
+
targetConfig.options.env = {
|
119
|
+
ESLINT_USE_FLAT_CONFIG: useFlatConfig ? 'true' : 'false',
|
120
|
+
};
|
120
121
|
targets[options.targetName] = targetConfig;
|
121
122
|
return targets;
|
122
123
|
}
|
@@ -132,17 +133,6 @@ function normalizeOptions(options) {
|
|
132
133
|
}
|
133
134
|
return options;
|
134
135
|
}
|
135
|
-
function resolveESLintClass(useFlatConfig = false) {
|
136
|
-
try {
|
137
|
-
if (!useFlatConfig) {
|
138
|
-
return require('eslint').ESLint;
|
139
|
-
}
|
140
|
-
return require('eslint/use-at-your-own-risk').FlatESLint;
|
141
|
-
}
|
142
|
-
catch {
|
143
|
-
throw new Error('Unable to find ESLint. Ensure ESLint is installed.');
|
144
|
-
}
|
145
|
-
}
|
146
136
|
/**
|
147
137
|
* Determines if `child` is a subdirectory of `parent`. This is a simplified
|
148
138
|
* version that takes into account that paths are always relative to the
|
@@ -0,0 +1,23 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.resolveESLintClass = void 0;
|
4
|
+
async function resolveESLintClass(useFlatConfig = false) {
|
5
|
+
try {
|
6
|
+
// In eslint 8.57.0 (the final v8 version), a dedicated API was added for resolving the correct ESLint class.
|
7
|
+
const eslint = await Promise.resolve().then(() => require('eslint'));
|
8
|
+
if (typeof eslint.loadESLint === 'function') {
|
9
|
+
return await eslint.loadESLint({ useFlatConfig });
|
10
|
+
}
|
11
|
+
// If that API is not available (an older version of v8), we need to use the old way of resolving the ESLint class.
|
12
|
+
if (!useFlatConfig) {
|
13
|
+
return eslint.ESLint;
|
14
|
+
}
|
15
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
16
|
+
const { FlatESLint } = require('eslint/use-at-your-own-risk');
|
17
|
+
return FlatESLint;
|
18
|
+
}
|
19
|
+
catch {
|
20
|
+
throw new Error('Unable to find ESLint. Ensure ESLint is installed.');
|
21
|
+
}
|
22
|
+
}
|
23
|
+
exports.resolveESLintClass = resolveESLintClass;
|