-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.lintstagedrc.js
32 lines (29 loc) · 913 Bytes
/
.lintstagedrc.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
32
const path = require("path");
/**
* Using next lint with lint-staged requires this setup
* https://nextjs.org/docs/basic-features/eslint#lint-staged
*/
const buildEslintCommand = (filenames) =>
`next lint --fix --file ${filenames
.map((f) => path.relative(process.cwd(), f))
.join(" --file ")}`;
/**
* () => "npm run type:check"
* needs to be a function because arguments are getting passed from lint-staged
* when those arguments get through to the "tsc" command that "npm run type:check"
* is calling the args cause "tsc" to ignore the tsconfig.json in our root directory.
* https://github.com/microsoft/TypeScript/issues/27379
*/
module.exports = {
"*.{js,jsx}": [
"npm run format:fix",
buildEslintCommand,
"npm run format:check",
],
"*.{ts,tsx}": [
"npm run format:fix",
() => "npm run type:check",
buildEslintCommand,
"npm run format:check",
],
};