-
Notifications
You must be signed in to change notification settings - Fork 0
/
.lintstagedrc.js
31 lines (26 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
const { CLIEngine } = require('eslint');
const { execSync } = require('child_process');
const cli = new CLIEngine({});
/**
* * Because shellcheck script might not exist, check first if it does.
* * If it doesn't, provide an empty function for shell scripts linting
* */
let shellcheck;
try {
execSync('command -v shellcheck >/dev/null 2>&1');
shellcheck = files => files.map(file => `shellcheck "${file}"`);
} catch (e) {
shellcheck = _files => [];
}
module.exports = {
'**/*.ts?(x)': () => 'tsc -p tsconfig.json --noEmit',
// equivalent globs for the same set of files, execute in parallel
'*.{js,jsx,ts,tsx,PARALLEL_1}': files =>
`eslint --report-unused-disable-directives --max-warnings=0 ${files
.filter(file => !cli.isPathIgnored(file))
.map(f => `"${f}"`)
.join(' ')}`,
'*.sh': shellcheck,
'bin/*': shellcheck,
'*.{js,ts,jsx,tsx,css,md,mdx,scss}': 'prettier --write',
};