"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.runLinter = void 0;
const eslint_1 = require("eslint");
const utils_1 = require("../utils");
async function runLinter(files) {
    try {
        const eslint = new eslint_1.ESLint({
            overrideConfigFile: 'syft/lint/config.cjs',
            rulePaths: ['syft/lint/rules'],
            useEslintrc: true
        });
        const results = await eslint.lintFiles(files);
        const errors = results.filter((result) => result.errorCount > 0);
        const formatter = await eslint.loadFormatter('stylish');
        const resultText = formatter.format(results);
        console.log(resultText);
        return errors.length === 0;
    }
    catch (e) {
        (0, utils_1.logUnknownError)(':warning: Failed to run linter. Ignoring linting for now.', e);
        return true;
    }
}
exports.runLinter = runLinter;
