Skip to content

Commit

Permalink
Breaking: Remove extra rules from eslint:recommended (fixes #10873) (#…
Browse files Browse the repository at this point in the history
…11357)

Only explicitly recommended rules will be exported in eslint:recommended configuration.
  • Loading branch information
platinumazure authored and not-an-aardvark committed Apr 1, 2019
1 parent 2543f11 commit be83322
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 4 deletions.
9 changes: 6 additions & 3 deletions conf/eslint-recommended.js
Expand Up @@ -9,7 +9,10 @@
const builtInRules = require("../lib/built-in-rules-index");

module.exports = {
rules: Object.assign({}, ...Object.keys(builtInRules).map(ruleId => ({
[ruleId]: builtInRules[ruleId].meta.docs.recommended ? "error" : "off"
})))
rules: Object.assign(
{},
...Object.keys(builtInRules)
.filter(ruleId => builtInRules[ruleId].meta.docs.recommended)
.map(ruleId => ({ [ruleId]: "error" }))
)
};
24 changes: 24 additions & 0 deletions tests/conf/eslint-recommended.js
@@ -0,0 +1,24 @@
/**
* @fileoverview Tests for eslint:recommended.
* @author Kevin Partington
*/

"use strict";

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

const assert = require("chai").assert;
const eslintRecommended = require("../../conf/eslint-recommended");
const rules = eslintRecommended.rules;

describe("eslint-recommended", () => {
it("should configure recommended rules as error", () => {
assert.strictEqual(rules["no-undef"], "error");
});

it("should not configure non-recommended rules", () => {
assert.notProperty(rules, "camelcase");
});
});
2 changes: 1 addition & 1 deletion tests/lib/cli-engine.js
Expand Up @@ -1532,7 +1532,7 @@ describe("CLIEngine", () => {

const report = engine.executeOnFiles(["lib/cli*.js"]);

assert.deepStrictEqual(
assert.sameDeepMembers(
report.usedDeprecatedRules,
[
{ ruleId: "indent-legacy", replacedBy: ["indent"] },
Expand Down

0 comments on commit be83322

Please sign in to comment.