Skip to content

Commit e6f2a8a

Browse files
authored
Allow running yarn lint on subset of paths (facebook#34646)
1 parent ba2214e commit e6f2a8a

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

scripts/eslint/index.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,18 @@ function intersect(files, patterns) {
7272
return [...new Set(intersection)];
7373
}
7474

75-
async function runESLint({onlyChanged, ...options}) {
75+
async function runESLint({onlyChanged, paths, ...options}) {
7676
if (typeof onlyChanged !== 'boolean') {
7777
throw new Error('Pass options.onlyChanged as a boolean.');
7878
}
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+
}
7985
const {errorCount, warningCount, output} = await runESLintOnFilesWithOptions(
80-
allPaths,
86+
paths,
8187
onlyChanged,
8288
options
8389
);

scripts/tasks/eslint.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ async function main() {
1616
console.log('Hint: run `yarn linc` to only lint changed files.');
1717
}
1818

19-
const {_, ...cliOptions} = minimist(process.argv.slice(2));
19+
const {_: paths, ...cliOptions} = minimist(process.argv.slice(2));
2020

21-
if (await runESLint({onlyChanged: false, ...cliOptions})) {
21+
if (await runESLint({onlyChanged: false, ...cliOptions, paths})) {
2222
console.log('Lint passed.');
2323
} else {
2424
console.log('Lint failed.');

0 commit comments

Comments
 (0)