Pass extra CLI args through to ESLint (#20250)

These now work:

```
yarn run lint --fix
yarn run linc --fix
```
This commit is contained in:
Andrew Clark
2020-11-13 11:00:45 -08:00
committed by GitHub
parent b44e4b13a9
commit 73bf2d68ef
3 changed files with 9 additions and 4 deletions
+3 -2
View File
@@ -64,13 +64,14 @@ function intersect(files, patterns) {
return [...new Set(intersection)];
}
function runESLint({onlyChanged}) {
function runESLint({onlyChanged, ...options}) {
if (typeof onlyChanged !== 'boolean') {
throw new Error('Pass options.onlyChanged as a boolean.');
}
const {errorCount, warningCount, output} = runESLintOnFilesWithOptions(
allPaths,
onlyChanged
onlyChanged,
options
);
console.log(output);
return errorCount === 0 && warningCount === 0;
+3 -1
View File
@@ -7,6 +7,7 @@
'use strict';
const minimist = require('minimist');
const runESLint = require('../eslint');
console.log('Linting all files...');
@@ -15,7 +16,8 @@ if (!process.env.CI) {
console.log('Hint: run `yarn linc` to only lint changed files.');
}
if (runESLint({onlyChanged: false})) {
const cliOptions = minimist(process.argv.slice(2));
if (runESLint({onlyChanged: false, ...cliOptions})) {
console.log('Lint passed.');
} else {
console.log('Lint failed.');
+3 -1
View File
@@ -7,11 +7,13 @@
'use strict';
const minimist = require('minimist');
const runESLint = require('../eslint');
console.log('Linting changed files...');
if (runESLint({onlyChanged: true})) {
const cliOptions = minimist(process.argv.slice(2));
if (runESLint({onlyChanged: true, ...cliOptions})) {
console.log('Lint passed for changed files.');
} else {
console.log('Lint failed for changed files.');