mirror of
https://github.com/zebrajr/react.git
synced 2025-12-06 12:20:20 +01:00
Allow running yarn lint on subset of paths (#34646)
This commit is contained in:
parent
ba2214e571
commit
e6f2a8a376
|
|
@ -72,12 +72,18 @@ function intersect(files, patterns) {
|
||||||
return [...new Set(intersection)];
|
return [...new Set(intersection)];
|
||||||
}
|
}
|
||||||
|
|
||||||
async function runESLint({onlyChanged, ...options}) {
|
async function runESLint({onlyChanged, paths, ...options}) {
|
||||||
if (typeof onlyChanged !== 'boolean') {
|
if (typeof onlyChanged !== 'boolean') {
|
||||||
throw new Error('Pass options.onlyChanged as a 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(
|
const {errorCount, warningCount, output} = await runESLintOnFilesWithOptions(
|
||||||
allPaths,
|
paths,
|
||||||
onlyChanged,
|
onlyChanged,
|
||||||
options
|
options
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -16,9 +16,9 @@ async function main() {
|
||||||
console.log('Hint: run `yarn linc` to only lint changed files.');
|
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.');
|
console.log('Lint passed.');
|
||||||
} else {
|
} else {
|
||||||
console.log('Lint failed.');
|
console.log('Lint failed.');
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user