diff --git a/conf/category-list.json b/conf/category-list.json
deleted file mode 100644
index cd3b816b..00000000
--- a/conf/category-list.json
+++ /dev/null
@@ -1,39 +0,0 @@
-{
- "categories": [
- { "name": "Possible Errors", "description": "These rules relate to possible syntax or logic errors in JavaScript code:" },
- { "name": "Best Practices", "description": "These rules relate to better ways of doing things to help you avoid problems:" },
- { "name": "Strict Mode", "description": "These rules relate to strict mode directives:" },
- { "name": "Variables", "description": "These rules relate to variable declarations:" },
- { "name": "Stylistic Issues", "description": "These rules relate to style guidelines, and are therefore quite subjective:" },
- { "name": "ECMAScript 6", "description": "These rules relate to ES6, also known as ES2015:" }
- ],
- "deprecated": {
- "name": "Deprecated",
- "description": "These rules have been deprecated in accordance with the deprecation policy, and replaced by newer rules:",
- "rules": []
- },
- "removed": {
- "name": "Removed",
- "description": "These rules from older versions of ESLint (before the deprecation policy existed) have been replaced by newer rules:",
- "rules": [
- { "removed": "generator-star", "replacedBy": ["generator-star-spacing"] },
- { "removed": "global-strict", "replacedBy": ["strict"] },
- { "removed": "no-arrow-condition", "replacedBy": ["no-confusing-arrow", "no-constant-condition"] },
- { "removed": "no-comma-dangle", "replacedBy": ["comma-dangle"] },
- { "removed": "no-empty-class", "replacedBy": ["no-empty-character-class"] },
- { "removed": "no-empty-label", "replacedBy": ["no-labels"] },
- { "removed": "no-extra-strict", "replacedBy": ["strict"] },
- { "removed": "no-reserved-keys", "replacedBy": ["quote-props"] },
- { "removed": "no-space-before-semi", "replacedBy": ["semi-spacing"] },
- { "removed": "no-wrap-func", "replacedBy": ["no-extra-parens"] },
- { "removed": "space-after-function-name", "replacedBy": ["space-before-function-paren"] },
- { "removed": "space-after-keywords", "replacedBy": ["keyword-spacing"] },
- { "removed": "space-before-function-parentheses", "replacedBy": ["space-before-function-paren"] },
- { "removed": "space-before-keywords", "replacedBy": ["keyword-spacing"] },
- { "removed": "space-in-brackets", "replacedBy": ["object-curly-spacing", "array-bracket-spacing"] },
- { "removed": "space-return-throw-case", "replacedBy": ["keyword-spacing"] },
- { "removed": "space-unary-word-ops", "replacedBy": ["space-unary-ops"] },
- { "removed": "spaced-line-comment", "replacedBy": ["spaced-comment"] }
- ]
- }
-}
diff --git a/conf/default-cli-options.js b/conf/default-cli-options.js
deleted file mode 100644
index e09a829d..00000000
--- a/conf/default-cli-options.js
+++ /dev/null
@@ -1,31 +0,0 @@
-/**
- * @fileoverview Default CLIEngineOptions.
- * @author Ian VanSchooten
- */
-
-"use strict";
-
-module.exports = {
- configFile: null,
- baseConfig: false,
- rulePaths: [],
- useEslintrc: true,
- envs: [],
- globals: [],
- extensions: null,
- ignore: true,
- ignorePath: void 0,
- cache: false,
-
- /*
- * in order to honor the cacheFile option if specified
- * this option should not have a default value otherwise
- * it will always be used
- */
- cacheLocation: "",
- cacheFile: ".eslintcache",
- fix: false,
- allowInlineConfig: true,
- reportUnusedDisableDirectives: void 0,
- globInputPaths: true
-};
diff --git a/conf/eslint-all.js b/conf/eslint-all.js
deleted file mode 100644
index cdd8a3e4..00000000
--- a/conf/eslint-all.js
+++ /dev/null
@@ -1,32 +0,0 @@
-/**
- * @fileoverview Config to enable all rules.
- * @author Robert Fletcher
- */
-
-"use strict";
-
-//------------------------------------------------------------------------------
-// Requirements
-//------------------------------------------------------------------------------
-
-// FIXME: "../lib/rules" doesn't exist in this package
-const builtInRules = require("../lib/rules");
-
-//------------------------------------------------------------------------------
-// Helpers
-//------------------------------------------------------------------------------
-
-const allRules = {};
-
-for (const [ruleId, rule] of builtInRules) {
- if (!rule.meta.deprecated) {
- allRules[ruleId] = "error";
- }
-}
-
-//------------------------------------------------------------------------------
-// Public Interface
-//------------------------------------------------------------------------------
-
-/** @type {import("../lib/shared/types").ConfigData} */
-module.exports = { rules: allRules };
diff --git a/conf/eslint-recommended.js b/conf/eslint-recommended.js
deleted file mode 100644
index 2137685f..00000000
--- a/conf/eslint-recommended.js
+++ /dev/null
@@ -1,72 +0,0 @@
-/**
- * @fileoverview Configuration applied when a user configuration extends from
- * eslint:recommended.
- * @author Nicholas C. Zakas
- */
-
-"use strict";
-
-/* eslint sort-keys: ["error", "asc"] */
-
-/** @type {import("../lib/shared/types").ConfigData} */
-module.exports = {
- rules: {
- "constructor-super": "error",
- "for-direction": "error",
- "getter-return": "error",
- "no-async-promise-executor": "error",
- "no-case-declarations": "error",
- "no-class-assign": "error",
- "no-compare-neg-zero": "error",
- "no-cond-assign": "error",
- "no-const-assign": "error",
- "no-constant-condition": "error",
- "no-control-regex": "error",
- "no-debugger": "error",
- "no-delete-var": "error",
- "no-dupe-args": "error",
- "no-dupe-class-members": "error",
- "no-dupe-else-if": "error",
- "no-dupe-keys": "error",
- "no-duplicate-case": "error",
- "no-empty": "error",
- "no-empty-character-class": "error",
- "no-empty-pattern": "error",
- "no-ex-assign": "error",
- "no-extra-boolean-cast": "error",
- "no-extra-semi": "error",
- "no-fallthrough": "error",
- "no-func-assign": "error",
- "no-global-assign": "error",
- "no-import-assign": "error",
- "no-inner-declarations": "error",
- "no-invalid-regexp": "error",
- "no-irregular-whitespace": "error",
- "no-misleading-character-class": "error",
- "no-mixed-spaces-and-tabs": "error",
- "no-new-symbol": "error",
- "no-obj-calls": "error",
- "no-octal": "error",
- "no-prototype-builtins": "error",
- "no-redeclare": "error",
- "no-regex-spaces": "error",
- "no-self-assign": "error",
- "no-setter-return": "error",
- "no-shadow-restricted-names": "error",
- "no-sparse-arrays": "error",
- "no-this-before-super": "error",
- "no-undef": "error",
- "no-unexpected-multiline": "error",
- "no-unreachable": "error",
- "no-unsafe-finally": "error",
- "no-unsafe-negation": "error",
- "no-unused-labels": "error",
- "no-unused-vars": "error",
- "no-useless-catch": "error",
- "no-useless-escape": "error",
- "no-with": "error",
- "require-yield": "error",
- "use-isnan": "error",
- "valid-typeof": "error"
- }
-};
diff --git a/conf/replacements.json b/conf/replacements.json
deleted file mode 100644
index c047811e..00000000
--- a/conf/replacements.json
+++ /dev/null
@@ -1,22 +0,0 @@
-{
- "rules": {
- "generator-star": ["generator-star-spacing"],
- "global-strict": ["strict"],
- "no-arrow-condition": ["no-confusing-arrow", "no-constant-condition"],
- "no-comma-dangle": ["comma-dangle"],
- "no-empty-class": ["no-empty-character-class"],
- "no-empty-label": ["no-labels"],
- "no-extra-strict": ["strict"],
- "no-reserved-keys": ["quote-props"],
- "no-space-before-semi": ["semi-spacing"],
- "no-wrap-func": ["no-extra-parens"],
- "space-after-function-name": ["space-before-function-paren"],
- "space-after-keywords": ["keyword-spacing"],
- "space-before-function-parentheses": ["space-before-function-paren"],
- "space-before-keywords": ["keyword-spacing"],
- "space-in-brackets": ["object-curly-spacing", "array-bracket-spacing", "computed-property-spacing"],
- "space-return-throw-case": ["keyword-spacing"],
- "space-unary-word-ops": ["space-unary-ops"],
- "spaced-line-comment": ["spaced-comment"]
- }
-}
diff --git a/lib/cascading-config-array-factory.js b/lib/cascading-config-array-factory.js
index a6933964..5f0da057 100644
--- a/lib/cascading-config-array-factory.js
+++ b/lib/cascading-config-array-factory.js
@@ -36,9 +36,10 @@ const debug = require("debug")("eslintrc:cascading-config-array-factory");
//------------------------------------------------------------------------------
// Define types for VSCode IntelliSense.
-/** @typedef {import("../shared/types").ConfigData} ConfigData */
-/** @typedef {import("../shared/types").Parser} Parser */
-/** @typedef {import("../shared/types").Plugin} Plugin */
+/** @typedef {import("./shared/types").ConfigData} ConfigData */
+/** @typedef {import("./shared/types").Parser} Parser */
+/** @typedef {import("./shared/types").Plugin} Plugin */
+/** @typedef {import("./shared/types").Rule} Rule */
/** @typedef {ReturnType} ConfigArray */
/**
@@ -51,6 +52,11 @@ const debug = require("debug")("eslintrc:cascading-config-array-factory");
* @property {string[]} [rulePaths] The value of `--rulesdir` option.
* @property {string} [specificConfigPath] The value of `--config` option.
* @property {boolean} [useEslintrc] if `false` then it doesn't load config files.
+ * @property {Function} loadRules The function to use to load rules.
+ * @property {Map} builtInRules The rules that are built in to ESLint.
+ * @property {Object} [resolver=ModuleResolver] The module resolver object.
+ * @property {string} eslintAllPath The path to the definitions for eslint:all.
+ * @property {string} eslintRecommendedPath The path to the definitions for eslint:recommended.
*/
/**
@@ -67,6 +73,11 @@ const debug = require("debug")("eslintrc:cascading-config-array-factory");
* @property {string[]|null} rulePaths The value of `--rulesdir` option. This is used to reset `baseConfigArray`.
* @property {string|null} specificConfigPath The value of `--config` option. This is used to reset `cliConfigArray`.
* @property {boolean} useEslintrc if `false` then it doesn't load config files.
+ * @property {Function} loadRules The function to use to load rules.
+ * @property {Map} builtInRules The rules that are built in to ESLint.
+ * @property {Object} [resolver=ModuleResolver] The module resolver object.
+ * @property {string} eslintAllPath The path to the definitions for eslint:all.
+ * @property {string} eslintRecommendedPath The path to the definitions for eslint:recommended.
*/
/** @type {WeakMap} */
@@ -205,14 +216,18 @@ class CascadingConfigArrayFactory {
useEslintrc = true,
builtInRules = new Map(),
loadRules,
- resolver
+ resolver,
+ eslintRecommendedPath,
+ eslintAllPath
} = {}) {
const configArrayFactory = new ConfigArrayFactory({
additionalPluginPool,
cwd,
resolvePluginsRelativeTo,
builtInRules,
- resolver
+ resolver,
+ eslintRecommendedPath,
+ eslintAllPath
});
internalSlotsMap.set(this, {
diff --git a/lib/config-array-factory.js b/lib/config-array-factory.js
index 97f8b5cb..6494a041 100644
--- a/lib/config-array-factory.js
+++ b/lib/config-array-factory.js
@@ -58,8 +58,6 @@ const debug = require("debug")("eslintrc:config-array-factory");
// Helpers
//------------------------------------------------------------------------------
-const eslintRecommendedPath = path.resolve(__dirname, "../../eslint/conf/eslint-recommended.js");
-const eslintAllPath = path.resolve(__dirname, "../../eslint/conf/eslint-all.js");
const configFilenames = [
".eslintrc.js",
".eslintrc.cjs",
@@ -71,10 +69,11 @@ const configFilenames = [
];
// Define types for VSCode IntelliSense.
-/** @typedef {import("../shared/types").ConfigData} ConfigData */
-/** @typedef {import("../shared/types").OverrideConfigData} OverrideConfigData */
-/** @typedef {import("../shared/types").Parser} Parser */
-/** @typedef {import("../shared/types").Plugin} Plugin */
+/** @typedef {import("./shared/types").ConfigData} ConfigData */
+/** @typedef {import("./shared/types").OverrideConfigData} OverrideConfigData */
+/** @typedef {import("./shared/types").Parser} Parser */
+/** @typedef {import("./shared/types").Plugin} Plugin */
+/** @typedef {import("./shared/types").Rule} Rule */
/** @typedef {import("./config-array/config-dependency").DependentParser} DependentParser */
/** @typedef {import("./config-array/config-dependency").DependentPlugin} DependentPlugin */
/** @typedef {ConfigArray[0]} ConfigArrayElement */
@@ -84,6 +83,10 @@ const configFilenames = [
* @property {Map} [additionalPluginPool] The map for additional plugins.
* @property {string} [cwd] The path to the current working directory.
* @property {string} [resolvePluginsRelativeTo] A path to the directory that plugins should be resolved from. Defaults to `cwd`.
+ * @property {Map} builtInRules The rules that are built in to ESLint.
+ * @property {Object} [resolver=ModuleResolver] The module resolver object.
+ * @property {string} eslintAllPath The path to the definitions for eslint:all.
+ * @property {string} eslintRecommendedPath The path to the definitions for eslint:recommended.
*/
/**
@@ -91,6 +94,10 @@ const configFilenames = [
* @property {Map} additionalPluginPool The map for additional plugins.
* @property {string} cwd The path to the current working directory.
* @property {string | undefined} resolvePluginsRelativeTo An absolute path the the directory that plugins should be resolved from.
+ * @property {Map} builtInRules The rules that are built in to ESLint.
+ * @property {Object} [resolver=ModuleResolver] The module resolver object.
+ * @property {string} eslintAllPath The path to the definitions for eslint:all.
+ * @property {string} eslintRecommendedPath The path to the definitions for eslint:recommended.
*/
/**
@@ -414,7 +421,9 @@ class ConfigArrayFactory {
cwd = process.cwd(),
resolvePluginsRelativeTo,
builtInRules,
- resolver = ModuleResolver
+ resolver = ModuleResolver,
+ eslintAllPath,
+ eslintRecommendedPath
} = {}) {
internalSlotsMap.set(this, {
additionalPluginPool,
@@ -423,7 +432,9 @@ class ConfigArrayFactory {
resolvePluginsRelativeTo &&
path.resolve(cwd, resolvePluginsRelativeTo),
builtInRules,
- resolver
+ resolver,
+ eslintAllPath,
+ eslintRecommendedPath
});
}
@@ -781,6 +792,8 @@ class ConfigArrayFactory {
* @private
*/
_loadExtendedBuiltInConfig(extendName, ctx) {
+ const { eslintAllPath, eslintRecommendedPath } = internalSlotsMap.get(this);
+
if (extendName === "eslint:recommended") {
return this._loadConfigData({
...ctx,
diff --git a/lib/shared/types.js b/lib/shared/types.js
new file mode 100644
index 00000000..d4ac14e2
--- /dev/null
+++ b/lib/shared/types.js
@@ -0,0 +1,150 @@
+/**
+ * @fileoverview Define common types for input completion.
+ * @author Toru Nagashima
+ */
+"use strict";
+
+/** @type {any} */
+module.exports = {};
+
+/** @typedef {boolean | "off" | "readable" | "readonly" | "writable" | "writeable"} GlobalConf */
+/** @typedef {0 | 1 | 2 | "off" | "warn" | "error"} SeverityConf */
+/** @typedef {SeverityConf | [SeverityConf, ...any[]]} RuleConf */
+
+/**
+ * @typedef {Object} EcmaFeatures
+ * @property {boolean} [globalReturn] Enabling `return` statements at the top-level.
+ * @property {boolean} [jsx] Enabling JSX syntax.
+ * @property {boolean} [impliedStrict] Enabling strict mode always.
+ */
+
+/**
+ * @typedef {Object} ParserOptions
+ * @property {EcmaFeatures} [ecmaFeatures] The optional features.
+ * @property {3|5|6|7|8|9|10|11|12|2015|2016|2017|2018|2019|2020|2021} [ecmaVersion] The ECMAScript version (or revision number).
+ * @property {"script"|"module"} [sourceType] The source code type.
+ */
+
+/**
+ * @typedef {Object} ConfigData
+ * @property {Record} [env] The environment settings.
+ * @property {string | string[]} [extends] The path to other config files or the package name of shareable configs.
+ * @property {Record} [globals] The global variable settings.
+ * @property {string | string[]} [ignorePatterns] The glob patterns that ignore to lint.
+ * @property {boolean} [noInlineConfig] The flag that disables directive comments.
+ * @property {OverrideConfigData[]} [overrides] The override settings per kind of files.
+ * @property {string} [parser] The path to a parser or the package name of a parser.
+ * @property {ParserOptions} [parserOptions] The parser options.
+ * @property {string[]} [plugins] The plugin specifiers.
+ * @property {string} [processor] The processor specifier.
+ * @property {boolean} [reportUnusedDisableDirectives] The flag to report unused `eslint-disable` comments.
+ * @property {boolean} [root] The root flag.
+ * @property {Record} [rules] The rule settings.
+ * @property {Object} [settings] The shared settings.
+ */
+
+/**
+ * @typedef {Object} OverrideConfigData
+ * @property {Record} [env] The environment settings.
+ * @property {string | string[]} [excludedFiles] The glob pattarns for excluded files.
+ * @property {string | string[]} [extends] The path to other config files or the package name of shareable configs.
+ * @property {string | string[]} files The glob patterns for target files.
+ * @property {Record} [globals] The global variable settings.
+ * @property {boolean} [noInlineConfig] The flag that disables directive comments.
+ * @property {OverrideConfigData[]} [overrides] The override settings per kind of files.
+ * @property {string} [parser] The path to a parser or the package name of a parser.
+ * @property {ParserOptions} [parserOptions] The parser options.
+ * @property {string[]} [plugins] The plugin specifiers.
+ * @property {string} [processor] The processor specifier.
+ * @property {boolean} [reportUnusedDisableDirectives] The flag to report unused `eslint-disable` comments.
+ * @property {Record} [rules] The rule settings.
+ * @property {Object} [settings] The shared settings.
+ */
+
+/**
+ * @typedef {Object} ParseResult
+ * @property {Object} ast The AST.
+ * @property {ScopeManager} [scopeManager] The scope manager of the AST.
+ * @property {Record} [services] The services that the parser provides.
+ * @property {Record} [visitorKeys] The visitor keys of the AST.
+ */
+
+/**
+ * @typedef {Object} Parser
+ * @property {(text:string, options:ParserOptions) => Object} parse The definition of global variables.
+ * @property {(text:string, options:ParserOptions) => ParseResult} [parseForESLint] The parser options that will be enabled under this environment.
+ */
+
+/**
+ * @typedef {Object} Environment
+ * @property {Record} [globals] The definition of global variables.
+ * @property {ParserOptions} [parserOptions] The parser options that will be enabled under this environment.
+ */
+
+/**
+ * @typedef {Object} LintMessage
+ * @property {number} column The 1-based column number.
+ * @property {number} [endColumn] The 1-based column number of the end location.
+ * @property {number} [endLine] The 1-based line number of the end location.
+ * @property {boolean} fatal If `true` then this is a fatal error.
+ * @property {{range:[number,number], text:string}} [fix] Information for autofix.
+ * @property {number} line The 1-based line number.
+ * @property {string} message The error message.
+ * @property {string|null} ruleId The ID of the rule which makes this message.
+ * @property {0|1|2} severity The severity of this message.
+ * @property {Array<{desc?: string, messageId?: string, fix: {range: [number, number], text: string}}>} [suggestions] Information for suggestions.
+ */
+
+/**
+ * @typedef {Object} SuggestionResult
+ * @property {string} desc A short description.
+ * @property {string} [messageId] Id referencing a message for the description.
+ * @property {{ text: string, range: number[] }} fix fix result info
+ */
+
+/**
+ * @typedef {Object} Processor
+ * @property {(text:string, filename:string) => Array} [preprocess] The function to extract code blocks.
+ * @property {(messagesList:LintMessage[][], filename:string) => LintMessage[]} [postprocess] The function to merge messages.
+ * @property {boolean} [supportsAutofix] If `true` then it means the processor supports autofix.
+ */
+
+/**
+ * @typedef {Object} RuleMetaDocs
+ * @property {string} category The category of the rule.
+ * @property {string} description The description of the rule.
+ * @property {boolean} recommended If `true` then the rule is included in `eslint:recommended` preset.
+ * @property {string} url The URL of the rule documentation.
+ */
+
+/**
+ * @typedef {Object} RuleMeta
+ * @property {boolean} [deprecated] If `true` then the rule has been deprecated.
+ * @property {RuleMetaDocs} docs The document information of the rule.
+ * @property {"code"|"whitespace"} [fixable] The autofix type.
+ * @property {Record} [messages] The messages the rule reports.
+ * @property {string[]} [replacedBy] The IDs of the alternative rules.
+ * @property {Array|Object} schema The option schema of the rule.
+ * @property {"problem"|"suggestion"|"layout"} type The rule type.
+ */
+
+/**
+ * @typedef {Object} Rule
+ * @property {Function} create The factory of the rule.
+ * @property {RuleMeta} meta The meta data of the rule.
+ */
+
+/**
+ * @typedef {Object} Plugin
+ * @property {Record} [configs] The definition of plugin configs.
+ * @property {Record} [environments] The definition of plugin environments.
+ * @property {Record} [processors] The definition of plugin processors.
+ * @property {Record} [rules] The definition of plugin rules.
+ */
+
+/**
+ * Information of deprecated rules.
+ * @typedef {Object} DeprecatedRuleInfo
+ * @property {string} ruleId The rule ID.
+ * @property {string[]} replacedBy The rule IDs that replace this deprecated rule.
+ */