Files
HuLa/.lintstagedrc.mjs
2025-12-29 12:41:26 +08:00

25 lines
1.0 KiB
JavaScript
Vendored
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.
import path from 'node:path'
function createCommand(prefix) {
return (filenames) => `${prefix} ${filenames.map((f) => path.relative(process.cwd(), f)).join(' ')}`
}
export default {
// JavaScript/TypeScript 文件使用 Biome (排除 .d.ts 文件和tauri-plugin-hula目录)
'*.{js,jsx,ts,tsx,json}': [
(filenames) => {
const filteredFiles = filenames.filter(
(f) =>
!f.includes('src-tauri/') && !f.includes('tauri-plugin-hula/') && !f.includes('public/') && !f.endsWith('.d.ts')
)
return filteredFiles.length > 0
? `biome check --write --unsafe ${filteredFiles.map((f) => path.relative(process.cwd(), f)).join(' ')}`
: 'echo "No files to check"'
}
],
// Vue 文件:使用 Biome 检查和修复,然后用 Prettier 格式化
'*.vue': [createCommand('biome check --write --unsafe'), createCommand('prettier --write')],
// Rust 代码:使用 manifest-path 指定 workspace避免切换目录
'src-tauri/**/*.rs': () => 'cargo fmt --manifest-path src-tauri/Cargo.toml'
}