Skip to content

Commit

Permalink
Breaking: fix config loading (fixes #11510, fixes #11559, fixes #11586)…
Browse files Browse the repository at this point in the history
… (#11546)
  • Loading branch information
mysticatea committed May 10, 2019
1 parent bc0819c commit 6ae21a4
Show file tree
Hide file tree
Showing 83 changed files with 9,846 additions and 6,926 deletions.
4 changes: 2 additions & 2 deletions Makefile.js
Expand Up @@ -26,7 +26,7 @@ const lodash = require("lodash"),
ejs = require("ejs"),
loadPerf = require("load-perf"),
yaml = require("js-yaml"),
CLIEngine = require("./lib/cli-engine");
{ CLIEngine } = require("./lib/cli-engine");

const { cat, cd, cp, echo, exec, exit, find, ls, mkdir, pwd, rm, test } = require("shelljs");

Expand Down Expand Up @@ -849,7 +849,7 @@ target.checkRuleFiles = function() {
// check parity between rules index file and rules directory
const builtInRulesIndexPath = "./lib/built-in-rules-index";
const ruleIdsInIndex = require(builtInRulesIndexPath);
const ruleEntryFromIndexIsMissing = !(basename in ruleIdsInIndex);
const ruleEntryFromIndexIsMissing = !ruleIdsInIndex.has(basename);

if (ruleEntryFromIndexIsMissing) {
console.error(`Missing rule from index (${builtInRulesIndexPath}.js): ${basename}. If you just added a ` +
Expand Down
5 changes: 3 additions & 2 deletions conf/environments.js
Expand Up @@ -14,7 +14,8 @@ const globals = require("globals");
// Public Interface
//------------------------------------------------------------------------------

module.exports = {
/** @type {Map<string, import("../lib/util/types").Environment>} */
module.exports = new Map(Object.entries({
builtin: {
globals: globals.es5
},
Expand Down Expand Up @@ -106,4 +107,4 @@ module.exports = {
greasemonkey: {
globals: globals.greasemonkey
}
};
}));
14 changes: 8 additions & 6 deletions conf/eslint-all.js
Expand Up @@ -15,15 +15,17 @@ const builtInRules = require("../lib/built-in-rules-index");
// Helpers
//------------------------------------------------------------------------------

const enabledRules = Object.keys(builtInRules).reduce((result, ruleId) => {
if (!builtInRules[ruleId].meta.deprecated) {
result[ruleId] = "error";
const allRules = {};

for (const [ruleId, rule] of builtInRules) {
if (!rule.meta.deprecated) {
allRules[ruleId] = "error";
}
return result;
}, {});
}

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

module.exports = { rules: enabledRules };
/** @type {import("../lib/util/types").ConfigData} */
module.exports = { rules: allRules };
17 changes: 9 additions & 8 deletions conf/eslint-recommended.js
Expand Up @@ -7,12 +7,13 @@
"use strict";

const builtInRules = require("../lib/built-in-rules-index");
const recommendedRules = {};

module.exports = {
rules: Object.assign(
{},
...Object.keys(builtInRules)
.filter(ruleId => builtInRules[ruleId].meta.docs.recommended)
.map(ruleId => ({ [ruleId]: "error" }))
)
};
for (const [ruleId, rule] of builtInRules) {
if (rule.meta.docs.recommended) {
recommendedRules[ruleId] = "error";
}
}

/** @type {import("../lib/util/types").ConfigData} */
module.exports = { rules: recommendedRules };
2 changes: 0 additions & 2 deletions docs/user-guide/migrating-to-6.0.0.md
Expand Up @@ -180,8 +180,6 @@ Due to a bug, the glob patterns in a `files` list in an `overrides` section of a

## <a name="overrides-precedence"></a> Overrides in an extended config file can now be overridden by a parent config file

**Note:** This update is planned, but has not been implemented in the latest alpha release yet.

Due to a bug, it was previously the case that an `overrides` block in a shareable config had precedence over the top level of a parent config. For example, with the following config setup, the `semi` rule would end up enabled even though it was explicitly disabled in the end user's config:

```js
Expand Down
4 changes: 2 additions & 2 deletions lib/api.js
Expand Up @@ -5,11 +5,11 @@

"use strict";

const Linter = require("./linter");
const { Linter } = require("./linter");

module.exports = {
Linter,
CLIEngine: require("./cli-engine"),
CLIEngine: require("./cli-engine").CLIEngine,
RuleTester: require("./testers/rule-tester"),
SourceCode: require("./util/source-code")
};
Expand Down
5 changes: 3 additions & 2 deletions lib/built-in-rules-index.js
Expand Up @@ -8,7 +8,8 @@

/* eslint sort-keys: ["error", "asc"] */

module.exports = {
/** @type {Map<string, import("./util/types").Rule>} */
module.exports = new Map(Object.entries({
"accessor-pairs": require("./rules/accessor-pairs"),
"array-bracket-newline": require("./rules/array-bracket-newline"),
"array-bracket-spacing": require("./rules/array-bracket-spacing"),
Expand Down Expand Up @@ -275,4 +276,4 @@ module.exports = {
"wrap-regex": require("./rules/wrap-regex"),
"yield-star-spacing": require("./rules/yield-star-spacing"),
yoda: require("./rules/yoda")
};
}));

0 comments on commit 6ae21a4

Please sign in to comment.