From 08274b1cba1f862e77f47333e80c419dd5167660 Mon Sep 17 00:00:00 2001 From: Sebastian Sebbie Silbermann Date: Mon, 29 Sep 2025 11:14:05 +0200 Subject: [PATCH] Allow running `yarn lint` on subset of paths --- scripts/eslint/index.js | 10 ++++++++-- scripts/tasks/eslint.js | 4 ++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/scripts/eslint/index.js b/scripts/eslint/index.js index 369637317ae..dd65429e071 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 6a01f88e982..ba7df75805e 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.');