Skip to content

Commit bb878aa

Browse files
authored
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
1 parent dbabfa7 commit bb878aa

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

packages/eslint/src/executors/lint/utility/eslint-utils.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type { ESLint } from 'eslint';
2+
import { gte } from 'semver';
23
import { isFlatConfig } from '../../../utils/config-file';
34
import { resolveESLintClass } from '../../../utils/resolve-eslint-class';
45
import type { Schema } from '../schema';
@@ -18,7 +19,8 @@ export async function resolveAndInstantiateESLint(
1819
useFlatConfigOverrideVal: useFlatConfig,
1920
});
2021

21-
const eslintOptions: ESLint.Options = {
22+
// ruleFilter exist only in eslint 9+, remove this type when eslint 8 support dropped
23+
const eslintOptions: ESLint.Options & { ruleFilter?: Function } = {
2224
overrideConfigFile: eslintConfigPath,
2325
fix: !!options.fix,
2426
cache: !!options.cache,
@@ -72,6 +74,11 @@ export async function resolveAndInstantiateESLint(
7274
options.reportUnusedDisableDirectives || undefined;
7375
}
7476

77+
// pass --quiet to eslint 9+ directly: filter only errors
78+
if (options.quiet && gte(ESLint.version, '9.0.0')) {
79+
eslintOptions.ruleFilter = (rule) => rule.severity === 2;
80+
}
81+
7582
const eslint = new ESLint(eslintOptions);
7683

7784
return {

0 commit comments

Comments
 (0)