Skip to content
Permalink
Browse files

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

… (#11546)
  • Loading branch information...
mysticatea committed May 10, 2019
1 parent bc0819c commit 6ae21a4bfe5a1566f787fbad798182a524b96d28
Showing with 9,846 additions and 6,926 deletions.
  1. +2 −2 Makefile.js
  2. +3 −2 conf/environments.js
  3. +8 −6 conf/eslint-all.js
  4. +9 −8 conf/eslint-recommended.js
  5. +0 −2 docs/user-guide/migrating-to-6.0.0.md
  6. +2 −2 lib/api.js
  7. +3 −2 lib/built-in-rules-index.js
  8. +488 −337 lib/cli-engine.js
  9. +403 −0 lib/cli-engine/cascading-config-array-factory.js
  10. +902 −0 lib/cli-engine/config-array-factory.js
  11. +455 −0 lib/cli-engine/config-array/config-array.js
  12. +114 −0 lib/cli-engine/config-array/config-dependency.js
  13. +98 −0 lib/cli-engine/config-array/extracted-config.js
  14. +18 −0 lib/cli-engine/config-array/index.js
  15. +183 −0 lib/cli-engine/config-array/override-tester.js
  16. +457 −0 lib/cli-engine/file-enumerator.js
  17. +1 −1 lib/cli.js
  18. +0 −388 lib/config.js
  19. +1 −1 lib/config/autoconfig.js
  20. +0 −130 lib/config/config-cache.js
  21. +3 −461 lib/config/config-file.js
  22. +13 −25 lib/config/config-initializer.js
  23. +0 −271 lib/config/config-ops.js
  24. +2 −6 lib/config/config-rule.js
  25. +61 −18 lib/config/config-validator.js
  26. +0 −84 lib/config/environments.js
  27. +0 −175 lib/config/plugins.js
  28. +227 −106 lib/linter.js
  29. +2 −2 lib/load-rules.js
  30. +13 −20 lib/rules.js
  31. +6 −6 lib/testers/rule-tester.js
  32. +0 −144 lib/util/file-finder.js
  33. +0 −285 lib/util/glob-utils.js
  34. +0 −63 lib/util/glob.js
  35. +22 −46 lib/util/ignored-paths.js
  36. +16 −20 lib/util/lint-result-cache.js
  37. +3 −13 lib/util/naming.js
  38. +0 −72 lib/util/path-utils.js
  39. +21 −10 lib/util/relative-module-resolver.js
  40. +2 −2 lib/util/report-translator.js
  41. +21 −32 lib/util/source-code-utils.js
  42. +126 −0 lib/util/types.js
  43. +1 −1 messages/file-not-found.txt
  44. +1 −1 messages/no-config-found.txt
  45. +1 −1 messages/plugin-missing.txt
  46. +4 −2 package.json
  47. +1 −1 tests/bench/bench.js
  48. +5 −0 tests/fixtures/config-file/extends-chain-2/parser.js
  49. +1 −1 tests/fixtures/config-file/js/node_modules/foo/index.js
  50. +1 −1 tests/fixtures/configurations/plugins-with-prefix-and-namespace.json
  51. +1 −1 tests/fixtures/configurations/plugins-without-prefix-with-namespace.json
  52. +289 −59 tests/lib/cli-engine.js
  53. +510 −0 tests/lib/cli-engine/_utils.js
  54. +1,215 −0 tests/lib/cli-engine/cascading-config-array-factory.js
  55. +2,238 −0 tests/lib/cli-engine/config-array-factory.js
  56. +728 −0 tests/lib/cli-engine/config-array/config-array.js
  57. +120 −0 tests/lib/cli-engine/config-array/config-dependency.js
  58. +139 −0 tests/lib/cli-engine/config-array/extracted-config.js
  59. +270 −0 tests/lib/cli-engine/config-array/override-tester.js
  60. +454 −0 tests/lib/cli-engine/file-enumerator.js
  61. +15 −15 tests/lib/cli.js
  62. +1 −1 tests/lib/code-path-analysis/code-path-analyzer.js
  63. +1 −1 tests/lib/code-path-analysis/code-path.js
  64. +0 −1,373 tests/lib/config.js
  65. +2 −766 tests/lib/config/config-file.js
  66. +13 −17 tests/lib/config/config-initializer.js
  67. +0 −678 tests/lib/config/config-ops.js
  68. +2 −2 tests/lib/config/config-rule.js
  69. +50 −52 tests/lib/config/config-validator.js
  70. +0 −69 tests/lib/config/environments.js
  71. +0 −238 tests/lib/config/plugins.js
  72. +1 −14 tests/lib/linter.js
  73. +1 −1 tests/lib/load-rules.js
  74. +3 −4 tests/lib/rules.js
  75. +1 −1 tests/lib/util/ast-utils.js
  76. +0 −177 tests/lib/util/file-finder.js
  77. +0 −414 tests/lib/util/glob-utils.js
  78. +16 −134 tests/lib/util/ignored-paths.js
  79. +18 −29 tests/lib/util/lint-result-cache.js
  80. +55 −24 tests/lib/util/npm-utils.js
  81. +0 −93 tests/lib/util/path-utils.js
  82. +2 −12 tests/lib/util/source-code-utils.js
  83. +1 −1 tests/lib/util/source-code.js
@@ -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");

@@ -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 ` +
@@ -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
},
@@ -106,4 +107,4 @@ module.exports = {
greasemonkey: {
globals: globals.greasemonkey
}
};
}));
@@ -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 };
@@ -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 };
@@ -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
@@ -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")
};
@@ -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"),
@@ -275,4 +276,4 @@ module.exports = {
"wrap-regex": require("./rules/wrap-regex"),
"yield-star-spacing": require("./rules/yield-star-spacing"),
yoda: require("./rules/yoda")
};
}));
Oops, something went wrong.

0 comments on commit 6ae21a4

Please sign in to comment.
You can’t perform that action at this time.