refactor(lint): migrate ESLint configuration from JSON to JS format and update related references

Signed-off-by: 孙振宇 <>
This commit is contained in:
孙振宇 2025-02-07 17:02:11 +08:00
parent f9d10df52d
commit 39cb4fc56a
4 changed files with 22 additions and 22 deletions

View File

@ -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"],
};

View File

@ -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"]
}

View File

@ -27,7 +27,7 @@ class CodeLintExecutor {
configFilePath = "com/freeleaps/devops/builtins/lint/pylint/pylintrc" configFilePath = "com/freeleaps/devops/builtins/lint/pylint/pylintrc"
break break
case CodeLinterTypes.ESLINT: case CodeLinterTypes.ESLINT:
configFilePath = "com/freeleaps/devops/builtins/lint/eslint/eslintrc.json" configFilePath = "com/freeleaps/devops/builtins/lint/eslint/eslintrc.js"
break break
default: default:
steps.log.error("CodeLintExecutor", "Unknown linter type") steps.log.error("CodeLintExecutor", "Unknown linter type")

View File

@ -24,9 +24,9 @@ class ESLint extends LinterBase {
steps.log.info("${linterType.linter}", "Install eslint dependencies...") steps.log.info("${linterType.linter}", "Install eslint dependencies...")
steps.sh("npm install -g ${deps.join(' ')}") steps.sh("npm install -g ${deps.join(' ')}")
// check if given config file is not end with .json // check if given config file is not end with .json
if (!configs.endsWith('.json')) { if (!configs.endsWith('.js')) {
steps.log.warn("${linterType.linter}", "Invalid eslint configuration file, must be a JSON file, convert file as valid JSON file...") 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}.json") steps.sh("mv ${configs} ${configs}.js")
configs = "${configs}.json" configs = "${configs}.json"
} }
steps.log.info("${linterType.linter}", "Running eslint...") steps.log.info("${linterType.linter}", "Running eslint...")