refactor(web): extract drag position helpers
This commit is contained in:
@@ -292,6 +292,21 @@ export const rules = [
|
||||
],
|
||||
forbidden: [],
|
||||
},
|
||||
{
|
||||
file: "apps/web/src/hooks/timelineDragPosition.ts",
|
||||
maxLines: 80,
|
||||
required: [
|
||||
{
|
||||
pattern: /\bexport function resolveProjectDragPosition\b/,
|
||||
message: "timeline drag position helpers must keep project drag date derivation centralized",
|
||||
},
|
||||
{
|
||||
pattern: /\bexport function resolveAllocationDragPosition\b/,
|
||||
message: "timeline drag position helpers must keep allocation drag date derivation centralized",
|
||||
},
|
||||
],
|
||||
forbidden: [],
|
||||
},
|
||||
{
|
||||
file: "apps/web/src/hooks/timelineDocumentDrag.ts",
|
||||
maxLines: 50,
|
||||
@@ -383,6 +398,10 @@ export const rules = [
|
||||
pattern: /from "\.\/timelineDragCleanup\.js"/,
|
||||
message: "timeline drag must keep unmount teardown delegated to the extracted helper module",
|
||||
},
|
||||
{
|
||||
pattern: /from "\.\/timelineDragPosition\.js"/,
|
||||
message: "timeline drag must keep project and allocation drag position derivation delegated to the extracted helper module",
|
||||
},
|
||||
{
|
||||
pattern: /from "\.\/timelineDocumentDrag\.js"/,
|
||||
message: "timeline drag must keep document mouse listener lifecycle delegated to the extracted helper module",
|
||||
@@ -433,6 +452,10 @@ export const rules = [
|
||||
pattern: /\bfunction attachDocumentMouseDrag\b/,
|
||||
message: "timeline drag must not re-inline extracted document listener helper implementations",
|
||||
},
|
||||
{
|
||||
pattern: /\bconst (?:deltaX|pointerDeltaX) = clientX - (?:drag|alloc)\.startMouseX;[\s\S]*computeDragDates\(/,
|
||||
message: "timeline drag must not re-inline extracted project or allocation drag position helpers",
|
||||
},
|
||||
{
|
||||
pattern: /\bfunction (?:isAllocationMultiSelected|startAllocationMultiDrag|updateAllocationMultiDrag|finalizeAllocationMultiDrag)\b/,
|
||||
message: "timeline drag must not re-inline extracted allocation multi-drag helper implementations",
|
||||
|
||||
@@ -82,6 +82,7 @@ describe("architecture guardrails", () => {
|
||||
const allocationActionsRule = rules.find((rule) => rule.file === "apps/web/src/hooks/timelineAllocationActions.ts");
|
||||
const allocationReleaseRule = rules.find((rule) => rule.file === "apps/web/src/hooks/timelineAllocationRelease.ts");
|
||||
const cleanupRule = rules.find((rule) => rule.file === "apps/web/src/hooks/timelineDragCleanup.ts");
|
||||
const positionRule = rules.find((rule) => rule.file === "apps/web/src/hooks/timelineDragPosition.ts");
|
||||
const documentDragRule = rules.find((rule) => rule.file === "apps/web/src/hooks/timelineDocumentDrag.ts");
|
||||
const allocationDragStateRule = rules.find((rule) => rule.file === "apps/web/src/hooks/timelineAllocationDragState.ts");
|
||||
const projectDragRule = rules.find((rule) => rule.file === "apps/web/src/hooks/timelineProjectDrag.ts");
|
||||
@@ -100,6 +101,7 @@ describe("architecture guardrails", () => {
|
||||
assert.ok(allocationActionsRule);
|
||||
assert.ok(allocationReleaseRule);
|
||||
assert.ok(cleanupRule);
|
||||
assert.ok(positionRule);
|
||||
assert.ok(documentDragRule);
|
||||
assert.ok(allocationDragStateRule);
|
||||
assert.ok(projectDragRule);
|
||||
@@ -116,6 +118,7 @@ describe("architecture guardrails", () => {
|
||||
"apps/web/src/hooks/useTimelineDrag.ts: missing guardrail anchor: timeline drag must keep allocation drag completion rules delegated to the extracted helper module",
|
||||
"apps/web/src/hooks/useTimelineDrag.ts: missing guardrail anchor: timeline drag must keep allocation release classification delegated to the extracted helper module",
|
||||
"apps/web/src/hooks/useTimelineDrag.ts: missing guardrail anchor: timeline drag must keep unmount teardown delegated to the extracted helper module",
|
||||
"apps/web/src/hooks/useTimelineDrag.ts: missing guardrail anchor: timeline drag must keep project and allocation drag position derivation delegated to the extracted helper module",
|
||||
"apps/web/src/hooks/useTimelineDrag.ts: missing guardrail anchor: timeline drag must keep document mouse listener lifecycle delegated to the extracted helper module",
|
||||
"apps/web/src/hooks/useTimelineDrag.ts: missing guardrail anchor: timeline drag must keep allocation multi-drag rules delegated to the extracted helper module",
|
||||
"apps/web/src/hooks/useTimelineDrag.ts: missing guardrail anchor: timeline drag must keep allocation drag bootstrap delegated to the extracted helper module",
|
||||
@@ -180,6 +183,10 @@ describe("architecture guardrails", () => {
|
||||
"apps/web/src/hooks/timelineDragCleanup.ts: missing guardrail anchor: timeline drag cleanup helpers must keep unmount teardown centralized",
|
||||
]);
|
||||
|
||||
assert.deepEqual(evaluateRule(positionRule, "export function resolveProjectDragPosition() {}\n"), [
|
||||
"apps/web/src/hooks/timelineDragPosition.ts: missing guardrail anchor: timeline drag position helpers must keep allocation drag date derivation centralized",
|
||||
]);
|
||||
|
||||
assert.deepEqual(evaluateRule(documentDragRule, ""), [
|
||||
"apps/web/src/hooks/timelineDocumentDrag.ts: missing guardrail anchor: timeline document drag helpers must keep document mouse listener wiring centralized",
|
||||
]);
|
||||
@@ -211,6 +218,7 @@ describe("architecture guardrails", () => {
|
||||
"apps/web/src/hooks/useTimelineDrag.ts: missing guardrail anchor: timeline drag must keep allocation drag completion rules delegated to the extracted helper module",
|
||||
"apps/web/src/hooks/useTimelineDrag.ts: missing guardrail anchor: timeline drag must keep allocation release classification delegated to the extracted helper module",
|
||||
"apps/web/src/hooks/useTimelineDrag.ts: missing guardrail anchor: timeline drag must keep unmount teardown delegated to the extracted helper module",
|
||||
"apps/web/src/hooks/useTimelineDrag.ts: missing guardrail anchor: timeline drag must keep project and allocation drag position derivation delegated to the extracted helper module",
|
||||
"apps/web/src/hooks/useTimelineDrag.ts: missing guardrail anchor: timeline drag must keep document mouse listener lifecycle delegated to the extracted helper module",
|
||||
"apps/web/src/hooks/useTimelineDrag.ts: missing guardrail anchor: timeline drag must keep allocation multi-drag rules delegated to the extracted helper module",
|
||||
"apps/web/src/hooks/useTimelineDrag.ts: missing guardrail anchor: timeline drag must keep allocation drag bootstrap delegated to the extracted helper module",
|
||||
|
||||
Reference in New Issue
Block a user