feat(linter): add support eslint 9 --quiet param (#28743)
closes #28291 <!-- Please make sure you have read the submission guidelines before posting an PR --> <!-- https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr --> <!-- Please make sure that your commit message follows our format --> <!-- Example: `fix(nx): must begin with lowercase` --> <!-- If this is a particularly complex change or feature addition, you can request a dedicated Nx release for this pull request branch. Mention someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they will confirm if the PR warrants its own release for testing purposes, and generate it for you if appropriate. --> ## Current Behavior <!-- This is the behavior we have today --> eslint 9 support --quiet param for not run warn rules, but nx not pass that param directly ## Expected Behavior <!-- This is the behavior we should expect with the changes in this PR --> nx executor should pass --quiet directly to eslint ## Related Issue(s) <!-- Please link the issue being fixed so it gets closed when this is merged. --> Fixes #28291
This commit is contained in:
parent
dbabfa7d2c
commit
bb878aa033
@ -1,4 +1,5 @@
|
|||||||
import type { ESLint } from 'eslint';
|
import type { ESLint } from 'eslint';
|
||||||
|
import { gte } from 'semver';
|
||||||
import { isFlatConfig } from '../../../utils/config-file';
|
import { isFlatConfig } from '../../../utils/config-file';
|
||||||
import { resolveESLintClass } from '../../../utils/resolve-eslint-class';
|
import { resolveESLintClass } from '../../../utils/resolve-eslint-class';
|
||||||
import type { Schema } from '../schema';
|
import type { Schema } from '../schema';
|
||||||
@ -18,7 +19,8 @@ export async function resolveAndInstantiateESLint(
|
|||||||
useFlatConfigOverrideVal: useFlatConfig,
|
useFlatConfigOverrideVal: useFlatConfig,
|
||||||
});
|
});
|
||||||
|
|
||||||
const eslintOptions: ESLint.Options = {
|
// ruleFilter exist only in eslint 9+, remove this type when eslint 8 support dropped
|
||||||
|
const eslintOptions: ESLint.Options & { ruleFilter?: Function } = {
|
||||||
overrideConfigFile: eslintConfigPath,
|
overrideConfigFile: eslintConfigPath,
|
||||||
fix: !!options.fix,
|
fix: !!options.fix,
|
||||||
cache: !!options.cache,
|
cache: !!options.cache,
|
||||||
@ -72,6 +74,11 @@ export async function resolveAndInstantiateESLint(
|
|||||||
options.reportUnusedDisableDirectives || undefined;
|
options.reportUnusedDisableDirectives || undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// pass --quiet to eslint 9+ directly: filter only errors
|
||||||
|
if (options.quiet && gte(ESLint.version, '9.0.0')) {
|
||||||
|
eslintOptions.ruleFilter = (rule) => rule.severity === 2;
|
||||||
|
}
|
||||||
|
|
||||||
const eslint = new ESLint(eslintOptions);
|
const eslint = new ESLint(eslintOptions);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user