Skip to content

Commit

Permalink
Pass extra CLI args through to ESLint (facebook#20250)
Browse files Browse the repository at this point in the history
These now work:

```
yarn run lint --fix
yarn run linc --fix
```
  • Loading branch information
acdlite authored Nov 13, 2020
1 parent b44e4b1 commit 73bf2d6
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
5 changes: 3 additions & 2 deletions scripts/eslint/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 3 additions & 1 deletion scripts/tasks/eslint.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

'use strict';

const minimist = require('minimist');
const runESLint = require('../eslint');

console.log('Linting all files...');
Expand All @@ -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.');
Expand Down
4 changes: 3 additions & 1 deletion scripts/tasks/linc.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.');
Expand Down

0 comments on commit 73bf2d6

Please sign in to comment.