-
-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathlint-staged.config.js
More file actions
40 lines (38 loc) · 1.17 KB
/
lint-staged.config.js
File metadata and controls
40 lines (38 loc) · 1.17 KB
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
37
38
39
40
import fs from 'node:fs'
import { fileURLToPath } from 'node:url'
import path from 'pathe'
const __dirname = fileURLToPath(new URL('.', import.meta.url))
/**
* @filename: lint-staged.config.js
* @type {import('lint-staged').Configuration}
*/
export default {
'*': [
'eslint --fix',
],
'docs/**': _stagedFiles => [
'pnpm run docs:build',
],
'packages/**': (stagedFiles) => {
const packages = stagedFiles.map((file) => {
const packagePath = path.relative(__dirname, file)
return packagePath.split('/')[1]
})
const packageNames = [...new Set(packages)].map((packagePath) => {
const packageJsonPath = path.join(__dirname, 'packages', packagePath, 'package.json')
const content = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'))
return content.name
})
return [
'pnpm run test',
// `pnpm run -r ${packageNames.map(name => `--filter ...${name}`).join(' ')} build`,
`pnpm run -r ${packageNames.map(name => `--filter ...${name}`).join(' ')} test:types`,
]
},
'README.md': _stagedFiles => [
'pnpm run copy-readme',
],
'pnpm-lock.yaml': _stagedFiles => [
'run-p docs:build bb test',
],
}