generated from Experience-Monks/nextjs-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlint-staged.config.js
23 lines (22 loc) · 1005 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
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 --write ${escapedFileNames}`,
`next lint --ignore-path .eslintignore --max-warnings=0 --fix --file ${filenames
.map((filename) => `"${isWin ? filename : escape([filename])}"`)
.join(' --file ')}`,
`git add ${escapedFileNames}`
];
},
'**/*.ts?(x)': () => 'tsc -p tsconfig.json --noEmit',
'**/*.{json,md,mdx,css,html,yml,yaml,scss}': (filenames) => {
const escapedFileNames = filenames.map((filename) => `"${isWin ? filename : escape([filename])}"`).join(' ');
return [
`prettier --with-node-modules --ignore-path .prettierignore --write ${escapedFileNames}`,
`git add ${escapedFileNames}`
];
}
};