Skip to content

Commit 08e0884

Browse files
TrottFishrock123
authored andcommitted
tools: add -F flag for fixing lint issues
Add `-F` flag to `jslint.js` which enables the automatic fixing of issues that are fixable. PR-URL: #6483 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Brian White <[email protected]>
1 parent 7c30f15 commit 08e0884

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

tools/jslint.js

+13-2
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,15 @@ const CLIEngine = require('./eslint').CLIEngine;
1313
const glob = require('./eslint/node_modules/glob');
1414

1515
const cwd = process.cwd();
16-
const cli = new CLIEngine({
16+
const cliOptions = {
1717
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);
1925

2026
if (cluster.isMaster) {
2127
var numCPUs = 1;
@@ -240,6 +246,11 @@ if (cluster.isMaster) {
240246
if (files instanceof Array) {
241247
// Lint some files
242248
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+
243254
if (config.sendAll) {
244255
// Return both success and error results
245256

0 commit comments

Comments
 (0)