Pass extra CLI args through to ESLint (#20250)
These now work: ``` yarn run lint --fix yarn run linc --fix ```
Andrew Clark committed
Nov 13, 2020 at 13:00 UTC
73bf2d68efc363810209bb3c35768793b1e40ecb
3 files changed
+9
-4
scripts/eslint/index.js
+3
-2
@@ -64,13 +64,14 @@ function intersect(files, patterns) {
64
return [...new Set(intersection)];
65
}
66
67
-function runESLint({onlyChanged}) {
67
+function runESLint({onlyChanged, ...options}) {
68
if (typeof onlyChanged !== 'boolean') {
69
throw new Error('Pass options.onlyChanged as a boolean.');
70
}
71
const {errorCount, warningCount, output} = runESLintOnFilesWithOptions(
72
allPaths,
73
- onlyChanged
73
+ onlyChanged,
74
+ options
75
);
76
console.log(output);
77
return errorCount === 0 && warningCount === 0;
scripts/tasks/eslint.js
+3
-1
@@ -7,6 +7,7 @@
7
8
'use strict';
9
10
+const minimist = require('minimist');
11
const runESLint = require('../eslint');
12
13
console.log('Linting all files...');
@@ -15,7 +16,8 @@ if (!process.env.CI) {
16
console.log('Hint: run `yarn linc` to only lint changed files.');
17
}
18
18
-if (runESLint({onlyChanged: false})) {
19
+const cliOptions = minimist(process.argv.slice(2));
20
+if (runESLint({onlyChanged: false, ...cliOptions})) {
21
console.log('Lint passed.');
22
} else {
23
console.log('Lint failed.');
scripts/tasks/linc.js
+3
-1
@@ -7,11 +7,13 @@
7
8
'use strict';
9
10
+const minimist = require('minimist');
11
const runESLint = require('../eslint');
12
13
console.log('Linting changed files...');
14
14
-if (runESLint({onlyChanged: true})) {
15
+const cliOptions = minimist(process.argv.slice(2));
16
+if (runESLint({onlyChanged: true, ...cliOptions})) {
17
console.log('Lint passed for changed files.');
18
} else {
19
console.log('Lint failed for changed files.');