refactor(lstsv): single source for the TSV column list - #72
Merged
Merged
Conversation
The columns were listed four times: the TSVRow interface, generateTSV()'s fixed headers, its attribute-column array, and a duplicate TSVRowData interface in xlsform2lstsv/constants.ts. src/lstsv/columns.ts now holds BASE_COLUMNS and ATTRIBUTE_COLUMNS (as const, with each attribute's source documented). TSVRow is derived from them, the serializer builds its header from them, and TSVRowData is an alias of TSVRow. The dead `typeof value !== 'string'` check in escapeForTSV is gone. On the issue's codegen idea: the column order is part of the snapshots, and two attributes (cssclass, hide_tip) aren't registry-driven. So a test checks instead that every LimeSurvey attribute the registry names (dateFormat, parameterAttributes, integerOnly, exclusiveChoice) is in ATTRIBUTE_COLUMNS, and a new one fails the build rather than being dropped silently. Output unchanged: every TSV snapshot is byte-identical. Closes #65 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 #65.
The TSV columns were listed in four places: the
TSVRowinterface, the fixedheaders, the attribute-column array, and a duplicateTSVRowDatainterface inxlsform2lstsv/constants.ts. They're now in one:src/lstsv/columns.ts.BASE_COLUMNSandATTRIBUTE_COLUMNSareas const, with each attribute's source documented.TSVRowis derived from them, andTSVRowDatais now an alias of it.The dead
typeof value !== 'string'check inescapeForTSVis removed.On codegen emitting the attribute list: I didn't do this.
cssclassandhide_tiparen't registry-driven.Instead,
tests/ts/unit/lstsv/columns.test.tschecks that every LimeSurvey attribute the registry names (dateFormat,parameterAttributes,integerOnly,exclusiveChoice) is inATTRIBUTE_COLUMNS. A new registry attribute fails the build instead of being dropped silently.Output: unchanged. Every TSV snapshot is byte-identical after re-blessing.
Tests: vitest 881 passed.
npm run validateis clean.🤖 Generated with Claude Code