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

Code before:
        // Now we can get down to linting

        const {
            linter,
            options: eslintOptions
        } = privateMembers.get(this);
        const configs = await calculateConfigArray(this, eslintOptions);
        const {
            allowInlineConfig,
            cwd,
            fix,
            fixTypes,
            warnIgnored: constructorWarnIgnored,
            ruleFilter,
            stats
        } = eslintOptions;
        const results = [];
        const startTime = Date.now();
        const fixTypesSet = fixTypes ? new Set(fixTypes) : null;
        let fixer = fix;
        const resolvedFilename = path.resolve(cwd, filePath || "__placeholder__.js");

        if (fix && fixTypesSet) {
            const originalFix = (typeof fix === "function") ? fix : () => true;

            fixer = message => shouldMessageBeFixed(message, configs.getConfig(resolvedFilename), fixTypesSet) && originalFix(message);
        }

        // Clear the last used config arrays.
        if (resolvedFilename && await this.isPathIgnored(resolvedFilename)) {
            const shouldWarnIgnored = typeof warnIgnored === "boolean" ? warnIgnored : constructorWarnIgnored;

            if (shouldWarnIgnored) {
                const configStatus = configs.getConfigStatus(resolvedFilename);

                results.push(createIgnoreResult(resolvedFilename, cwd, configStatus));
            }
        } else {

            // Do lint.
            results.push(verifyText({
                text: code,
                filePath: resolvedFilename.endsWith("__placeholder__.js") ? "<text>" : resolvedFilename,
                configs,
                cwd,
                fix: fixer,
                allowInlineConfig,
                ruleFilter,
                stats,
                linter
            }));

Review comment (refactor):
This logic is very similar to what we have in `lintFiles()`:

https://github.com/eslint/eslint/blob/c554d7299e9da9fac4a97fb62b3ec34374eb1e28/lib/eslint/eslint.js#L925-L929

Would it make sense to extract it into a new function, maybe `getFixerForFixTypes`, that we could call with the `config` and `fixTypesSet` in both places to get the fixer? I.e.:


```js
            fixer = getFixerForFixTypes(configs.getConfig(resolvedFilename), fixTypesSet);
```

Code after:
        if (filePath !== void 0 && !isNonEmptyString(filePath)) {
            throw new Error("'options.filePath' must be a non-empty string or undefined");
        }

        if (typeof warnIgnored !== "boolean" && typeof warnIgnored !== "undefined") {
            throw new Error("'options.warnIgnored' must be a boolean or undefined");
        }

        // Now we can get down to linting

        const {
            linter,
            options: eslintOptions
        } = privateMembers.get(this);
        const configs = await calculateConfigArray(this, eslintOptions);
        const {
            allowInlineConfig,
            cwd,
            fix,
            fixTypes,
            warnIgnored: constructorWarnIgnored,
            ruleFilter,
            stats
        } = eslintOptions;
        const results = [];
        const startTime = Date.now();
        const fixTypesSet = fixTypes ? new Set(fixTypes) : null;
        const resolvedFilename = path.resolve(cwd, filePath || "__placeholder__.js");
        const config = configs.getConfig(resolvedFilename);

        const fixer = getFixerForFixTypes(fix, fixTypesSet, config);

        // Clear the last used config arrays.
        if (resolvedFilename && await this.isPathIgnored(resolvedFilename)) {
            const shouldWarnIgnored = typeof warnIgnored === "boolean" ? warnIgnored : constructorWarnIgnored;

            if (shouldWarnIgnored) {
                const configStatus = configs.getConfigStatus(resolvedFilename);

                results.push(createIgnoreResult(resolvedFilename, cwd, configStatus));
            }
        } else {

            // Do lint.
            results.push(verifyText({
                text: code,
                filePath: resolvedFilename.endsWith("__placeholder__.js") ? "<text>" : resolvedFilename,
                configs,
                cwd,
                fix: fixer,
                allowInlineConfig,