-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathlint-staged.config.js
26 lines (22 loc) · 1000 Bytes
/
lint-staged.config.js
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
const lintStaged = {
// Type check TypeScript files
'**/*.(ts|tsx)': () => 'yarn test:types',
// IDE may warn about a duplicate key, but need to be separate for correct env handling.
// Lint and format TypeScript and JavaScript files
'*.(ts|tsx|js|jsx)': (filenames) => [
// some extra handling to use next's eslint https://github.com/vercel/next.js/issues/27997#issuecomment-900554790
`yarn lint --fix --file ${filenames
.map((file) => file.split(process.cwd())[1])
.join(' --file ')}`,
`yarn prettier ${filenames.join(' ')} --write`,
],
// Run unit tests relating to modified files.
// todo: Jest should be able to ignore files that don't need tests (*.stories.*, config, etc)
'**/*.(ts|tsx|js|jsx)': (filenames) => [
`yarn test -- --findRelatedTests ${filenames.join(' ')} --passWithNoTests`,
],
// Format MarkDown and JSON
'**/*.(md|json|yml)': (filenames) =>
`yarn prettier ${filenames.join(' ')} --write`,
}
export default lintStaged