Browse Source

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: https://github.com/nodejs/node/pull/6483
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Brian White <mscdex@mscdex.net>
v6.x
Rich Trott 9 years ago
committed by Jeremiah Senkpiel
parent
commit
08e0884ae0
  1. 15
      tools/jslint.js

15
tools/jslint.js

@ -13,9 +13,15 @@ const CLIEngine = require('./eslint').CLIEngine;
const glob = require('./eslint/node_modules/glob'); const glob = require('./eslint/node_modules/glob');
const cwd = process.cwd(); const cwd = process.cwd();
const cli = new CLIEngine({ const cliOptions = {
rulePaths: rulesDirs 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) { if (cluster.isMaster) {
var numCPUs = 1; var numCPUs = 1;
@ -240,6 +246,11 @@ if (cluster.isMaster) {
if (files instanceof Array) { if (files instanceof Array) {
// Lint some files // Lint some files
const report = cli.executeOnFiles(files); const report = cli.executeOnFiles(files);
// If we were asked to fix the fixable issues, do so.
if (cliOptions.fix)
CLIEngine.outputFixes(report);
if (config.sendAll) { if (config.sendAll) {
// Return both success and error results // Return both success and error results

Loading…
Cancel
Save