refactor(web): extract project drag finalize

This commit is contained in:
2026-04-01 11:49:14 +02:00
parent 463caedcfd
commit 1e2bd3d4eb
5 changed files with 218 additions and 30 deletions
+28 -1
View File
@@ -412,6 +412,25 @@ export const rules = [
],
forbidden: [],
},
{
file: "apps/web/src/hooks/timelineProjectDragFinalize.ts",
maxLines: 60,
required: [
{
pattern: /\bexport function finalizeProjectDrag\b/,
message: "timeline project drag finalize helpers must keep completion flow centralized",
},
{
pattern: /from "\.\/timelineProjectDrag\.js"/,
message: "timeline project drag finalize helpers must keep mutation gating delegated to the project drag helper module",
},
{
pattern: /from "\.\/timelineLivePreview\.js"/,
message: "timeline project drag finalize helpers must keep preview preservation delegated to the live preview helper module",
},
],
forbidden: [],
},
{
file: "apps/web/src/hooks/timelineProjectDragSession.ts",
maxLines: 70,
@@ -484,7 +503,11 @@ export const rules = [
},
{
pattern: /from "\.\/timelineProjectDrag\.js"/,
message: "timeline drag must keep project drag bootstrap and mutation gating delegated to the extracted helper module",
message: "timeline drag must keep project drag bootstrap delegated to the extracted helper module",
},
{
pattern: /from "\.\/timelineProjectDragFinalize\.js"/,
message: "timeline drag must keep project drag completion delegated to the extracted helper module",
},
{
pattern: /from "\.\/timelineProjectDragSession\.js"/,
@@ -544,6 +567,10 @@ export const rules = [
pattern: /\bfunction (?:createProjectDragState|buildProjectShiftMutationInput)\b/,
message: "timeline drag must not re-inline extracted project drag helper implementations",
},
{
pattern: /\bconst mutationInput = buildProjectShiftMutationInput\(finalDrag\)\b[\s\S]*applyShiftMutation\.(?:mutate|mutateAsync)\(/,
message: "timeline drag must not re-inline extracted project drag finalize flow",
},
],
},
{
+14 -2
View File
@@ -94,6 +94,9 @@ describe("architecture guardrails", () => {
(rule) => rule.file === "apps/web/src/hooks/timelineAllocationReleaseEffects.ts",
);
const projectDragRule = rules.find((rule) => rule.file === "apps/web/src/hooks/timelineProjectDrag.ts");
const projectDragFinalizeRule = rules.find(
(rule) => rule.file === "apps/web/src/hooks/timelineProjectDragFinalize.ts",
);
const projectDragSessionRule = rules.find((rule) => rule.file === "apps/web/src/hooks/timelineProjectDragSession.ts");
assert.ok(dragRule);
@@ -117,6 +120,7 @@ describe("architecture guardrails", () => {
assert.ok(allocationDragSessionRule);
assert.ok(allocationReleaseEffectsRule);
assert.ok(projectDragRule);
assert.ok(projectDragFinalizeRule);
assert.ok(projectDragSessionRule);
assert.deepEqual(evaluateRule(dragRule, "function clearLivePreview() {}\n"), [
@@ -134,7 +138,8 @@ describe("architecture guardrails", () => {
"apps/web/src/hooks/useTimelineDrag.ts: missing guardrail anchor: timeline drag must keep allocation drag bootstrap delegated to the extracted helper module",
"apps/web/src/hooks/useTimelineDrag.ts: missing guardrail anchor: timeline drag must keep allocation drag document session wiring delegated to the extracted helper module",
"apps/web/src/hooks/useTimelineDrag.ts: missing guardrail anchor: timeline drag must keep allocation release side effects delegated to the extracted helper module",
"apps/web/src/hooks/useTimelineDrag.ts: missing guardrail anchor: timeline drag must keep project drag bootstrap and mutation gating delegated to the extracted helper module",
"apps/web/src/hooks/useTimelineDrag.ts: missing guardrail anchor: timeline drag must keep project drag bootstrap delegated to the extracted helper module",
"apps/web/src/hooks/useTimelineDrag.ts: missing guardrail anchor: timeline drag must keep project drag completion delegated to the extracted helper module",
"apps/web/src/hooks/useTimelineDrag.ts: missing guardrail anchor: timeline drag must keep project drag document session wiring 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",
]);
@@ -233,6 +238,12 @@ describe("architecture guardrails", () => {
"apps/web/src/hooks/timelineProjectDrag.ts: missing guardrail anchor: timeline project drag helpers must keep no-op project-shift mutation gating centralized",
]);
assert.deepEqual(evaluateRule(projectDragFinalizeRule, ""), [
"apps/web/src/hooks/timelineProjectDragFinalize.ts: missing guardrail anchor: timeline project drag finalize helpers must keep completion flow centralized",
"apps/web/src/hooks/timelineProjectDragFinalize.ts: missing guardrail anchor: timeline project drag finalize helpers must keep mutation gating delegated to the project drag helper module",
"apps/web/src/hooks/timelineProjectDragFinalize.ts: missing guardrail anchor: timeline project drag finalize helpers must keep preview preservation delegated to the live preview helper module",
]);
assert.deepEqual(evaluateRule(projectDragSessionRule, ""), [
"apps/web/src/hooks/timelineProjectDragSession.ts: missing guardrail anchor: timeline project drag session helpers must keep document drag lifecycle centralized",
]);
@@ -257,7 +268,8 @@ describe("architecture guardrails", () => {
"apps/web/src/hooks/useTimelineDrag.ts: missing guardrail anchor: timeline drag must keep allocation drag bootstrap delegated to the extracted helper module",
"apps/web/src/hooks/useTimelineDrag.ts: missing guardrail anchor: timeline drag must keep allocation drag document session wiring delegated to the extracted helper module",
"apps/web/src/hooks/useTimelineDrag.ts: missing guardrail anchor: timeline drag must keep allocation release side effects delegated to the extracted helper module",
"apps/web/src/hooks/useTimelineDrag.ts: missing guardrail anchor: timeline drag must keep project drag bootstrap and mutation gating delegated to the extracted helper module",
"apps/web/src/hooks/useTimelineDrag.ts: missing guardrail anchor: timeline drag must keep project drag bootstrap delegated to the extracted helper module",
"apps/web/src/hooks/useTimelineDrag.ts: missing guardrail anchor: timeline drag must keep project drag completion delegated to the extracted helper module",
"apps/web/src/hooks/useTimelineDrag.ts: missing guardrail anchor: timeline drag must keep project drag document session wiring delegated to the extracted helper module",
"apps/web/src/hooks/useTimelineDrag.ts: forbidden pattern matched: timeline drag must not re-inline extracted touch event forwarding dependencies",
],