Skip to content

Commit

Permalink
Add reset cli flag (refs eslint#692)
Browse files Browse the repository at this point in the history
Adds a --reset flag to the cli options that resets all
default rules to be off.
  • Loading branch information
btmills committed Mar 26, 2014
1 parent 44460ff commit d90413f
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 2 deletions.
11 changes: 10 additions & 1 deletion docs/command-line-interface/README.md
Expand Up @@ -26,6 +26,7 @@ Options:
-c, --config path::String load configuration data from this file
--rulesdir path::String load additional rules from this directory
-f, --format String use a specific output format - default: stylish
--reset set all default rules to off
-v, --version outputs the version number
```

Expand Down Expand Up @@ -65,7 +66,15 @@ Example:

eslint --rulesdir my-rules/ file.js

The rules in your custom rules directory must following the same format as bundled rules to work properly.
The rules in your custom rules directory must follow the same format as bundled rules to work properly.

### `--reset`

This option turns off all rules enabled in ESLint's default configuration file located at `conf/eslint.json`. ESLint will still report syntax errors.

Example:

eslint --reset file.js

### `-v`, `--version`

Expand Down
3 changes: 2 additions & 1 deletion lib/config.js
Expand Up @@ -125,7 +125,8 @@ function Config(options) {

this.cache = {};
this.exclusionsCache = {};
this.baseConfig = require(path.resolve(__dirname, "..", "conf", "eslint.json"));
this.baseConfig = options.reset ? {} :
require(path.resolve(__dirname, "..", "conf", "eslint.json"));
this.baseConfig.format = options.format;
useConfig = options.config;

Expand Down
4 changes: 4 additions & 0 deletions lib/options.js
Expand Up @@ -44,5 +44,9 @@ module.exports = optionator({
alias: "v",
type: "Boolean",
description: "Outputs the version number."
}, {
option: "reset",
type: "Boolean",
description: "Set all default rules to off."
}]
});
9 changes: 9 additions & 0 deletions tests/lib/cli.js
Expand Up @@ -226,4 +226,13 @@ describe("cli", function() {
assert.equal(exit, 1);
});
});

describe("when executing with reset flag", function() {
it("should execute without any errors", function () {
var exit = cli.execute("--reset tests/fixtures/missing-semicolon.js");

assert.isTrue(console.log.notCalled);
assert.equal(exit, 0);
});
});
});

0 comments on commit d90413f

Please sign in to comment.