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

refactor: locateConfigFileToUse returns an Error object #17159

Merged
Merged
Changes from all 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
8 changes: 4 additions & 4 deletions lib/eslint/flat-eslint.js
Expand Up @@ -326,15 +326,15 @@ async function loadFlatConfigFile(filePath) {
* as override config file is not explicitly set to `false`, it will search
* upwards from the cwd for a file named `eslint.config.js`.
* @param {import("./eslint").ESLintOptions} options The ESLint instance options.
* @returns {{configFilePath:string,basePath:string,error:boolean}} Location information for
* @returns {{configFilePath:string,basePath:string,error:Error|null}} Location information for
* the config file.
*/
async function locateConfigFileToUse({ configFile, cwd }) {

// determine where to load config file from
let configFilePath;
let basePath = cwd;
let error = false;
let error = null;

if (typeof configFile === "string") {
debug(`Override config file path is ${configFile}`);
Expand All @@ -346,7 +346,7 @@ async function locateConfigFileToUse({ configFile, cwd }) {
if (configFilePath) {
basePath = path.resolve(path.dirname(configFilePath));
} else {
error = true;
error = new Error("Could not find config file.");
}

}
Expand Down Expand Up @@ -385,7 +385,7 @@ async function calculateConfigArray(eslint, {

// config file is required to calculate config
if (error) {
throw new Error("Could not find config file.");
throw error;
}

const configs = new FlatConfigArray(baseConfig || [], { basePath, shouldIgnore });
Expand Down