-
Notifications
You must be signed in to change notification settings - Fork 2
/
lint-staged.config.js
35 lines (32 loc) · 986 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
27
28
29
30
31
32
33
34
35
const { ESLint } = require('eslint')
const filterAsync = require('node-filter-async').default
const eslintCli = new ESLint()
const removeIgnoredFiles = async (files, eslintCli) => {
const filteredFiles = await filterAsync(files, async file => {
const isIgnored = await eslintCli.isPathIgnored(file)
return !isIgnored
})
return filteredFiles.join(' ')
}
module.exports = {
'{apps,packages}/**/*.ts?(x)': async files => {
const filesToLint = await removeIgnoredFiles(files, eslintCli)
if (!filesToLint) {
return []
}
return [
`yarn run eslint --max-warnings=0 --cache --debug ${filesToLint}`,
`yarn run prettier --write ${filesToLint}`,
]
},
'{apps,packages}/**/*.js?(x)': async files => {
const filesToLint = await removeIgnoredFiles(files, eslintCli)
if (!filesToLint) {
return []
}
return [
`yarn run eslint --cache ${filesToLint}`,
`yarn run prettier --write ${filesToLint}`,
]
},
}