Skip to content
Permalink
Browse files

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

  • Loading branch information...
mysticatea committed Apr 9, 2019
1 parent cbdee62 commit ea25be21ee4350674a33000472215095cfa1a4ec
Showing with 9,695 additions and 6,916 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. +2 −2 lib/api.js
  6. +3 −2 lib/built-in-rules-index.js
  7. +483 −338 lib/cli-engine.js
  8. +393 −0 lib/cli-engine/cascading-config-array-factory.js
  9. +896 −0 lib/cli-engine/config-array-factory.js
  10. +445 −0 lib/cli-engine/config-array/config-array.js
  11. +104 −0 lib/cli-engine/config-array/config-dependency.js
  12. +98 −0 lib/cli-engine/config-array/extracted-config.js
  13. +18 −0 lib/cli-engine/config-array/index.js
  14. +177 −0 lib/cli-engine/config-array/override-tester.js
  15. +459 −0 lib/cli-engine/file-enumerator.js
  16. +1 −1 lib/cli.js
  17. +0 −388 lib/config.js
  18. +1 −1 lib/config/autoconfig.js
  19. +0 −130 lib/config/config-cache.js
  20. +3 −461 lib/config/config-file.js
  21. +13 −25 lib/config/config-initializer.js
  22. +0 −271 lib/config/config-ops.js
  23. +3 −6 lib/config/config-rule.js
  24. +60 −18 lib/config/config-validator.js
  25. +0 −84 lib/config/environments.js
  26. +0 −175 lib/config/plugins.js
  27. +230 −106 lib/linter.js
  28. +2 −2 lib/load-rules.js
  29. +13 −20 lib/rules.js
  30. +6 −6 lib/testers/rule-tester.js
  31. +0 −144 lib/util/file-finder.js
  32. +0 −285 lib/util/glob-utils.js
  33. +0 −63 lib/util/glob.js
  34. +24 −46 lib/util/ignored-paths.js
  35. +16 −20 lib/util/lint-result-cache.js
  36. +3 −13 lib/util/naming.js
  37. +0 −72 lib/util/path-utils.js
  38. +21 −10 lib/util/relative-module-resolver.js
  39. +2 −2 lib/util/report-translator.js
  40. +21 −32 lib/util/source-code-utils.js
  41. +126 −0 lib/util/types.js
  42. +1 −1 messages/file-not-found.txt
  43. +1 −1 messages/no-config-found.txt
  44. +1 −1 messages/plugin-missing.txt
  45. +4 −2 package.json
  46. +1 −1 tests/bench/bench.js
  47. +5 −0 tests/fixtures/config-file/extends-chain-2/parser.js
  48. +1 −1 tests/fixtures/config-file/js/node_modules/foo/index.js
  49. +1 −1 tests/fixtures/configurations/plugins-with-prefix-and-namespace.json
  50. +1 −1 tests/fixtures/configurations/plugins-without-prefix-with-namespace.json
  51. +279 −56 tests/lib/cli-engine.js
  52. +507 −0 tests/lib/cli-engine/_utils.js
  53. +1,224 −0 tests/lib/cli-engine/cascading-config-array-factory.js
  54. +2,185 −0 tests/lib/cli-engine/config-array-factory.js
  55. +724 −0 tests/lib/cli-engine/config-array/config-array.js
  56. +92 −0 tests/lib/cli-engine/config-array/config-dependency.js
  57. +139 −0 tests/lib/cli-engine/config-array/extracted-config.js
  58. +254 −0 tests/lib/cli-engine/config-array/override-tester.js
  59. +454 −0 tests/lib/cli-engine/file-enumerator.js
  60. +15 −15 tests/lib/cli.js
  61. +1 −1 tests/lib/code-path-analysis/code-path-analyzer.js
  62. +1 −1 tests/lib/code-path-analysis/code-path.js
  63. +0 −1,373 tests/lib/config.js
  64. +2 −766 tests/lib/config/config-file.js
  65. +13 −17 tests/lib/config/config-initializer.js
  66. +0 −678 tests/lib/config/config-ops.js
  67. +2 −2 tests/lib/config/config-rule.js
  68. +50 −52 tests/lib/config/config-validator.js
  69. +0 −69 tests/lib/config/environments.js
  70. +0 −238 tests/lib/config/plugins.js
  71. +1 −14 tests/lib/linter.js
  72. +1 −1 tests/lib/load-rules.js
  73. +3 −4 tests/lib/rules.js
  74. +1 −1 tests/lib/util/ast-utils.js
  75. +0 −177 tests/lib/util/file-finder.js
  76. +0 −414 tests/lib/util/glob-utils.js
  77. +16 −134 tests/lib/util/ignored-paths.js
  78. +18 −29 tests/lib/util/lint-result-cache.js
  79. +49 −18 tests/lib/util/npm-utils.js
  80. +0 −93 tests/lib/util/path-utils.js
  81. +2 −12 tests/lib/util/source-code-utils.js
  82. +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");

@@ -871,7 +871,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 };
@@ -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")
};
}));

0 comments on commit ea25be2

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