forked from nextui-org/tailwind-variants
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.lintstagedrc.cjs
27 lines (21 loc) · 902 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
27
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|d.ts)
"**/*.{js,cjs,mjs,ts,jsx,tsx,json,md}": async (files) => {
const filesToLint = await removeIgnoredFiles(files);
return [`prettier --config .prettierrc.json --ignore-path --write ${filesToLint}`];
},
"**/*.{js,cjs,mjs,ts,jsx,tsx}": async (files) => {
const filesToLint = await removeIgnoredFiles(files);
return [`eslint -c .eslintrc.json --max-warnings=0 --fix ${filesToLint}`];
},
};