generated from belgattitude/nextjs-monorepo-example
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlint-staged.config.base.js
31 lines (28 loc) · 1.04 KB
/
lint-staged.config.base.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
27
28
29
30
31
/**
* lint-staged/prettier has an issue with special characters in filenames,
* like the ones uses for nextjs dynamic routes (ie: [id].tsx...)
* @link https://github.com/okonet/lint-staged/issues/676
*/
const escape = require('shell-quote').quote;
const { CLIEngine } = require('eslint');
const cli = new CLIEngine({});
const isWin = process.platform === 'win32';
const escapeFileNamesForPrettier = (filenames) =>
filenames
.map((filename) => `"${false ? filename : escape([filename])}"`)
.join(' ');
module.exports = {
'**/*.{js,jsx,ts,tsx}': (filenames) => {
return [
// react-hooks/exhaustive-deps must be kept off, a change made here can
// potentially break your code
`eslint --rule 'react-hooks/exhaustive-deps: off' --max-warnings=25 --fix ${filenames
.filter((file) => !cli.isPathIgnored(file))
.map((f) => `"${f}"`)
.join(' ')}`,
];
},
'**/*.{json,md,mdx,css,html,yml,yaml,scss}': (filenames) => {
return [`prettier --write ${escapeFileNamesForPrettier(filenames)}`];
},
};