test(repo): guard timeline drag helper boundaries
This commit is contained in:
@@ -119,6 +119,51 @@ export const rules = [
|
||||
],
|
||||
forbidden: [],
|
||||
},
|
||||
{
|
||||
file: "apps/web/src/hooks/timelineTouch.ts",
|
||||
maxLines: 80,
|
||||
required: [
|
||||
{
|
||||
pattern: /\bexport function getTouchPoint\b/,
|
||||
message: "timeline touch helpers must keep touch coordinate fallback centralized",
|
||||
},
|
||||
{
|
||||
pattern: /\bexport function resolveTouchDragDecision\b/,
|
||||
message: "timeline touch helpers must keep scroll-vs-drag disambiguation centralized",
|
||||
},
|
||||
],
|
||||
forbidden: [],
|
||||
},
|
||||
{
|
||||
file: "apps/web/src/hooks/timelineMultiSelect.ts",
|
||||
maxLines: 90,
|
||||
required: [
|
||||
{
|
||||
pattern: /\bexport function createMultiSelectState\b/,
|
||||
message: "timeline multi-select helpers must keep selection bootstrap centralized",
|
||||
},
|
||||
{
|
||||
pattern: /\bexport function finalizeMultiSelectDraft\b/,
|
||||
message: "timeline multi-select helpers must keep minimal-drag reset logic centralized",
|
||||
},
|
||||
],
|
||||
forbidden: [],
|
||||
},
|
||||
{
|
||||
file: "apps/web/src/hooks/timelineRangeSelection.ts",
|
||||
maxLines: 90,
|
||||
required: [
|
||||
{
|
||||
pattern: /\bexport function updateRangeSelectionDraft\b/,
|
||||
message: "timeline range helpers must keep preview date derivation centralized",
|
||||
},
|
||||
{
|
||||
pattern: /\bexport function finalizeRangeSelection\b/,
|
||||
message: "timeline range helpers must keep ordered range finalization centralized",
|
||||
},
|
||||
],
|
||||
forbidden: [],
|
||||
},
|
||||
{
|
||||
file: "apps/web/src/hooks/useTimelineDrag.ts",
|
||||
required: [
|
||||
@@ -126,12 +171,28 @@ export const rules = [
|
||||
pattern: /from "\.\/timelineLivePreview\.js"/,
|
||||
message: "timeline drag must keep live preview behavior delegated to the extracted helper module",
|
||||
},
|
||||
{
|
||||
pattern: /from "\.\/timelineTouch\.js"/,
|
||||
message: "timeline drag must keep touch fallback and drag disambiguation delegated to the extracted helper module",
|
||||
},
|
||||
{
|
||||
pattern: /from "\.\/timelineMultiSelect\.js"/,
|
||||
message: "timeline drag must keep multi-select rectangle lifecycle delegated to the extracted helper module",
|
||||
},
|
||||
{
|
||||
pattern: /from "\.\/timelineRangeSelection\.js"/,
|
||||
message: "timeline drag must keep range preview and finalization delegated to the extracted helper module",
|
||||
},
|
||||
],
|
||||
forbidden: [
|
||||
{
|
||||
pattern: /\bfunction (?:toPxValue|joinTransforms|captureLivePreviewTargets|renderLivePreview|scheduleLivePreview|clearLivePreview|datesMatch|preserveLivePreview)\b/,
|
||||
message: "timeline drag must not re-inline live preview helper implementations",
|
||||
},
|
||||
{
|
||||
pattern: /\bfunction toClientX\b/,
|
||||
message: "timeline drag must not re-inline touch coordinate fallback helpers",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
|
||||
@@ -71,12 +71,21 @@ describe("architecture guardrails", () => {
|
||||
it("guards the extracted timeline live preview ownership boundary", () => {
|
||||
const dragRule = rules.find((rule) => rule.file === "apps/web/src/hooks/useTimelineDrag.ts");
|
||||
const livePreviewRule = rules.find((rule) => rule.file === "apps/web/src/hooks/timelineLivePreview.ts");
|
||||
const touchRule = rules.find((rule) => rule.file === "apps/web/src/hooks/timelineTouch.ts");
|
||||
const multiSelectRule = rules.find((rule) => rule.file === "apps/web/src/hooks/timelineMultiSelect.ts");
|
||||
const rangeRule = rules.find((rule) => rule.file === "apps/web/src/hooks/timelineRangeSelection.ts");
|
||||
|
||||
assert.ok(dragRule);
|
||||
assert.ok(livePreviewRule);
|
||||
assert.ok(touchRule);
|
||||
assert.ok(multiSelectRule);
|
||||
assert.ok(rangeRule);
|
||||
|
||||
assert.deepEqual(evaluateRule(dragRule, "function clearLivePreview() {}\n"), [
|
||||
"apps/web/src/hooks/useTimelineDrag.ts: missing guardrail anchor: timeline drag must keep live preview behavior delegated to the extracted helper module",
|
||||
"apps/web/src/hooks/useTimelineDrag.ts: missing guardrail anchor: timeline drag must keep touch fallback and drag disambiguation delegated to the extracted helper module",
|
||||
"apps/web/src/hooks/useTimelineDrag.ts: missing guardrail anchor: timeline drag must keep multi-select rectangle lifecycle delegated to the extracted helper module",
|
||||
"apps/web/src/hooks/useTimelineDrag.ts: missing guardrail anchor: timeline drag must keep range preview and finalization delegated to the extracted helper module",
|
||||
"apps/web/src/hooks/useTimelineDrag.ts: forbidden pattern matched: timeline drag must not re-inline live preview helper implementations",
|
||||
]);
|
||||
|
||||
@@ -84,5 +93,17 @@ describe("architecture guardrails", () => {
|
||||
"apps/web/src/hooks/timelineLivePreview.ts: missing guardrail anchor: timeline live preview helpers must keep preview reset logic centralized",
|
||||
"apps/web/src/hooks/timelineLivePreview.ts: missing guardrail anchor: timeline live preview helpers must keep snapshot preservation centralized",
|
||||
]);
|
||||
|
||||
assert.deepEqual(evaluateRule(touchRule, "export function getTouchPoint() {}\n"), [
|
||||
"apps/web/src/hooks/timelineTouch.ts: missing guardrail anchor: timeline touch helpers must keep scroll-vs-drag disambiguation centralized",
|
||||
]);
|
||||
|
||||
assert.deepEqual(evaluateRule(multiSelectRule, "export function createMultiSelectState() {}\n"), [
|
||||
"apps/web/src/hooks/timelineMultiSelect.ts: missing guardrail anchor: timeline multi-select helpers must keep minimal-drag reset logic centralized",
|
||||
]);
|
||||
|
||||
assert.deepEqual(evaluateRule(rangeRule, "export function updateRangeSelectionDraft() {}\n"), [
|
||||
"apps/web/src/hooks/timelineRangeSelection.ts: missing guardrail anchor: timeline range helpers must keep ordered range finalization centralized",
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user