diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 1eb77dfd..7335f212 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -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" diff --git a/.gitlab-ci/run-eslint b/.gitlab-ci/run-eslint deleted file mode 100755 index 3383efda..00000000 --- a/.gitlab-ci/run-eslint +++ /dev/null @@ -1,58 +0,0 @@ -#!/usr/bin/env node - -// SPDX-FileCopyrightText: 2023 Florian Müllner -// -// 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); -});