From 39cb4fc56ab31ba3d5f09e6e25875d28b4c46a36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=99=E6=8C=AF=E5=AE=87?= <> Date: Fri, 7 Feb 2025 17:02:11 +0800 Subject: [PATCH] refactor(lint): migrate ESLint configuration from JSON to JS format and update related references MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 孙振宇 <> --- .../devops/builtins/lint/eslint/eslintrc.js | 18 ++++++++++++++++++ .../devops/builtins/lint/eslint/eslintrc.json | 18 ------------------ .../freeleaps/devops/CodeLintExecutor.groovy | 2 +- .../com/freeleaps/devops/lint/ESLint.groovy | 6 +++--- 4 files changed, 22 insertions(+), 22 deletions(-) create mode 100644 first-class-pipeline/resources/com/freeleaps/devops/builtins/lint/eslint/eslintrc.js delete mode 100644 first-class-pipeline/resources/com/freeleaps/devops/builtins/lint/eslint/eslintrc.json diff --git a/first-class-pipeline/resources/com/freeleaps/devops/builtins/lint/eslint/eslintrc.js b/first-class-pipeline/resources/com/freeleaps/devops/builtins/lint/eslint/eslintrc.js new file mode 100644 index 00000000..2029082f --- /dev/null +++ b/first-class-pipeline/resources/com/freeleaps/devops/builtins/lint/eslint/eslintrc.js @@ -0,0 +1,18 @@ +module.exports = { + root: true, + parser: "@typescript-eslint/parser", + parserOptions: { + ecmaVersion: 6, + sourceType: "module", + }, + plugins: ["@typescript-eslint"], + rules: { + "@typescript-eslint/naming-convention": "warn", + "@typescript-eslint/semi": "warn", + curly: "warn", + eqeqeq: "warn", + "no-throw-literal": "warn", + semi: "off", + }, + ignorePatterns: ["out", "dist", "**/*.d.ts"], +}; diff --git a/first-class-pipeline/resources/com/freeleaps/devops/builtins/lint/eslint/eslintrc.json b/first-class-pipeline/resources/com/freeleaps/devops/builtins/lint/eslint/eslintrc.json deleted file mode 100644 index 5dfecab7..00000000 --- a/first-class-pipeline/resources/com/freeleaps/devops/builtins/lint/eslint/eslintrc.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "root": true, - "parser": "@typescript-eslint/parser", - "parserOptions": { - "ecmaVersion": 6, - "sourceType": "module" - }, - "plugins": ["@typescript-eslint"], - "rules": { - "@typescript-eslint/naming-convention": "warn", - "@typescript-eslint/semi": "warn", - "curly": "warn", - "eqeqeq": "warn", - "no-throw-literal": "warn", - "semi": "off" - }, - "ignorePatterns": ["out", "dist", "**/*.d.ts"] -} diff --git a/first-class-pipeline/src/com/freeleaps/devops/CodeLintExecutor.groovy b/first-class-pipeline/src/com/freeleaps/devops/CodeLintExecutor.groovy index 1d4141f3..1ec40c1f 100644 --- a/first-class-pipeline/src/com/freeleaps/devops/CodeLintExecutor.groovy +++ b/first-class-pipeline/src/com/freeleaps/devops/CodeLintExecutor.groovy @@ -27,7 +27,7 @@ class CodeLintExecutor { configFilePath = "com/freeleaps/devops/builtins/lint/pylint/pylintrc" break case CodeLinterTypes.ESLINT: - configFilePath = "com/freeleaps/devops/builtins/lint/eslint/eslintrc.json" + configFilePath = "com/freeleaps/devops/builtins/lint/eslint/eslintrc.js" break default: steps.log.error("CodeLintExecutor", "Unknown linter type") diff --git a/first-class-pipeline/src/com/freeleaps/devops/lint/ESLint.groovy b/first-class-pipeline/src/com/freeleaps/devops/lint/ESLint.groovy index 52c96047..5c70be49 100644 --- a/first-class-pipeline/src/com/freeleaps/devops/lint/ESLint.groovy +++ b/first-class-pipeline/src/com/freeleaps/devops/lint/ESLint.groovy @@ -24,9 +24,9 @@ class ESLint extends LinterBase { steps.log.info("${linterType.linter}", "Install eslint dependencies...") steps.sh("npm install -g ${deps.join(' ')}") // check if given config file is not end with .json - if (!configs.endsWith('.json')) { - steps.log.warn("${linterType.linter}", "Invalid eslint configuration file, must be a JSON file, convert file as valid JSON file...") - steps.sh("mv ${configs} ${configs}.json") + if (!configs.endsWith('.js')) { + steps.log.warn("${linterType.linter}", "Invalid eslint configuration file, must be a JS file, convert file as valid JS file...") + steps.sh("mv ${configs} ${configs}.js") configs = "${configs}.json" } steps.log.info("${linterType.linter}", "Running eslint...")