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

Breaking: fix config loading (fixes #11510, fixes #11559, fixes #11586) #11546

Merged
merged 53 commits into from May 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
ea25be2
Breaking: fix config loading (fixes #11510, fixes #11559, fixes #11586)
mysticatea Apr 9, 2019
ef57db3
fix typo
platinumazure Apr 11, 2019
69566ee
clarify a magic number
platinumazure Apr 11, 2019
8157464
correct a comment
platinumazure Apr 11, 2019
d96176f
correct a test description
platinumazure Apr 11, 2019
11f293d
fix typo
platinumazure Apr 11, 2019
f6eb5fa
fix typo
platinumazure Apr 11, 2019
d6538e7
fix typo
platinumazure Apr 11, 2019
f51d2c0
fix a copy/paste mistake
platinumazure Apr 11, 2019
bedce88
fix typo
platinumazure Apr 11, 2019
95d3dc2
remove "a.js" from getConfigForFile (https://github.com/eslint/eslint…
mysticatea Apr 12, 2019
6a13317
remove commented out debug.enabled=true
mysticatea Apr 12, 2019
fa671b8
fix CascadingConfigArrayFactoryOptions#cliConfig comment
mysticatea Apr 12, 2019
e743a71
originalEnabled → originalDebugEnabled
mysticatea Apr 12, 2019
ef65825
fix a test description (https://github.com/eslint/eslint/pull/11546#d…
mysticatea Apr 12, 2019
c1f7075
remove "Moved from *" groups
mysticatea Apr 12, 2019
80d55d6
Inmemory → InMemory
mysticatea Apr 12, 2019
41f0d91
remove JSON.stringify(files) from test subjects
mysticatea Apr 12, 2019
f8e3102
remove shadowing variables
mysticatea Apr 12, 2019
3df21e8
update wrong JSDoc comment
mysticatea Apr 12, 2019
f8f6950
remove a workaround for Node 6
mysticatea Apr 12, 2019
d1c2752
make `factory` instance unique for each test case
mysticatea Apr 12, 2019
75c5157
add a test case for `root`
mysticatea Apr 12, 2019
8a2772e
fix a test case more readable
mysticatea Apr 12, 2019
6ea6c1e
improve tests for JSON.stringify and console.log
mysticatea Apr 12, 2019
6f97db3
Merge branch 'master' into issue11510
mysticatea Apr 13, 2019
db764bb
Merge branch 'master' into issue11510
mysticatea Apr 25, 2019
45f724e
Merge branch 'master' into issue11510
mysticatea Apr 27, 2019
5bc6da0
fix typo
mysticatea May 9, 2019
abdea3e
"on" → "in" in a comment
mysticatea May 9, 2019
c04ead2
Merge branch 'master' into issue11510
mysticatea May 9, 2019
511da78
change `verifyText` parameter to an object
mysticatea May 9, 2019
6a3c384
add a comment about `basename` and `resultFilePath`
mysticatea May 9, 2019
bfc25ec
simplify `dirSuffix`
mysticatea May 9, 2019
57774b4
"on" → "in" in an error message
mysticatea May 9, 2019
49d1461
remove the default value from `CascadingConfigArrayFactory#getConfigA…
mysticatea May 9, 2019
bdb3123
freeze cached config arrays
mysticatea May 9, 2019
4fae2b2
"*OnDirectory" → "*InDirectory"
mysticatea May 9, 2019
3447120
normalize plugins in `_loadPlugin` method
mysticatea May 9, 2019
6f5269b
rename placeholder filename
mysticatea May 9, 2019
b5c0285
remove unnecessary `if` for local plugins
mysticatea May 9, 2019
396ff47
add more check for __proto__
mysticatea May 9, 2019
55fd2da
"mergeRules" → "mergeRuleConfigs"
mysticatea May 9, 2019
5a2453d
"root" → "isRoot()"
mysticatea May 9, 2019
f8cd098
add assertion for basePath in OverrideTester.and()
mysticatea May 9, 2019
bc23404
Update lib/config/config-initializer.js
mysticatea May 9, 2019
eb5164a
"builtInRules.keys()" → "builtInRules.entries()"
mysticatea May 9, 2019
810dd77
"Function.prototype" → "noop"
mysticatea May 9, 2019
fb5c29a
remove unnecessary lodash.cloneDeep
mysticatea May 9, 2019
a852b02
fix about `<text>`
mysticatea May 9, 2019
1fda3f2
fix `getConfigForFile()` to require an argument
mysticatea May 9, 2019
40925c0
`builtInRules.entries()` → `builtInRules`
mysticatea May 9, 2019
fcf8228
update migration guide
mysticatea May 9, 2019
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
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")
};
}));