mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-08 17:10:07 +00:00
chore: enforce vue block order in pre-commit
This commit is contained in:
@@ -1,10 +1,19 @@
|
||||
/* eslint-disable @typescript-eslint/no-floating-promises */
|
||||
const vueBlockOrderRule =
|
||||
"vue/block-order: ['error', {'order': ['docs', 'script', 'template', 'i18n', 'style']}]"
|
||||
|
||||
export default {
|
||||
'./**/*.js': (stagedFiles) => formatAndEslint(stagedFiles),
|
||||
|
||||
'./**/*.{ts,tsx,vue,mts}': (stagedFiles) => [
|
||||
'./**/*.{ts,tsx,mts}': (stagedFiles) => [
|
||||
...formatAndEslint(stagedFiles),
|
||||
'pnpm typecheck'
|
||||
]
|
||||
],
|
||||
|
||||
'./**/*.vue': (stagedFiles) => [
|
||||
runVueBlockOrder(stagedFiles),
|
||||
...formatAndEslint(stagedFiles)
|
||||
].filter(Boolean)
|
||||
}
|
||||
|
||||
function formatAndEslint(fileNames) {
|
||||
@@ -13,3 +22,9 @@ function formatAndEslint(fileNames) {
|
||||
`pnpm exec prettier --cache --write ${fileNames.join(' ')}`
|
||||
]
|
||||
}
|
||||
|
||||
function runVueBlockOrder(fileNames) {
|
||||
if (fileNames.length === 0) return null
|
||||
const quotedFiles = fileNames.map((file) => `"${file}"`).join(' ')
|
||||
return `pnpm exec eslint --fix --rule "${vueBlockOrderRule}" ${quotedFiles}`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user