GeezerVison is showing github.com — tools: add -F flag for fixing lint issues · nodejs/node@08e0884
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: tools/jslint.js +13-2Lines changed: 13 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -13,9 +13,15 @@ const CLIEngine = require('./eslint').CLIEngine; |
13 | 13 | const glob = require('./eslint/node_modules/glob'); |
14 | 14 |
|
15 | 15 | const cwd = process.cwd(); |
16 | | -const cli = new CLIEngine({ |
| 16 | +const cliOptions = { |
17 | 17 | rulePaths: rulesDirs |
18 | | -}); |
| 18 | +}; |
| 19 | + |
| 20 | +// Check if we should fix errors that are fixable |
| 21 | +if (process.argv.indexOf('-F') !== -1) |
| 22 | + cliOptions.fix = true; |
| 23 | + |
| 24 | +const cli = new CLIEngine(cliOptions); |
19 | 25 |
|
20 | 26 | if (cluster.isMaster) { |
21 | 27 | var numCPUs = 1; |
@@ -240,6 +246,11 @@ if (cluster.isMaster) { |
240 | 246 | if (files instanceof Array) { |
241 | 247 | // Lint some files |
242 | 248 | const report = cli.executeOnFiles(files); |
| 249 | + |
| 250 | + // If we were asked to fix the fixable issues, do so. |
| 251 | + if (cliOptions.fix) |
| 252 | + CLIEngine.outputFixes(report); |
| 253 | + |
243 | 254 | if (config.sendAll) { |
244 | 255 | // Return both success and error results |
245 | 256 |
|
|