diff --git a/lib/cli-engine/file-enumerator.js b/lib/cli-engine/file-enumerator.js index 446342a1a93..c2961d71ac0 100644 --- a/lib/cli-engine/file-enumerator.js +++ b/lib/cli-engine/file-enumerator.js @@ -213,7 +213,11 @@ class FileEnumerator { */ constructor({ cwd = process.cwd(), - configArrayFactory = new CascadingConfigArrayFactory({ cwd }), + configArrayFactory = new CascadingConfigArrayFactory({ + cwd, + eslintRecommendedPath: path.resolve(__dirname, "../../conf/eslint-recommended.js"), + eslintAllPath: path.resolve(__dirname, "../../conf/eslint-all.js") + }), extensions = null, globInputPaths = true, errorOnUnmatchedPattern = true, diff --git a/tests/lib/cli-engine/file-enumerator.js b/tests/lib/cli-engine/file-enumerator.js index 1561b42e105..3ea51a408c8 100644 --- a/tests/lib/cli-engine/file-enumerator.js +++ b/tests/lib/cli-engine/file-enumerator.js @@ -488,4 +488,31 @@ describe("FileEnumerator", () => { }); }); }); + + // https://github.com/eslint/eslint/issues/13789 + describe("constructor default values when config extends eslint:recommended", () => { + const root = path.join(os.tmpdir(), "eslint/file-enumerator"); + const files = { + "file.js": "", + ".eslintrc.json": JSON.stringify({ + extends: ["eslint:recommended"] + }) + }; + const { prepare, cleanup, getPath } = createCustomTeardown({ cwd: root, files }); + + + /** @type {FileEnumerator} */ + let enumerator; + + beforeEach(async () => { + await prepare(); + enumerator = new FileEnumerator({ cwd: getPath() }); + }); + + afterEach(cleanup); + + it("should not throw an exception iterating files", () => { + Array.from(enumerator.iterateFiles(["."])); + }); + }); });