Skip to content

feat(readtext): add position-aware list parsing - #928

Merged
YusukeHirao merged 3 commits into
devfrom
feature/readtext-list-with-position
Jul 27, 2026
Merged

feat(readtext): add position-aware list parsing#928
YusukeHirao merged 3 commits into
devfrom
feature/readtext-list-with-position

Conversation

@YusukeHirao

Copy link
Copy Markdown
Member

Summary

  • Add toListWithPosition / readListWithPosition, position-aware companions to toList / readList that tag each surviving line with its 1-origin line/column in the source text
  • Reimplement toList on top of toListWithPosition so the blank-line/comment filtering rules stay in one place
  • Re-export the ListItem type from the ./list subpath so consumers can name it explicitly

Motivation

toList/readList strip blank lines and # comments before returning a plain string[], so a caller that needs to report "line 3 of the source file was invalid" back to a user cannot reconstruct the original line number from the filtered array — the index has already shifted. nitpicker's --inventory CLI flag needs exactly this (nitpicker/nitpicker#99: warn-and-skip invalid URL lines with their line:column instead of hard-erroring on the first bad line).

Test plan

  • yarn test — 1673 tests pass (118 files)
  • yarn lint — clean
  • yarn build — 28 projects build successfully
  • New to-list-with-position.spec.ts covers: line numbering across blank/comment lines, column position with leading whitespace (spaces and tabs), whitespace-only lines treated as blank, CRLF line endings, and the empty-result case

🤖 Generated with Claude Code

Add toListWithPosition/readListWithPosition returning each surviving
line's 1-origin line/column, so callers that reject invalid entries
can report which line of the source file they came from — toList's
plain string[] loses that mapping once blank/comment lines are
filtered out. toList is reimplemented on top of the new parser to
keep the filtering rules in one place.
Consumers that need to type an intermediate value as ListItem[]
(e.g. a caller partitioning valid/invalid entries) could not name
the type — list.ts re-exported the parsing functions but not their
shared item type.
README only covered readList/readGrid; the new position-aware
companion is a main public API addition and was missing from the
usage section.
@YusukeHirao
YusukeHirao requested a review from yusasa16 as a code owner July 27, 2026 03:51
@YusukeHirao
YusukeHirao merged commit f321fcc into dev Jul 27, 2026
6 checks passed
@YusukeHirao
YusukeHirao deleted the feature/readtext-list-with-position branch July 27, 2026 03:59
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