Repository: eslint/eslint
File: lib/eslint/flat-eslint.js (JavaScript)

Code before:
    if (importedConfigFileModificationTime.get(filePath) !== mtime) {
        delete require.cache[filePath];
    }

    const config = (await import(fileURL)).default;

    importedConfigFileModificationTime.set(filePath, mtime);

    return config;
}

/**
 * Determines which config file to use. This is determined by seeing if an
 * override config file was passed, and if so, using it; otherwise, as long
 * 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}} Location information for
 *      the config file.
 */
async function locateConfigFileToUse({ configFile, cwd }) {

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

    if (typeof configFile === "string") {
        debug(`Override config file path is ${configFile}`);
        configFilePath = path.resolve(cwd, configFile);
    } else if (configFile !== false) {
        debug("Searching for eslint.config.js");
        configFilePath = await findFlatConfigFile(cwd);

        if (!configFilePath) {
            throw new Error("Could not find config file.");
        }

        basePath = path.resolve(path.dirname(configFilePath));
    }

    return {
        configFilePath,
        basePath
    };

}

/**
 * Calculates the config array for this run based on inputs.
 * @param {FlatESLint} eslint The instance to create the config array for.
 * @param {import("./eslint").ESLintOptions} options The ESLint instance options.

Review comment (suggestion):
The name `error` sounds generic and I expected it to be an instance of `Error`. Can we use something like `isConfigFileDetected`/`hasConfigFile`? I feel it's better suited for a boolean value.

Code after:
    if (importedConfigFileModificationTime.get(filePath) !== mtime) {
        delete require.cache[filePath];
    }

    const config = (await import(fileURL)).default;

    importedConfigFileModificationTime.set(filePath, mtime);

    return config;
}

/**
 * Determines which config file to use. This is determined by seeing if an
 * override config file was passed, and if so, using it; otherwise, as long
 * 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
 *      the config file.
 */
async function locateConfigFileToUse({ configFile, cwd }) {

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

    if (typeof configFile === "string") {
        debug(`Override config file path is ${configFile}`);
        configFilePath = path.resolve(cwd, configFile);
    } else if (configFile !== false) {
        debug("Searching for eslint.config.js");
        configFilePath = await findFlatConfigFile(cwd);

        if (configFilePath) {
            basePath = path.resolve(path.dirname(configFilePath));
        } else {
            error = true;
        }

    }

    return {
        configFilePath,
        basePath,
        error
    };

}

/**