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

Code before:
     */
    async findConfigFile() {
        const options = privateMembers.get(this).options;
        const { configFilePath } = await locateConfigFileToUse(options);

        return configFilePath;
    }

    /**
     * Checks if a given path is ignored by ESLint.
     * @param {string} filePath The path of the file to check.
     * @returns {Promise<boolean>} Whether or not the given path is ignored.
     */
    async isPathIgnored(filePath) {
        const config = await this.calculateConfigForFile(filePath);

        return config === void 0;
    }
}

/**
 * Returns whether flat config should be used.
 * @param {boolean} [allowFlatConfig] Whether or not to allow flat config.
 * @returns {Promise<boolean>} Where flat config should be used.
 */
async function shouldUseFlatConfig(allowFlatConfig) {
    if (!allowFlatConfig) {
        return false;
    }

    switch (process.env.ESLINT_USE_FLAT_CONFIG) {
        case "true":
            return true;
        case "false":
            return false;
        default:

            /*
             * If neither explicitly enabled nor disabled, then use the presence
             * of a flat config file to determine enablement.
             */
            return !!(await findFlatConfigFile(process.cwd()));
    }
}

//------------------------------------------------------------------------------
// Public Interface
//------------------------------------------------------------------------------

module.exports = {
    FlatESLint,

Review comment (suggestion):
I'm not sure it makes sense to expose the function with this argument. It was a convenience internally, but I think for external consumption, there would be no need to call `shouldUseFlatConfig()` if `allowFlatConfig` was `false`.

So, I think we should just get rid of the argument here and assume anyone calling `shouldUseFlatConfig()` wants to allow it.

Code after:
     */
    async findConfigFile() {
        const options = privateMembers.get(this).options;
        const { configFilePath } = await locateConfigFileToUse(options);

        return configFilePath;
    }

    /**
     * Checks if a given path is ignored by ESLint.
     * @param {string} filePath The path of the file to check.
     * @returns {Promise<boolean>} Whether or not the given path is ignored.
     */
    async isPathIgnored(filePath) {
        const config = await this.calculateConfigForFile(filePath);

        return config === void 0;
    }
}

/**
 * Returns whether flat config should be used.
 * @returns {Promise<boolean>} Whether flat config should be used.
 */
async function shouldUseFlatConfig() {
    switch (process.env.ESLINT_USE_FLAT_CONFIG) {
        case "true":
            return true;
        case "false":
            return false;
        default:

            /*
             * If neither explicitly enabled nor disabled, then use the presence
             * of a flat config file to determine enablement.
             */
            return !!(await findFlatConfigFile(process.cwd()));
    }
}

//------------------------------------------------------------------------------
// Public Interface
//------------------------------------------------------------------------------

module.exports = {
    FlatESLint,
    shouldUseFlatConfig
};