Skip to content

Refactor duplicated helpers and fix local lint traversal - #23

Merged
bwin merged 3 commits into
devfrom
refactor/dedupe-helpers
Nov 8, 2026
Merged

bwin merged 3 commits into
devfrom
refactor/dedupe-helpers

Conversation

@bwin

@bwin bwin commented Nov 8, 2026 •

Copy link
Copy Markdown
Owner

Summary

Behavior-preserving refactor that removes duplicated helper logic across the library, demo, and tests. It also fixes local lint/format checks so they no longer traverse ignored .claude/worktrees.

Library

  • Share subject normalization in subjectList() and reuse subjectExists() in emphasis().
  • Share tooltip anchor math, subject index lookup, and balance-row markup in SankeyDiagram.
  • Share ghost attribute scoping and fallback amount formatting in presentation.
  • Share layout validation errors and minimum-width growth logic.
  • Extract the crossing predicate in paths.

Demo and tests

  • Add demo/format.ts for the formatter previously copied in three demo files.
  • Reuse showConverted() and same() instead of maintaining demo-local copies.
  • Add tests/helpers.ts for the shared error() assertion used by the core and unit suites.

Tooling

  • Ignore .claude/, playwright-report/, and test-results/ in ESLint.
  • Ignore .claude/ in Prettier.

Follow-up hardening

  • Treat absent subjects as distinct in same() and cover it with regression tests.
  • Keep emphasis() strict for malformed subject entries while sharing the existence logic.
  • Build minLinkWidth expansion errors only after a failed width check.

Verification

  • npm run typecheck
  • npm run lint
  • npm run format:check
  • npm test - 169/169 passed
  • npm run build
  • npm run test:browser - 17/17 passed
  • npm run verify:package

No rendered output, default styling, public API, or package contents changed, so no screenshots are included.

bwin added 3 commits November 8, 2026 12:34
Share subject normalization, tooltip anchors, balance rows, ghost attribute scoping, fallback amount formatting, validation errors, minimum-width growth and crossing predicates. Reuse the demo formatter and showConverted helper, and share the test input-error assertion.
ESLint and Prettier were traversing ignored .claude/worktrees copies, producing unrelated failures. Ignore that directory plus generated Playwright output.
Treat absent subjects as distinct in same(), keep emphasis() strict for malformed entries while retaining shared existence logic, and build minLinkWidth error messages only after a failed width check. Add regression coverage for the subject helpers.
@bwin
bwin merged commit 30816cd into dev Nov 8, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant