Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New: Add eslint:all option (fixes #6240) #6248

Merged
merged 1 commit into from Jun 8, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please follow the same format as other files: http://eslint.org/docs/developer-guide/code-conventions#file-format


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

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

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

var ruleFiles = fs.readdirSync(path.resolve(__dirname, "../lib/rules"));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should lazyload this since not everyone is going to be using eslint:all but they would still endup paying the price for a whole directory scan at load time.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't this only get loaded if they have it configured?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah. sorry I dint see the require on the other end.

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