forked from redhat-developer/rhdh
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.lintstagedrc.cjs
More file actions
32 lines (28 loc) · 1.07 KB
/
.lintstagedrc.cjs
File metadata and controls
32 lines (28 loc) · 1.07 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
/**
* @type {import('lint-staged').Configuration}
*/
module.exports = {
".{cursor,claude,rulesync}/**/*.{mdc,md,json}": (filenames) => {
const hasRulesync = filenames.some((f) => f.includes(".rulesync/"));
const changedDirs = ["cursor", "claude"].filter((dir) =>
filenames.some((f) => f.includes(`.${dir}/`))
);
// If .rulesync changed, generate and sync to .cursor and .claude
if (hasRulesync) {
return ["yarn rulesync:generate", "git add .cursor .claude"];
}
// If .cursor or .claude changed directly, throw error
if (changedDirs.length > 0) {
changedDirs.forEach((dir) => {
console.error(`⚠️ Direct changes to .${dir} detected!`);
console.error("Files triggering check:", filenames.filter((f) => f.includes(`.${dir}/`)));
console.error("💡 To sync back to .rulesync, run:");
console.error(` yarn rulesync:import:${dir}\n`);
});
throw new Error(
`❌ Direct changes to ${changedDirs.map((d) => `.${d}`).join(" and ")} are not allowed.`
);
}
return [];
},
};