@nx/eslint 0.0.0-pr-27404-f7ba497 → 0.0.0-pr-27404-00130f5
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": "0.0.0-pr-27404-
|
|
3
|
+
"version": "0.0.0-pr-27404-00130f5",
|
|
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": "0.0.0-pr-27404-
|
|
39
|
-
"@nx/js": "0.0.0-pr-27404-
|
|
38
|
+
"@nx/devkit": "0.0.0-pr-27404-00130f5",
|
|
39
|
+
"@nx/js": "0.0.0-pr-27404-00130f5",
|
|
40
40
|
"semver": "^7.5.3",
|
|
41
41
|
"tslib": "^2.3.0",
|
|
42
42
|
"typescript": "~5.4.2",
|
|
43
|
-
"@nx/linter": "0.0.0-pr-27404-
|
|
43
|
+
"@nx/linter": "0.0.0-pr-27404-00130f5"
|
|
44
44
|
},
|
|
45
45
|
"peerDependenciesMeta": {
|
|
46
46
|
"@zkochan/js-yaml": {
|
|
@@ -91,6 +91,11 @@ function migrateEslintFile(projectEslintPath, tree) {
|
|
|
91
91
|
'plugin:@nrwl/typescript',
|
|
92
92
|
'plugin:@nrwl/javascript',
|
|
93
93
|
]);
|
|
94
|
+
config = (0, ast_utils_1.removePredefinedConfigs)(config, '@nx/eslint-plugin', 'nx', [
|
|
95
|
+
'flat/base',
|
|
96
|
+
'flat/typescript',
|
|
97
|
+
'flat/javascript',
|
|
98
|
+
]);
|
|
94
99
|
tree.write(projectEslintPath, config);
|
|
95
100
|
}
|
|
96
101
|
else {
|
|
@@ -13,6 +13,10 @@ export declare function replaceOverride(content: string, root: string, lookup: (
|
|
|
13
13
|
* Adding require statement to the top of the file
|
|
14
14
|
*/
|
|
15
15
|
export declare function addImportToFlatConfig(content: string, variable: string | string[], imp: string): string;
|
|
16
|
+
/**
|
|
17
|
+
* Remove an import from flat config
|
|
18
|
+
*/
|
|
19
|
+
export declare function removeImportFromFlatConfig(content: string, variable: string, imp: string): string;
|
|
16
20
|
/**
|
|
17
21
|
* Injects new ts.expression to the end of the module.exports array.
|
|
18
22
|
*/
|
|
@@ -22,6 +26,7 @@ export declare function addBlockToFlatConfigExport(content: string, config: ts.E
|
|
|
22
26
|
}): string;
|
|
23
27
|
export declare function removePlugin(content: string, pluginName: string, pluginImport: string): string;
|
|
24
28
|
export declare function removeCompatExtends(content: string, compatExtends: string[]): string;
|
|
29
|
+
export declare function removePredefinedConfigs(content: string, moduleImport: string, moduleVariable: string, configs: string[]): string;
|
|
25
30
|
/**
|
|
26
31
|
* Add plugins block to the top of the export blocks
|
|
27
32
|
*/
|
|
@@ -4,9 +4,11 @@ exports.removeOverridesFromLintConfig = removeOverridesFromLintConfig;
|
|
|
4
4
|
exports.hasOverride = hasOverride;
|
|
5
5
|
exports.replaceOverride = replaceOverride;
|
|
6
6
|
exports.addImportToFlatConfig = addImportToFlatConfig;
|
|
7
|
+
exports.removeImportFromFlatConfig = removeImportFromFlatConfig;
|
|
7
8
|
exports.addBlockToFlatConfigExport = addBlockToFlatConfigExport;
|
|
8
9
|
exports.removePlugin = removePlugin;
|
|
9
10
|
exports.removeCompatExtends = removeCompatExtends;
|
|
11
|
+
exports.removePredefinedConfigs = removePredefinedConfigs;
|
|
10
12
|
exports.addPluginsToExportsBlock = addPluginsToExportsBlock;
|
|
11
13
|
exports.addFlatCompatToFlatConfig = addFlatCompatToFlatConfig;
|
|
12
14
|
exports.createNodeList = createNodeList;
|
|
@@ -233,6 +235,32 @@ function addImportToFlatConfig(content, variable, imp) {
|
|
|
233
235
|
},
|
|
234
236
|
]);
|
|
235
237
|
}
|
|
238
|
+
/**
|
|
239
|
+
* Remove an import from flat config
|
|
240
|
+
*/
|
|
241
|
+
function removeImportFromFlatConfig(content, variable, imp) {
|
|
242
|
+
const source = ts.createSourceFile('', content, ts.ScriptTarget.Latest, true, ts.ScriptKind.JS);
|
|
243
|
+
const changes = [];
|
|
244
|
+
ts.forEachChild(source, (node) => {
|
|
245
|
+
// we can only combine object binding patterns
|
|
246
|
+
if (ts.isVariableStatement(node) &&
|
|
247
|
+
ts.isVariableDeclaration(node.declarationList.declarations[0]) &&
|
|
248
|
+
ts.isIdentifier(node.declarationList.declarations[0].name) &&
|
|
249
|
+
node.declarationList.declarations[0].name.getText() === variable &&
|
|
250
|
+
ts.isCallExpression(node.declarationList.declarations[0].initializer) &&
|
|
251
|
+
node.declarationList.declarations[0].initializer.expression.getText() ===
|
|
252
|
+
'require' &&
|
|
253
|
+
ts.isStringLiteral(node.declarationList.declarations[0].initializer.arguments[0]) &&
|
|
254
|
+
node.declarationList.declarations[0].initializer.arguments[0].text === imp) {
|
|
255
|
+
changes.push({
|
|
256
|
+
type: devkit_1.ChangeType.Delete,
|
|
257
|
+
start: node.pos,
|
|
258
|
+
length: node.end - node.pos,
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
});
|
|
262
|
+
return (0, devkit_1.applyChangesToString)(content, changes);
|
|
263
|
+
}
|
|
236
264
|
/**
|
|
237
265
|
* Injects new ts.expression to the end of the module.exports array.
|
|
238
266
|
*/
|
|
@@ -418,6 +446,38 @@ function removeCompatExtends(content, compatExtends) {
|
|
|
418
446
|
});
|
|
419
447
|
return (0, devkit_1.applyChangesToString)(content, changes);
|
|
420
448
|
}
|
|
449
|
+
function removePredefinedConfigs(content, moduleImport, moduleVariable, configs) {
|
|
450
|
+
const source = ts.createSourceFile('', content, ts.ScriptTarget.Latest, true, ts.ScriptKind.JS);
|
|
451
|
+
const changes = [];
|
|
452
|
+
let removeImport = true;
|
|
453
|
+
findAllBlocks(source).forEach((node) => {
|
|
454
|
+
if (ts.isSpreadElement(node) &&
|
|
455
|
+
ts.isElementAccessExpression(node.expression) &&
|
|
456
|
+
ts.isPropertyAccessExpression(node.expression.expression) &&
|
|
457
|
+
ts.isIdentifier(node.expression.expression.expression) &&
|
|
458
|
+
node.expression.expression.expression.getText() === moduleVariable &&
|
|
459
|
+
ts.isStringLiteral(node.expression.argumentExpression)) {
|
|
460
|
+
const config = node.expression.argumentExpression.getText();
|
|
461
|
+
// Check the text without quotes
|
|
462
|
+
if (configs.includes(config.substring(1, config.length - 1))) {
|
|
463
|
+
changes.push({
|
|
464
|
+
type: devkit_1.ChangeType.Delete,
|
|
465
|
+
start: node.pos,
|
|
466
|
+
length: node.end - node.pos + 1, // trailing comma
|
|
467
|
+
});
|
|
468
|
+
}
|
|
469
|
+
else {
|
|
470
|
+
// If there is still a config used, do not remove import
|
|
471
|
+
removeImport = false;
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
});
|
|
475
|
+
let updated = (0, devkit_1.applyChangesToString)(content, changes);
|
|
476
|
+
if (removeImport) {
|
|
477
|
+
updated = removeImportFromFlatConfig(updated, moduleVariable, moduleImport);
|
|
478
|
+
}
|
|
479
|
+
return updated;
|
|
480
|
+
}
|
|
421
481
|
/**
|
|
422
482
|
* Add plugins block to the top of the export blocks
|
|
423
483
|
*/
|