- vsh lint 按硬件自适应:CPU<=4 核串行(汇总错误),>4 核并行; CPU>4 且空闲内存>8GB 时 oxfmt/oxlint 默认线程数提升至 4,否则维持 2 - lefthook pre-commit 改为串行执行,避免与 check:type 并行导致低配机资源飙升 - pre-commit 仅对暂存文件 lint 并自动修复回填(stage_fixed) - lint 命令统一加 pnpm exec 前缀,修复 lefthook 经 sh 调用时 oxlint 找不到 workspace 局部依赖(eslint-plugin-eslint-comments)的问题
76 lines
1.9 KiB
YAML
76 lines
1.9 KiB
YAML
# EXAMPLE USAGE:
|
||
#
|
||
# Refer for explanation to following link:
|
||
# https://lefthook.dev/configuration/
|
||
#
|
||
# pre-push:
|
||
# jobs:
|
||
# - name: packages audit
|
||
# tags:
|
||
# - frontend
|
||
# - security
|
||
# run: yarn audit
|
||
#
|
||
# - name: gems audit
|
||
# tags:
|
||
# - backend
|
||
# - security
|
||
# run: bundle audit
|
||
#
|
||
# pre-commit:
|
||
# parallel: true
|
||
# jobs:
|
||
# - run: yarn eslint {staged_files}
|
||
# glob: "*.{js,ts,jsx,tsx}"
|
||
#
|
||
# - name: rubocop
|
||
# glob: "*.rb"
|
||
# exclude:
|
||
# - config/application.rb
|
||
# - config/routes.rb
|
||
# run: bundle exec rubocop --force-exclusion {all_files}
|
||
#
|
||
# - name: govet
|
||
# files: git ls-files -m
|
||
# glob: "*.go"
|
||
# run: go vet {files}
|
||
#
|
||
# - script: "hello.js"
|
||
# runner: node
|
||
#
|
||
# - script: "hello.go"
|
||
# runner: go run
|
||
|
||
pre-commit:
|
||
# 串行执行(不设 parallel),避免与 check:type 同时运行导致低配机内存/CPU 瞬时飙升。
|
||
# lint 仅检查暂存文件并自动修复后回填,大幅降低负载;check:type 仍需全量。
|
||
jobs:
|
||
- name: oxlint
|
||
glob: '*.{js,jsx,ts,tsx,vue,cjs,mjs,cts,mts}'
|
||
run: pnpm exec oxlint --fix --type-aware --threads=4 --no-error-on-unmatched-pattern {staged_files}
|
||
stage_fixed: true
|
||
- name: oxfmt
|
||
glob: '*.{js,jsx,ts,tsx,vue,cjs,mjs,cts,mts,json,jsonc}'
|
||
run: pnpm exec oxfmt --threads=4 --no-error-on-unmatched-pattern {staged_files}
|
||
stage_fixed: true
|
||
- name: eslint
|
||
glob: '*.{js,jsx,ts,tsx,vue,cjs,mjs,cts,mts}'
|
||
run: pnpm exec eslint --fix {staged_files}
|
||
stage_fixed: true
|
||
- name: stylelint
|
||
glob: '*.{vue,css,less,scss}'
|
||
run: pnpm exec stylelint --fix {staged_files}
|
||
stage_fixed: true
|
||
- name: checkType
|
||
run: pnpm check:type
|
||
|
||
post-merge:
|
||
commands:
|
||
install:
|
||
run: pnpm install
|
||
|
||
commit-msg:
|
||
commands:
|
||
commitlint:
|
||
run: pnpm exec commitlint --edit $1
|