refactor: enforce module boundaries in lint; remove the existing violations - #71
Merged
Merged
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #61.
Violations removed:
lstsv2ddi→xlsform2ddi/data.ts(buildDataCsv,Submission)src/ddi/data.ts: it works onVariable[]+ response records onlysrc/lstsv/validate.ts→src/xlsform/validate.ts(SubsetViolation)src/diagnostics.ts(re-exported fromxlsform/validate.ts)src/xlsform/parser.tsdynamicallyimport()ed thexlsform2lstsvpipelineXLSFormParseris pipeline code; it moved tosrc/pipelines/xlsform2lstsv/xlsformParser.tslstsv2xlsform→lstsv2ddi("other"/vocab helpers)src/conventions/in #70Enforcement:
eslint.config.jserrors on:It uses
no-restricted-imports, plusno-restricted-syntaxfor dynamicimport(), which the former doesn't see. The pipeline list is read fromsrc/pipelines/, so a new pipeline is covered automatically. I checked both rules against deliberate violations: each probe produced an error.ARCHITECTURE.mddocuments 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 validateis clean, with no cycles. pytest: 37 passed.🤖 Generated with Claude Code