@nx/eslint 17.0.0-rc.3 → 17.0.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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/eslint",
|
|
3
|
-
"version": "17.0.0
|
|
3
|
+
"version": "17.0.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": {
|
|
@@ -34,10 +34,10 @@
|
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"tslib": "^2.3.0",
|
|
37
|
-
"@nx/devkit": "17.0.0
|
|
38
|
-
"@nx/js": "17.0.0
|
|
37
|
+
"@nx/devkit": "17.0.0",
|
|
38
|
+
"@nx/js": "17.0.0",
|
|
39
39
|
"typescript": "~5.1.3",
|
|
40
|
-
"@nx/linter": "17.0.0
|
|
40
|
+
"@nx/linter": "17.0.0"
|
|
41
41
|
},
|
|
42
42
|
"peerDependenciesMeta": {
|
|
43
43
|
"eslint": {
|
|
@@ -47,15 +47,15 @@ function updateRelativePathsInConfig(tree, sourcePath, destinationPath) {
|
|
|
47
47
|
const offset = (0, devkit_1.offsetFromRoot)(destinationPath);
|
|
48
48
|
if ((0, flat_config_1.useFlatConfig)(tree)) {
|
|
49
49
|
const config = tree.read(configPath, 'utf-8');
|
|
50
|
-
tree.write(configPath, replaceFlatConfigPaths(config, sourcePath, offset, destinationPath));
|
|
50
|
+
tree.write(configPath, replaceFlatConfigPaths(config, sourcePath, offset, destinationPath, tree));
|
|
51
51
|
}
|
|
52
52
|
else {
|
|
53
53
|
(0, devkit_1.updateJson)(tree, configPath, (json) => {
|
|
54
54
|
if (typeof json.extends === 'string') {
|
|
55
|
-
json.extends = offsetFilePath(sourcePath, json.extends, offset);
|
|
55
|
+
json.extends = offsetFilePath(sourcePath, json.extends, offset, tree);
|
|
56
56
|
}
|
|
57
57
|
else if (json.extends) {
|
|
58
|
-
json.extends = json.extends.map((extend) => offsetFilePath(sourcePath, extend, offset));
|
|
58
|
+
json.extends = json.extends.map((extend) => offsetFilePath(sourcePath, extend, offset, tree));
|
|
59
59
|
}
|
|
60
60
|
json.overrides?.forEach((o) => {
|
|
61
61
|
if (o.parserOptions?.project) {
|
|
@@ -69,13 +69,13 @@ function updateRelativePathsInConfig(tree, sourcePath, destinationPath) {
|
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
71
|
exports.updateRelativePathsInConfig = updateRelativePathsInConfig;
|
|
72
|
-
function replaceFlatConfigPaths(config, sourceRoot, offset, destinationRoot) {
|
|
72
|
+
function replaceFlatConfigPaths(config, sourceRoot, offset, destinationRoot, tree) {
|
|
73
73
|
let match;
|
|
74
74
|
let newConfig = config;
|
|
75
75
|
// replace requires
|
|
76
76
|
const requireRegex = RegExp(/require\(['"](.*)['"]\)/g);
|
|
77
77
|
while ((match = requireRegex.exec(newConfig)) !== null) {
|
|
78
|
-
const newPath = offsetFilePath(sourceRoot, match[1], offset);
|
|
78
|
+
const newPath = offsetFilePath(sourceRoot, match[1], offset, tree);
|
|
79
79
|
newConfig =
|
|
80
80
|
newConfig.slice(0, match.index) +
|
|
81
81
|
`require('${newPath}')` +
|
|
@@ -92,7 +92,14 @@ function replaceFlatConfigPaths(config, sourceRoot, offset, destinationRoot) {
|
|
|
92
92
|
}
|
|
93
93
|
return newConfig;
|
|
94
94
|
}
|
|
95
|
-
function offsetFilePath(projectRoot, pathToFile, offset) {
|
|
95
|
+
function offsetFilePath(projectRoot, pathToFile, offset, tree) {
|
|
96
|
+
if (exports.eslintConfigFileWhitelist.some((eslintFile) => pathToFile.includes(eslintFile))) {
|
|
97
|
+
// if the file is point to base eslint
|
|
98
|
+
const rootEslint = findEslintFile(tree);
|
|
99
|
+
if (rootEslint) {
|
|
100
|
+
return (0, devkit_1.joinPathFragments)(offset, rootEslint);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
96
103
|
if (!pathToFile.startsWith('..')) {
|
|
97
104
|
// not a relative path
|
|
98
105
|
return pathToFile;
|