forked from nextui-org/nextui
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.lintstagedrc.cjs
26 lines (20 loc) · 837 Bytes
/
.lintstagedrc.cjs
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
const {relative} = require("path");
const {ESLint} = require("eslint");
const removeIgnoredFiles = async (files) => {
const cwd = process.cwd();
const eslint = new ESLint();
const relativePaths = files.map((file) => relative(cwd, file));
const isIgnored = await Promise.all(relativePaths.map((file) => eslint.isPathIgnored(file)));
const filteredFiles = files.filter((_, i) => !isIgnored[i]);
return filteredFiles.join(" ");
};
module.exports = {
"**/*.{js,ts,jsx,tsx}": async (files) => {
const filesToLint = await removeIgnoredFiles(files);
return [`eslint -c .eslintrc.json --max-warnings=0 --fix ${filesToLint}`];
},
"**/*.css": async (files) => {
const filesToLint = await removeIgnoredFiles(files);
return [`prettier --config .prettierrc.json --ignore-path --write ${filesToLint}`];
},
};