-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlint-staged.config.mjs
More file actions
36 lines (32 loc) · 1.16 KB
/
lint-staged.config.mjs
File metadata and controls
36 lines (32 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import micromatch from 'micromatch'
const lintStagedConfig = {
'*.{js,jsx,ts,tsx}': async (files) => {
// Windows 경로 정규화
const match = micromatch(files, '*.{js,jsx,ts,tsx}')
const filesStr = match.map((file) => `"${file}"`).join(' ')
if (filesStr) {
return [
`prettier --check ${filesStr}`, // 먼저 포맷 체크
`prettier --write ${filesStr}`, // 포맷 수정
`eslint --fix ${filesStr}`, // ESLint 자동 수정
`eslint ${filesStr}`, // ESLint 오류 확인 (자동 수정 불가능한 오류 체크)
`prettier --check ${filesStr}`, // 최종 포맷 확인
'npm run type-check', // TypeScript 타입 체크 추가
]
}
return []
},
'*.{json,css,md}': async (files) => {
const match = micromatch(files, '*.{json,css,md}')
const filesStr = match.map((file) => `"${file}"`).join(' ')
if (filesStr) {
return [
`prettier --check ${filesStr}`, // 먼저 포맷 체크
`prettier --write ${filesStr}`, // 포맷 수정
`prettier --check ${filesStr}`, // 최종 포맷 확인
]
}
return []
},
}
export default lintStagedConfig