-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
.lintstagedrc.js
25 lines (23 loc) · 966 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
import { ESLint } from 'eslint';
const removeIgnoredEslintFiles = async (files) => {
const eslint = new ESLint();
const ignoredFiles = await Promise.all(files.map((file) => eslint.isPathIgnored(file)));
const filteredFiles = files.filter((_, i) => !ignoredFiles[i]);
return filteredFiles.join(' ');
};
export default {
'*.{mdx,ts}': ['eslint --max-warnings=0 --fix', 'prettier --write'],
'*.{json,js}': ['prettier --write'],
// '*.{ts,tsx}': async (files) => {
// const eslintFiles = await removeIgnoredEslintFiles(files);
// return [
// // ...eslintFiles.map((file) => `eslint --max-warnings=0 --fix ${file}`),
// `eslint --max-warnings=0 --fix ${eslintFiles}`,
// // Doing the following "map" approach to avoid this error
// // "ENAMETOOLONG: name too long"
// ...files.map((file) => `prettier --write ${file}`),
// ];
// },
// '*.{js,jsx}': ['prettier --write'],
// '*.md': ['prettier --write'],
};