forked from vercel/next.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlint-staged.config.js
26 lines (25 loc) · 914 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 escape = require('shell-quote').quote
const isWin = process.platform === 'win32'
module.exports = {
'**/*.{js,jsx,ts,tsx}': filenames => {
const escapedFileNames = filenames
.map(filename => `"${isWin ? filename : escape([filename])}"`)
.join(' ')
return [
`prettier --with-node-modules --ignore-path='./.prettierignore_staged' --write ${escapedFileNames}`,
`eslint --no-ignore --max-warnings=0 --fix ${filenames
.map(f => `"${f}"`)
.join(' ')}`,
`git add ${escapedFileNames}`,
]
},
'**/*.{json,md,mdx,css,html,yml,yaml,scss,sass}': filenames => {
const escapedFileNames = filenames
.map(filename => `"${isWin ? filename : escape([filename])}"`)
.join(' ')
return [
`prettier --with-node-modules --ignore-path='./.prettierignore_staged' --write ${escapedFileNames}`,
`git add ${escapedFileNames}`,
]
},
}