@nx/eslint 17.3.1 → 17.3.2
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.3.
|
3
|
+
"version": "17.3.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": {
|
@@ -30,20 +30,17 @@
|
|
30
30
|
"generators": "./generators.json",
|
31
31
|
"executors": "./executors.json",
|
32
32
|
"peerDependencies": {
|
33
|
-
"eslint": "^8.0.0",
|
34
33
|
"js-yaml": "4.1.0"
|
35
34
|
},
|
36
35
|
"dependencies": {
|
37
|
-
"@nx/devkit": "17.3.
|
38
|
-
"@nx/js": "17.3.
|
36
|
+
"@nx/devkit": "17.3.2",
|
37
|
+
"@nx/js": "17.3.2",
|
38
|
+
"eslint": "^8.0.0",
|
39
39
|
"tslib": "^2.3.0",
|
40
40
|
"typescript": "~5.3.2",
|
41
|
-
"@nx/linter": "17.3.
|
41
|
+
"@nx/linter": "17.3.2"
|
42
42
|
},
|
43
43
|
"peerDependenciesMeta": {
|
44
|
-
"eslint": {
|
45
|
-
"optional": true
|
46
|
-
},
|
47
44
|
"js-yaml": {
|
48
45
|
"optional": true
|
49
46
|
}
|
@@ -118,14 +118,6 @@ Please see https://nx.dev/guides/eslint for full guidance on how to resolve this
|
|
118
118
|
lintResults = ESLint.getErrorResults(lintResults);
|
119
119
|
}
|
120
120
|
const formatter = await eslint.loadFormatter(normalizedOptions.format);
|
121
|
-
let totalErrors = 0;
|
122
|
-
let totalWarnings = 0;
|
123
|
-
for (const result of lintResults) {
|
124
|
-
if (result.errorCount || result.warningCount) {
|
125
|
-
totalErrors += result.errorCount;
|
126
|
-
totalWarnings += result.warningCount;
|
127
|
-
}
|
128
|
-
}
|
129
121
|
const formattedResults = await formatter.format(lintResults);
|
130
122
|
if (normalizedOptions.outputFile) {
|
131
123
|
const pathToOutputFile = (0, devkit_1.joinPathFragments)(context.root, normalizedOptions.outputFile);
|
@@ -135,20 +127,48 @@ Please see https://nx.dev/guides/eslint for full guidance on how to resolve this
|
|
135
127
|
else {
|
136
128
|
console.info(formattedResults);
|
137
129
|
}
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
if (totalErrors > 0 && printInfo) {
|
142
|
-
console.error('Lint errors found in the listed files.\n');
|
143
|
-
}
|
144
|
-
if (totalWarnings === 0 && totalErrors === 0 && printInfo) {
|
145
|
-
console.info('All files pass linting.\n');
|
130
|
+
const totals = getTotals(lintResults);
|
131
|
+
if (printInfo) {
|
132
|
+
outputPrintInfo(totals);
|
146
133
|
}
|
147
134
|
return {
|
148
135
|
success: normalizedOptions.force ||
|
149
|
-
(
|
136
|
+
(totals.errors === 0 &&
|
150
137
|
(normalizedOptions.maxWarnings === -1 ||
|
151
|
-
|
138
|
+
totals.warnings <= normalizedOptions.maxWarnings)),
|
152
139
|
};
|
153
140
|
}
|
154
141
|
exports.default = run;
|
142
|
+
function getTotals(lintResults) {
|
143
|
+
let errors = 0;
|
144
|
+
let warnings = 0;
|
145
|
+
let fixableErrors = 0;
|
146
|
+
let fixableWarnings = 0;
|
147
|
+
for (const result of lintResults) {
|
148
|
+
errors += result.errorCount || 0;
|
149
|
+
warnings += result.warningCount || 0;
|
150
|
+
fixableErrors += result.fixableErrorCount || 0;
|
151
|
+
fixableWarnings += result.fixableWarningCount || 0;
|
152
|
+
}
|
153
|
+
return {
|
154
|
+
errors,
|
155
|
+
warnings,
|
156
|
+
fixableErrors,
|
157
|
+
fixableWarnings,
|
158
|
+
};
|
159
|
+
}
|
160
|
+
function pluralizedOutput(word, count) {
|
161
|
+
return `${count} ${word}${count === 1 ? '' : 's'}`;
|
162
|
+
}
|
163
|
+
function outputPrintInfo({ errors, warnings, fixableErrors, fixableWarnings, }) {
|
164
|
+
const total = warnings + errors;
|
165
|
+
const totalFixable = fixableErrors + fixableWarnings;
|
166
|
+
if (total <= 0) {
|
167
|
+
console.info('\u2714 All files pass linting\n');
|
168
|
+
return;
|
169
|
+
}
|
170
|
+
console.info(`\u2716 ${pluralizedOutput('problem', total)} (${pluralizedOutput('error', errors)}, ${pluralizedOutput('warning', warnings)})\n`);
|
171
|
+
if (totalFixable <= 0)
|
172
|
+
return;
|
173
|
+
console.info(` ${pluralizedOutput('error', fixableErrors)} and ${pluralizedOutput('warning', fixableWarnings)} are potentially fixable with the \`--fix\` option.\n`);
|
174
|
+
}
|
@@ -38,7 +38,6 @@ async function resolveAndInstantiateESLint(eslintConfigPath, options, useFlatCon
|
|
38
38
|
* not be any html files in the project, so keeping it true would break linting every time
|
39
39
|
*/
|
40
40
|
errorOnUnmatchedPattern: false,
|
41
|
-
reportUnusedDisableDirectives: options.reportUnusedDisableDirectives || undefined,
|
42
41
|
};
|
43
42
|
if (useFlatConfig) {
|
44
43
|
if (typeof options.useEslintrc !== 'undefined') {
|
@@ -50,6 +49,9 @@ async function resolveAndInstantiateESLint(eslintConfigPath, options, useFlatCon
|
|
50
49
|
if (options.ignorePath !== undefined) {
|
51
50
|
throw new Error('For Flat Config, ESLint removed `ignorePath` and so it is not supported as an option. See https://eslint.org/docs/latest/use/configure/configuration-files-new');
|
52
51
|
}
|
52
|
+
if (options.reportUnusedDisableDirectives) {
|
53
|
+
throw new Error('For Flat Config, ESLint removed `reportedUnusedDisableDirectives` and so it is not supported as an option. See https://eslint.org/docs/latest/use/configure/configuration-files-new');
|
54
|
+
}
|
53
55
|
}
|
54
56
|
else {
|
55
57
|
eslintOptions.rulePaths = options.rulesdir || [];
|
@@ -61,6 +63,8 @@ async function resolveAndInstantiateESLint(eslintConfigPath, options, useFlatCon
|
|
61
63
|
* merge the provided config with others it finds automatically.
|
62
64
|
*/
|
63
65
|
eslintOptions.useEslintrc = !options.noEslintrc;
|
66
|
+
eslintOptions.reportUnusedDisableDirectives =
|
67
|
+
options.reportUnusedDisableDirectives || undefined;
|
64
68
|
}
|
65
69
|
const eslint = new ESLint(eslintOptions);
|
66
70
|
return {
|
@@ -46,7 +46,8 @@ function convertProjectToFlatConfig(tree, project, projectConfig, nxJson, eslint
|
|
46
46
|
const eslintFile = (0, eslint_file_1.findEslintFile)(tree, projectConfig.root);
|
47
47
|
if (eslintFile && !eslintFile.endsWith('.js')) {
|
48
48
|
if (projectConfig.targets) {
|
49
|
-
const eslintTargets = Object.keys(projectConfig.targets || {}).filter((t) => projectConfig.targets[t].executor === '@nx/eslint:lint'
|
49
|
+
const eslintTargets = Object.keys(projectConfig.targets || {}).filter((t) => projectConfig.targets[t].executor === '@nx/eslint:lint' ||
|
50
|
+
projectConfig.targets[t].command?.includes('eslint'));
|
50
51
|
let ignorePath;
|
51
52
|
for (const target of eslintTargets) {
|
52
53
|
// remove any obsolete `eslintConfig` options pointing to the old config file
|
@@ -59,10 +60,14 @@ function convertProjectToFlatConfig(tree, project, projectConfig, nxJson, eslint
|
|
59
60
|
}
|
60
61
|
(0, devkit_1.updateProjectConfiguration)(tree, project, projectConfig);
|
61
62
|
}
|
62
|
-
const
|
63
|
-
nxJson.targetDefaults[t].executor === '@nx/eslint:lint'
|
63
|
+
const nxHasEsLintTargets = Object.keys(nxJson.targetDefaults || {}).some((t) => (t === '@nx/eslint:lint' ||
|
64
|
+
nxJson.targetDefaults[t].executor === '@nx/eslint:lint' ||
|
65
|
+
nxJson.targetDefaults[t].command?.includes('eslint')) &&
|
64
66
|
projectConfig.targets?.[t]);
|
65
|
-
|
67
|
+
const nxHasEsLintPlugin = (nxJson.plugins || []).some((p) => typeof p === 'string'
|
68
|
+
? p === '@nx/eslint/plugin'
|
69
|
+
: p.plugin === '@nx/eslint/plugin');
|
70
|
+
if (nxHasEsLintTargets || nxHasEsLintPlugin || eslintTargets.length > 0) {
|
66
71
|
convertConfigToFlatConfig(tree, projectConfig.root, eslintFile, 'eslint.config.js', ignorePath);
|
67
72
|
eslintIgnoreFiles.add(`${projectConfig.root}/.eslintignore`);
|
68
73
|
if (ignorePath) {
|