Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
refactor: locateConfigFileToUse returns an Error object (#17159)
followup of #17151 (comment)
  • Loading branch information
aladdin-add committed May 7, 2023
1 parent 69a19c8 commit 4caa344
Showing 1 changed file with 4 additions and 4 deletions.
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

0 comments on commit 4caa344

Please sign in to comment.