Repository navigation
test(Markdown): a transform that moves a block's lines but keeps its offsets is refused - #7360
Conversation
…offsets is refused
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
There was a problem hiding this comment.
This test-only change does what it says: the new case pins the validator's line check for blocks that keep their offsets, and it matches the source-lines rule that transforms cannot shift or forge lines. It fails when that check is removed (the moved paragraph is then stamped with the wrong lines), so it guards the real outcome. Nothing more is needed; optionally, two sibling cases that move only the start line or only the end line would pin each comparison separately, since dropping just one of them still passes today.
[Automated review]
PR Analysis Report📚 Storybook Preview🧪 Sandbox PreviewNo new or modified components detected. Bundle Size Summary
Accessibility AuditStatus: No accessibility violations detected. Generated by PR Enrichment workflow | Storybook | Sandbox | View full report |
Maintainer impact
The Markdown plugin validator compares a block's source lines when the block also carries offsets (
protocol.ts, thestartLine/endLinecomparison in the source-position check). No test failed when that comparison was removed, so a later edit could drop it silently. A transform could then move a top-level block to other lines, keep its offsets, and pass validation, andmarkdownSourceLinesPluginwould stamp the block with lines that don't match the source.Intended invariant
A transform plugin may rebuild nodes, but it may not change where a block sits in the source. A block whose recorded lines change is refused, whether or not it also has offsets, and the document renders as the plugin-only render does.
Change
One test in
sourceLines.test.tsx. A transform keeps a top-level paragraph's offsets but moves itslinefrom 20 to 19. The test asserts that the transform is refused and that the stamps match a plugin-only render. No production code changes.Evidence
pnpm exec vitest run packages/core/src/Markdown/plugins/sourceLines.test.tsx, 15 passed.Scope
Testing
pnpm exec vitest run packages/core/src/Markdown/plugins/sourceLines.test.tsx: 15 passed.tsc --noEmit -p packages/coreclean; pre-push checks green.