-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy path.lintstagedrc.mjs
More file actions
34 lines (29 loc) · 1.18 KB
/
Copy path.lintstagedrc.mjs
File metadata and controls
34 lines (29 loc) · 1.18 KB
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
// lint-staged config — moved here from package.json so we can use a
// function to filter file lists before invoking oxlint. The default glob
// picks up files under src/tests/, but oxlint excludes that directory via
// ignorePatterns in .oxlintrc.json; passing it nothing-but-ignored files
// makes oxlint exit non-zero with "No files found to lint", which breaks
// the pre-commit hook for test-only changes. The filter drops src/tests/
// paths before invoking oxlint; oxfmt still formats them.
import path from "node:path";
const IGNORED = ["src/tests/"];
const filterLintable = (files) =>
files.filter((file) => {
const rel = path.relative(import.meta.dirname, file);
return !IGNORED.some((prefix) => rel.startsWith(prefix));
});
const config = {
"demo/**/*.{js,jsx,ts,tsx}":
"oxlint -c demo/.oxlintrc.json --disable-nested-config --fix",
"!(demo|codemod)/**/*.{js,jsx,ts,tsx}": (files) => {
const lintable = filterLintable(files);
if (lintable.length === 0) {
return [];
}
return `oxlint -c .oxlintrc.json --disable-nested-config --fix ${lintable
.map((f) => JSON.stringify(f))
.join(" ")}`;
},
"*": "oxfmt",
};
export default config;