forked from funnyzak/tts-now
-
Notifications
You must be signed in to change notification settings - Fork 0
/
lint-staged.config.js
39 lines (35 loc) · 1016 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
36
37
38
39
// lint-staged.config.js
// https://www.npmjs.com/package/lint-staged
// https://github.com/DavidAnson/markdownlint
// https://github.com/micromatch/micromatch
const micromatch = require('micromatch');
module.exports = (allStagedFiles) => {
const shFiles = micromatch(allStagedFiles, ['**/src/**/*.sh']);
if (shFiles.length) {
return "printf '%s\n' \"Script files aren't allowed in src directory\" >&2";
}
const runScripts = [];
const codeFiles = micromatch(allStagedFiles, [
'**/*.js',
'**/*.jsx',
'**/*.ts',
'**/*.tsx'
]);
if (codeFiles.length > 0) {
runScripts.push(`prettier --write ${codeFiles.join(' ')}`);
runScripts.push(`eslint --fix --cache ${codeFiles.join(' ')}`);
}
const docFiles = micromatch(allStagedFiles, [
'**/*.md',
'**/*.html',
'**/*.json',
'**/*.css',
'**/*.less',
'**/*.scss',
'**/*.sass'
]);
if (docFiles.length > 0) {
runScripts.push(`prettier --write ${docFiles.join(' ')}`);
}
return runScripts;
};