ci: Use script from tools to run eslint

Now that we include a more public version of the script, there
is no reason to keep the original script just for CI.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell-extensions/-/merge_requests/408>
This commit is contained in:
Florian Müllner
2025-06-10 04:00:27 +02:00
committed by Marge Bot
parent 7d41858bab
commit f4bf96cbbc
2 changed files with 1 additions and 62 deletions

View File

@@ -101,11 +101,8 @@ eslint:
variables:
LINT_LOG: "eslint-report.xml"
script:
- export NODE_PATH=$(npm root -g)
- ./.gitlab-ci/run-eslint --output-file "$LINT_LOG" --format junit --stdout
- ./tools/run-eslint.sh --output-file "$LINT_LOG" --format junit --stdout
artifacts:
paths:
- "$LINT_LOG"
reports:
junit: "$LINT_LOG"

View File

@@ -1,58 +0,0 @@
#!/usr/bin/env node
// SPDX-FileCopyrightText: 2023 Florian Müllner <fmuellner@gnome.org>
//
// SPDX-License-Identifier: GPL-2.0-or-later
const {ESLint} = require('eslint');
console.log(`Running ESLint version ${ESLint.version}...`);
const fs = require('fs');
const path = require('path');
function hasOption(...names) {
return process.argv.some(arg => names.includes(arg));
}
function getOption(...names) {
const optIndex =
process.argv.findIndex(arg => names.includes(arg)) + 1;
if (optIndex === 0)
return undefined;
return process.argv[optIndex];
}
(async function main() {
const outputOption = getOption('--output-file', '-o');
const outputPath = outputOption ? path.resolve(outputOption) : null;
const sourceDir = path.dirname(process.argv[1]);
process.chdir(path.resolve(sourceDir, '..'));
const sources = ['extensions'];
const eslint = new ESLint();
const results = await eslint.lintFiles(sources);
const formatter = await eslint.loadFormatter(getOption('--format', '-f'));
const resultText = formatter.format(results);
if (outputPath) {
fs.mkdirSync(path.dirname(outputPath), {recursive: true});
fs.writeFileSync(outputPath, resultText);
if (hasOption('--stdout')) {
const consoleFormatter = await eslint.loadFormatter();
console.log(consoleFormatter.format(results));
}
} else {
console.log(resultText);
}
process.exitCode = results.some(r => r.errorCount > 0) ? 1 : 0;
})().catch((error) => {
process.exitCode = 1;
console.error(error);
});