Files
Edu/lint-staged.config.js

18 lines
813 B
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
module.exports = {
'*.{ts,tsx}': ['eslint --fix', 'prettier --write'],
// Go 工具链不在 git hook PATH 中Go 文件格式化由 go fmt 手动执行
// golangci-lint 安装后恢复:['gofmt -w', 'golangci-lint run --fix']
// 排除 proto_gen自动生成的 gRPC stub和 .coverage二进制文件
'*.py': (files) => {
const filtered = files.filter(
(f) => !f.includes('proto_gen') && !f.endsWith('.coverage'),
);
return filtered.length > 0
? [`ruff check --fix ${filtered.map((f) => `"${f}"`).join(' ')}`, `ruff format ${filtered.map((f) => `"${f}"`).join(' ')}`]
: [];
},
// buf format 一次只接受 1 个文件参数,需逐个调用
'*.proto': (files) => files.map((file) => `buf format --write "${file}"`),
'*.md': ['prettier --write'],
};