diff --git a/scripts/eslint/index.js b/scripts/eslint/index.js index 369637317a..dd65429e07 100644 --- a/scripts/eslint/index.js +++ b/scripts/eslint/index.js @@ -72,12 +72,18 @@ function intersect(files, patterns) { return [...new Set(intersection)]; } -async function runESLint({onlyChanged, ...options}) { +async function runESLint({onlyChanged, paths, ...options}) { if (typeof onlyChanged !== 'boolean') { throw new Error('Pass options.onlyChanged as a boolean.'); } + if (onlyChanged && paths !== undefined) { + throw new Error('Cannot specify paths when onlyChanged is true.'); + } + if (paths === undefined || paths.length === 0) { + paths = allPaths; + } const {errorCount, warningCount, output} = await runESLintOnFilesWithOptions( - allPaths, + paths, onlyChanged, options ); diff --git a/scripts/tasks/eslint.js b/scripts/tasks/eslint.js index 6a01f88e98..ba7df75805 100644 --- a/scripts/tasks/eslint.js +++ b/scripts/tasks/eslint.js @@ -16,9 +16,9 @@ async function main() { console.log('Hint: run `yarn linc` to only lint changed files.'); } - const {_, ...cliOptions} = minimist(process.argv.slice(2)); + const {_: paths, ...cliOptions} = minimist(process.argv.slice(2)); - if (await runESLint({onlyChanged: false, ...cliOptions})) { + if (await runESLint({onlyChanged: false, ...cliOptions, paths})) { console.log('Lint passed.'); } else { console.log('Lint failed.');