@nx/eslint 20.2.0 → 20.2.2
Sign up to get free protection for your applications and to get access to all the features.
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@nx/eslint",
|
3
|
-
"version": "20.2.
|
3
|
+
"version": "20.2.2",
|
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": "20.2.
|
39
|
-
"@nx/js": "20.2.
|
38
|
+
"@nx/devkit": "20.2.2",
|
39
|
+
"@nx/js": "20.2.2",
|
40
40
|
"semver": "^7.5.3",
|
41
41
|
"tslib": "^2.3.0",
|
42
42
|
"typescript": "~5.6.2"
|
@@ -7,8 +7,8 @@ export declare function addOverrideToLintConfig(tree: Tree, root: string, overri
|
|
7
7
|
insertAtTheEnd?: boolean;
|
8
8
|
checkBaseConfig?: boolean;
|
9
9
|
}): void;
|
10
|
-
export declare function updateOverrideInLintConfig(tree: Tree,
|
11
|
-
export declare function lintConfigHasOverride(tree: Tree,
|
10
|
+
export declare function updateOverrideInLintConfig(tree: Tree, rootOrFile: string, lookup: (override: Linter.ConfigOverride<Linter.RulesRecord>) => boolean, update: (override: Linter.ConfigOverride<Linter.RulesRecord>) => Linter.ConfigOverride<Linter.RulesRecord>): void;
|
11
|
+
export declare function lintConfigHasOverride(tree: Tree, rootOrFile: string, lookup: (override: Linter.ConfigOverride<Linter.RulesRecord>) => boolean, checkBaseConfig?: boolean): boolean;
|
12
12
|
export declare function replaceOverridesInLintConfig(tree: Tree, root: string, overrides: Linter.ConfigOverride<Linter.RulesRecord>[]): void;
|
13
13
|
export declare function addExtendsToLintConfig(tree: Tree, root: string, plugin: string | {
|
14
14
|
name: string;
|
@@ -20,6 +20,7 @@ const version_utils_1 = require("../../utils/version-utils");
|
|
20
20
|
const versions_1 = require("../../utils/versions");
|
21
21
|
const ast_utils_1 = require("./flat-config/ast-utils");
|
22
22
|
const path_utils_1 = require("./flat-config/path-utils");
|
23
|
+
const posix_1 = require("node:path/posix");
|
23
24
|
function findEslintFile(tree, projectRoot) {
|
24
25
|
if (projectRoot === undefined && tree.exists(config_file_1.baseEsLintConfigFile)) {
|
25
26
|
return config_file_1.baseEsLintConfigFile;
|
@@ -139,15 +140,21 @@ function addOverrideToLintConfig(tree, root, override, options = {
|
|
139
140
|
});
|
140
141
|
}
|
141
142
|
}
|
142
|
-
function updateOverrideInLintConfig(tree,
|
143
|
+
function updateOverrideInLintConfig(tree, rootOrFile, lookup, update) {
|
144
|
+
let fileName;
|
145
|
+
let root = rootOrFile;
|
146
|
+
if (tree.exists(rootOrFile) && tree.isFile(rootOrFile)) {
|
147
|
+
fileName = rootOrFile;
|
148
|
+
root = (0, posix_1.dirname)(rootOrFile);
|
149
|
+
}
|
143
150
|
if ((0, flat_config_1.useFlatConfig)(tree)) {
|
144
|
-
|
151
|
+
fileName ??= (0, devkit_1.joinPathFragments)(root, (0, flat_config_1.getRootESLintFlatConfigFilename)(tree));
|
145
152
|
let content = tree.read(fileName, 'utf8');
|
146
153
|
content = (0, ast_utils_1.replaceOverride)(content, root, lookup, update);
|
147
154
|
tree.write(fileName, content);
|
148
155
|
}
|
149
156
|
else {
|
150
|
-
|
157
|
+
fileName ??= (0, devkit_1.joinPathFragments)(root, '.eslintrc.json');
|
151
158
|
if (!tree.exists(fileName)) {
|
152
159
|
return;
|
153
160
|
}
|
@@ -170,18 +177,26 @@ function updateOverrideInLintConfig(tree, root, lookup, update) {
|
|
170
177
|
});
|
171
178
|
}
|
172
179
|
}
|
173
|
-
function lintConfigHasOverride(tree,
|
174
|
-
|
180
|
+
function lintConfigHasOverride(tree, rootOrFile, lookup, checkBaseConfig = false) {
|
181
|
+
let fileName;
|
182
|
+
let root = rootOrFile;
|
183
|
+
if (tree.exists(rootOrFile) && tree.isFile(rootOrFile)) {
|
184
|
+
fileName = rootOrFile;
|
185
|
+
root = (0, posix_1.dirname)(rootOrFile);
|
186
|
+
}
|
187
|
+
if (!fileName && !isEslintConfigSupported(tree, root)) {
|
175
188
|
return false;
|
176
189
|
}
|
177
|
-
const isBase =
|
190
|
+
const isBase = !fileName &&
|
191
|
+
checkBaseConfig &&
|
192
|
+
findEslintFile(tree, root).includes('.base');
|
178
193
|
if ((0, flat_config_1.useFlatConfig)(tree)) {
|
179
|
-
|
194
|
+
fileName ??= (0, devkit_1.joinPathFragments)(root, isBase ? config_file_1.baseEsLintFlatConfigFile : (0, flat_config_1.getRootESLintFlatConfigFilename)(tree));
|
180
195
|
const content = tree.read(fileName, 'utf8');
|
181
196
|
return (0, ast_utils_1.hasOverride)(content, lookup);
|
182
197
|
}
|
183
198
|
else {
|
184
|
-
|
199
|
+
fileName ??= (0, devkit_1.joinPathFragments)(root, isBase ? config_file_1.baseEsLintConfigFile : '.eslintrc.json');
|
185
200
|
return (0, devkit_1.readJson)(tree, fileName).overrides?.some(lookup) || false;
|
186
201
|
}
|
187
202
|
}
|