Skip to content

Commit

Permalink
fix: Avoid dirname for built-in configs.
Browse files Browse the repository at this point in the history
Load eslint:recommended and eslint:all configs via import instead file paths.

Fixes: eslint#15575
  • Loading branch information
zddai committed Feb 13, 2022
1 parent 781f8d0 commit ce64343
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
7 changes: 4 additions & 3 deletions lib/cli-engine/cli-engine.js
Expand Up @@ -19,7 +19,8 @@ const fs = require("fs");
const path = require("path");
const defaultOptions = require("../../conf/default-cli-options");
const pkg = require("../../package.json");

const eslintRecommendedConfig = require("../../conf/eslint-recommended.js");
const eslintAllConfig = require("../../conf/eslint-all.js");

const {
Legacy: {
Expand Down Expand Up @@ -616,8 +617,8 @@ class CLIEngine {
useEslintrc: options.useEslintrc,
builtInRules,
loadRules,
eslintRecommendedPath: path.resolve(__dirname, "../../conf/eslint-recommended.js"),
eslintAllPath: path.resolve(__dirname, "../../conf/eslint-all.js")
eslintRecommendedConfig,
eslintAllConfig
});
const fileEnumerator = new FileEnumerator({
configArrayFactory,
Expand Down
6 changes: 4 additions & 2 deletions lib/cli-engine/file-enumerator.js
Expand Up @@ -40,6 +40,8 @@ const getGlobParent = require("glob-parent");
const isGlob = require("is-glob");
const escapeRegExp = require("escape-string-regexp");
const { Minimatch } = require("minimatch");
const eslintRecommendedConfig = require("../../conf/eslint-recommended.js");
const eslintAllConfig = require("../../conf/eslint-all.js");

const {
Legacy: {
Expand Down Expand Up @@ -215,8 +217,8 @@ class FileEnumerator {
cwd = process.cwd(),
configArrayFactory = new CascadingConfigArrayFactory({
cwd,
eslintRecommendedPath: path.resolve(__dirname, "../../conf/eslint-recommended.js"),
eslintAllPath: path.resolve(__dirname, "../../conf/eslint-all.js")
eslintRecommendedConfig,
eslintAllConfig
}),
extensions = null,
globInputPaths = true,
Expand Down

0 comments on commit ce64343

Please sign in to comment.