-
Notifications
You must be signed in to change notification settings - Fork 121
/
.lintstagedrc.js
36 lines (27 loc) · 931 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
33
34
35
36
const micromatch = require('micromatch')
const { relative } = require('path')
const SCRIPT_PATTERNS = [
'packages/{babel-plugin-veui,veui,veui-loader,veui-theme-dls}/**/*.{js,ts,vue}'
]
const STYLE_PATTERNS = [
'packages/veui-theme-dls/**/*.less',
'packages/veui/demo/**/*.vue'
]
const JSON_PATTERNS = ['packages/**/package-lock.json']
module.exports = (staged) => {
const relativePaths = staged.map((p) => relative(__dirname, p))
const scripts = micromatch(relativePaths, SCRIPT_PATTERNS).join(' ')
const styles = micromatch(relativePaths, STYLE_PATTERNS).join(' ')
const jsons = micromatch(relativePaths, JSON_PATTERNS).join(' ')
const tasks = []
if (scripts || styles || jsons) {
tasks.push(`prettier --write ${[scripts, styles, jsons].join(' ')}`)
}
if (scripts) {
tasks.push(`eslint --fix ${scripts}`)
}
if (styles) {
tasks.push(`stylelint --fix ${styles}`)
}
return tasks
}