Allow running `yarn lint` on subset of paths (#34646)
Sebastian "Sebbie" Silbermann committed
Sep 30, 2025 at 12:30 UTC
e6f2a8a376f81faefbbc7f5af411a904eb778dfc
2 files changed
+10
-4
scripts/eslint/index.js
+8
-2
@@ -72,12 +72,18 @@ function intersect(files, patterns) {
72
return [...new Set(intersection)];
73
}
74
75
-async function runESLint({onlyChanged, ...options}) {
75
+async function runESLint({onlyChanged, paths, ...options}) {
76
if (typeof onlyChanged !== 'boolean') {
77
throw new Error('Pass options.onlyChanged as a boolean.');
78
}
79
+ if (onlyChanged && paths !== undefined) {
80
+ throw new Error('Cannot specify paths when onlyChanged is true.');
81
+ }
82
+ if (paths === undefined || paths.length === 0) {
83
+ paths = allPaths;
84
+ }
85
const {errorCount, warningCount, output} = await runESLintOnFilesWithOptions(
80
- allPaths,
86
+ paths,
87
onlyChanged,
88
options
89
);
scripts/tasks/eslint.js
+2
-2
@@ -16,9 +16,9 @@ async function main() {
16
console.log('Hint: run `yarn linc` to only lint changed files.');
17
}
18
19
- const {_, ...cliOptions} = minimist(process.argv.slice(2));
19
+ const {_: paths, ...cliOptions} = minimist(process.argv.slice(2));
20
21
- if (await runESLint({onlyChanged: false, ...cliOptions})) {
21
+ if (await runESLint({onlyChanged: false, ...cliOptions, paths})) {
22
console.log('Lint passed.');
23
} else {
24
console.log('Lint failed.');