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

Update: Allow eslint:all and eslint:recommended paths to be passed in #11

Merged
merged 4 commits into from
Oct 15, 2020
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
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
39 changes: 0 additions & 39 deletions conf/category-list.json

This file was deleted.

31 changes: 0 additions & 31 deletions conf/default-cli-options.js

This file was deleted.

32 changes: 0 additions & 32 deletions conf/eslint-all.js

This file was deleted.

72 changes: 0 additions & 72 deletions conf/eslint-recommended.js

This file was deleted.

22 changes: 0 additions & 22 deletions conf/replacements.json

This file was deleted.

25 changes: 20 additions & 5 deletions lib/cascading-config-array-factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -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<ConfigArrayFactory["create"]>} ConfigArray */

/**
Expand All @@ -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<string,Rule>} 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.
*/

/**
Expand All @@ -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<string,Rule>} 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<CascadingConfigArrayFactory, CascadingConfigArrayFactoryInternalSlots>} */
Expand Down Expand Up @@ -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, {
Expand Down
29 changes: 21 additions & 8 deletions lib/config-array-factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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 */
Expand All @@ -84,13 +83,21 @@ const configFilenames = [
* @property {Map<string,Plugin>} [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<string,Rule>} 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.
*/

/**
* @typedef {Object} ConfigArrayFactoryInternalSlots
* @property {Map<string,Plugin>} 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<string,Rule>} 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.
*/

/**
Expand Down Expand Up @@ -414,7 +421,9 @@ class ConfigArrayFactory {
cwd = process.cwd(),
resolvePluginsRelativeTo,
builtInRules,
resolver = ModuleResolver
resolver = ModuleResolver,
eslintAllPath,
eslintRecommendedPath
} = {}) {
internalSlotsMap.set(this, {
additionalPluginPool,
Expand All @@ -423,7 +432,9 @@ class ConfigArrayFactory {
resolvePluginsRelativeTo &&
path.resolve(cwd, resolvePluginsRelativeTo),
builtInRules,
resolver
resolver,
eslintAllPath,
eslintRecommendedPath
});
}

Expand Down Expand Up @@ -781,6 +792,8 @@ class ConfigArrayFactory {
* @private
*/
_loadExtendedBuiltInConfig(extendName, ctx) {
const { eslintAllPath, eslintRecommendedPath } = internalSlotsMap.get(this);

if (extendName === "eslint:recommended") {
return this._loadConfigData({
...ctx,
Expand Down