-
Notifications
You must be signed in to change notification settings - Fork 29.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
tools: add -F flag for fixing lint issues #6483
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,9 +13,15 @@ const CLIEngine = require('./eslint').CLIEngine; | |
const glob = require('./eslint/node_modules/glob'); | ||
|
||
const cwd = process.cwd(); | ||
const cli = new CLIEngine({ | ||
const cliOptions = { | ||
rulePaths: rulesDirs | ||
}); | ||
}; | ||
|
||
// Check if we should fix errors that are fixable | ||
if (process.argv.indexOf('-F') !== -1) | ||
cliOptions.fix = true; | ||
|
||
const cli = new CLIEngine(cliOptions); | ||
|
||
if (cluster.isMaster) { | ||
var numCPUs = 1; | ||
|
@@ -240,6 +246,11 @@ if (cluster.isMaster) { | |
if (files instanceof Array) { | ||
// Lint some files | ||
const report = cli.executeOnFiles(files); | ||
|
||
// If we were asked to fix the fixable issues, do so. | ||
if (cliOptions.fix) | ||
CLIEngine.outputFixes(report); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this line just remove the fixed lint errors from the report? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, that appears to be done by passing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, I was just surprised it has enough information in the |
||
|
||
if (config.sendAll) { | ||
// Return both success and error results | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
process.argv.includes('-F')
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or maybe put the result into above object, like
fix: process.argv.includes('-F')
, reducing the changes around here to a single line.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@silverwind wrote:
I don't feel strongly about it, but I went with
indexOf() !== -1
overincludes()
so that this could be used in the LTS branch and to be consistent with line 47 and elsewhere in the file that was already usingindexOf() !== -1
for existence.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, right. Keep it as-is for LTS then.