2025-02-05 08:29:52 +00:00
|
|
|
package com.freeleaps.devops.lint
|
|
|
|
|
|
|
|
|
|
import com.freeleaps.devops.enums.CodeLinterTypes
|
|
|
|
|
import com.freeleaps.devops.lint.LinterBase
|
|
|
|
|
|
|
|
|
|
class ESLint extends LinterBase {
|
2025-02-07 07:18:40 +00:00
|
|
|
|
2025-02-07 07:24:29 +00:00
|
|
|
def deps = [
|
2025-02-07 07:18:40 +00:00
|
|
|
'eslint-define-config',
|
|
|
|
|
'eslint-config-prettier',
|
|
|
|
|
'eslint-plugin-prettier',
|
|
|
|
|
'eslint-plugin-vue',
|
|
|
|
|
'@typescript-eslint/eslint-plugin',
|
|
|
|
|
'@typescript-eslint/parser',
|
|
|
|
|
'typescript'
|
|
|
|
|
]
|
|
|
|
|
|
2025-02-05 08:29:52 +00:00
|
|
|
ESLint(steps, workspace, configs) {
|
|
|
|
|
super(steps, workspace, configs, CodeLinterTypes.ESLINT)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
def doLint() {
|
2025-02-07 08:16:43 +00:00
|
|
|
steps.dir(workspace) {
|
|
|
|
|
steps.log.info("${linterType.linter}", "Install eslint dependencies...")
|
2025-02-07 08:30:27 +00:00
|
|
|
steps.sh("npm install -g ${deps.join(' ')}")
|
2025-02-07 08:53:17 +00:00
|
|
|
// check if given config file is not end with .json
|
2025-02-07 09:02:11 +00:00
|
|
|
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")
|
2025-02-07 08:53:17 +00:00
|
|
|
configs = "${configs}.json"
|
|
|
|
|
}
|
2025-02-07 08:16:43 +00:00
|
|
|
steps.log.info("${linterType.linter}", "Running eslint...")
|
|
|
|
|
steps.sh("eslint --config ${configs} ${workspace}")
|
|
|
|
|
}
|
2025-02-05 08:29:52 +00:00
|
|
|
}
|
|
|
|
|
}
|