Allow running yarn lint on subset of paths (#34646)

This commit is contained in:
Sebastian "Sebbie" Silbermann 2025-09-30 12:30:40 +02:00 committed by GitHub
parent ba2214e571
commit e6f2a8a376
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 4 deletions

View File

@ -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
);

View File

@ -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.');