-
Notifications
You must be signed in to change notification settings - Fork 0
/
.lintstagedrc.js
31 lines (29 loc) · 1.01 KB
/
.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
const ESLint = require('eslint').ESLint
const removeIgnoredFiles = async (files) => {
const eslint = new ESLint()
const isIgnored = await Promise.all(
files.map((file) => {
return eslint.isPathIgnored(file)
})
)
const filteredFiles = files.filter((_, i) => !isIgnored[i])
return filteredFiles.join(' ')
}
module.exports = {
"dashboard/**/*.{js,ts,jsx,tsx}": async (files) => {
const filesToLint = await removeIgnoredFiles(files)
return [`eslint --max-warnings=0 ${filesToLint} --fix`]
},
"storefront/**/*.{js,ts,jsx,tsx}": async (files) => {
const filesToLint = await removeIgnoredFiles(files)
return [`eslint --max-warnings=0 ${filesToLint} --fix`]
},
"packages/**/**/*.{js,ts,jsx,tsx}": async (files) => {
const filesToLint = await removeIgnoredFiles(files)
return [`eslint --max-warnings=0 ${filesToLint} --fix`]
},
"*.json": async (files) => {
const filesToLint = await removeIgnoredFiles(files)
return [`prettier --write ${filesToLint} --fix`]
},
}