ci: Add --fix flag to eslint

The CI enforces a style check, using ./.gitlab-ci/run-eslint to propose suggestions.
When trying to solve the problem, this command appears the immediate candidate for automatic fixing, The log message points the user to `--fix`, supporting that guess, but before this change, `--fix` would have no effect.
This commit is contained in:
dcz 2024-05-24 15:49:49 +00:00 committed by dcz
parent 9abad7f25f
commit 06f46ee488

View file

@ -23,15 +23,18 @@ function getOption(...names) {
(async function main() {
const outputOption = getOption('--output-file', '-o');
const fixOption = hasOption('--fix');
const outputPath = outputOption ? path.resolve(outputOption) : null;
const sourceDir = path.dirname(process.argv[1]);
process.chdir(path.resolve(sourceDir, '..'));
const sources = ['js', 'subprojects/extensions-app/js', 'tests'];
const eslint = new ESLint({cache: true});
const eslint = new ESLint({cache: true, fix: fixOption});
const results = await eslint.lintFiles(sources);
if (fixOption)
await ESLint.outputFixes(results);
const formatter = await eslint.loadFormatter(getOption('--format', '-f'));
const resultText = formatter.format(results);