Skip to content

Commit

Permalink
New: Add eslint:all option (fixes #6240) (#6248)
Browse files Browse the repository at this point in the history
This adds a new option to allow a user to extend `eslint:all` in order
to enable all rules by default.
  • Loading branch information
mockdeep authored and nzakas committed Jun 8, 2016
1 parent dfe05bf commit f804397
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 2 deletions.
1 change: 0 additions & 1 deletion .eslintignore
@@ -1,6 +1,5 @@
/bin/**
/build/**
/conf/**
/coverage/**
/docs/**
/jsdoc/**
Expand Down
2 changes: 1 addition & 1 deletion Makefile.js
Expand Up @@ -61,7 +61,7 @@ var NODE = "node ", // intentional extra space

// Files
MAKEFILE = "./Makefile.js",
JS_FILES = find("lib/").filter(fileType("js")).join(" "),
JS_FILES = find("lib/", "conf/").filter(fileType("js")).join(" "),
JSON_FILES = find("conf/").filter(fileType("json")),
MARKDOWN_FILES_ARRAY = find("docs/").concat(ls(".")).filter(fileType("md")),
TEST_FILES = getTestFilePatterns(),
Expand Down
29 changes: 29 additions & 0 deletions conf/eslint-all.js
@@ -0,0 +1,29 @@
/**
* @fileoverview Config to enable all rules.
* @author Robert Fletcher
*/

"use strict";

//------------------------------------------------------------------------------
// Requirements
//------------------------------------------------------------------------------

var fs = require("fs"),
path = require("path");

//------------------------------------------------------------------------------
// Helpers
//------------------------------------------------------------------------------

var ruleFiles = fs.readdirSync(path.resolve(__dirname, "../lib/rules"));
var enabledRules = ruleFiles.reduce(function(result, filename) {
result[path.basename(filename, ".js")] = "error";
return result;
}, {});

//------------------------------------------------------------------------------
// Public Interface
//------------------------------------------------------------------------------

module.exports = { rules: enabledRules };
6 changes: 6 additions & 0 deletions lib/config/config-file.js
Expand Up @@ -369,6 +369,12 @@ function applyExtends(config, filePath, relativeTo) {
* this lets us use the eslint.json file as the recommended rules
*/
parentPath = path.resolve(__dirname, "../../conf/eslint.json");
} else if (parentPath === "eslint:all") {

/*
* Add an explicit substitution for eslint:all to conf/eslint-all.js
*/
parentPath = path.resolve(__dirname, "../../conf/eslint-all.js");
} else if (isFilePath(parentPath)) {

/*
Expand Down
15 changes: 15 additions & 0 deletions tests/lib/config/config-file.js
Expand Up @@ -186,6 +186,21 @@ describe("ConfigFile", function() {

});

it("should apply all rules when extends config includes 'eslint:all'", function() {

var configDeps = {
"../util/module-resolver": createStubModuleResolver({})
};
var StubbedConfigFile = proxyquire("../../../lib/config/config-file", configDeps);
var config = StubbedConfigFile.applyExtends({
extends: "eslint:all"
}, "/whatever");

assert.equal(config.rules.eqeqeq, "error");
assert.equal(config.rules.curly, "error");

});

it("should throw an error when extends config is not found", function() {

var configDeps = {
Expand Down

0 comments on commit f804397

Please sign in to comment.