Skip to content

refactor: enforce module boundaries in lint; remove the existing violations - #71

Merged
jstet merged 1 commit into
mainfrom
refactor/61-boundaries
Sep 25, 2026
Merged

jstet merged 1 commit into
mainfrom
refactor/61-boundaries

Conversation

@jstet

@jstet jstet commented Sep 25, 2026

Copy link
Copy Markdown
Member

Closes #61.

Violations removed:

Was Now
lstsv2ddi → xlsform2ddi/data.ts (buildDataCsv, Submission) moved to src/ddi/data.ts: it works on Variable[] + response records only
src/lstsv/validate.ts → src/xlsform/validate.ts (SubsetViolation) moved to src/diagnostics.ts (re-exported from xlsform/validate.ts)
src/xlsform/parser.ts dynamically import()ed the xlsform2lstsv pipeline XLSFormParser is pipeline code; it moved to src/pipelines/xlsform2lstsv/xlsformParser.ts
lstsv2xlsform → lstsv2ddi ("other"/vocab helpers) already moved to src/conventions/ in #70

Enforcement: eslint.config.js errors on:

  • a format module importing another format module or a pipeline;
  • a pipeline importing a sibling pipeline.

It uses no-restricted-imports, plus no-restricted-syntax for dynamic import(), which the former doesn't see. The pipeline list is read from src/pipelines/, so a new pipeline is covered automatically. I checked both rules against deliberate violations: each probe produced an error. ARCHITECTURE.md documents the rules and where shared code goes.

Public API: unchanged; the same names are exported from the package root.

Tests: vitest 879 passed (including the browser bundle). npm run validate is clean, with no cycles. pytest: 37 passed.

🤖 Generated with Claude Code

…ations

ARCHITECTURE.md's rules (format modules don't import each other or a
pipeline; a pipeline doesn't import a sibling) were unenforced, and broken:

- lstsv2ddi imported buildDataCsv/Submission from xlsform2ddi. The data CSV
  code works on Variable[] and response records only, so it moves to
  src/ddi/data.ts (tests with it).
- src/lstsv/validate.ts imported SubsetViolation from src/xlsform. It moves to
  src/diagnostics.ts; src/xlsform/validate.ts re-exports it.
- src/xlsform/parser.ts (XLSFormParser) dynamically imported the xlsform2lstsv
  pipeline. It's pipeline code, so it moves to
  src/pipelines/xlsform2lstsv/xlsformParser.ts with a static import.
- The "other"/vocab helpers lstsv2xlsform took from lstsv2ddi already moved
  to src/conventions/ in #60.

eslint.config.js now errors on a format → format/pipeline import and on a
pipeline → sibling pipeline import (no-restricted-imports; no-restricted-syntax
for dynamic import()). The pipeline list is read from src/pipelines/. Both
rules were checked against deliberate violations.

Public exports are unchanged (same names from the package root).

Closes #61

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@jstet
jstet merged commit 067ea50 into main Sep 25, 2026
4 checks passed
@jstet
jstet deleted the refactor/61-boundaries branch September 25, 2026 11:01
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.

refactor: enforce module boundaries (no pipeline→pipeline or format→format imports)

1 participant