Repository navigation
Make table-syntax validation error location more precise - #605
Conversation
Table syntax errors were all reported at the table tag's location, making it hard to find the offending content. Now errors carry the location of the invalid node, and validateTree prefers it over the parent node's location. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]> Committed-By-Agent: claude
91e6af5 to
ee7ecb6
Compare
There was a problem hiding this comment.
Pull request overview
Improves Markdoc table-syntax validation diagnostics by reporting errors at the offending node location (instead of always pointing at the {% table %} tag), and bumps the package version for a future release.
Changes:
- Attach
locationtotable-syntaxValidationErrors based on the offending node in the table transform. - Update
validateTreeto preferValidationError.locationover the parent node’s location when producingValidateErrors. - Update table validation tests to assert the more precise error location; bump version to
0.5.7.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/validator.ts | Prefer error.location when emitting validation errors to improve pinpointing. |
| src/transforms/table.ts | Populate ValidationError.location from the offending AST node for table-syntax errors. |
| src/transforms/table.test.ts | Update assertions to expect errors to point to the invalid content. |
| package.json | Bump package version to 0.5.7. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]> Committed-By-Agent: claude
ee7ecb6 to
04a6a9d
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 5 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
…ocations Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]> Committed-By-Agent: claude
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 5 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
091acbb to
f03be80
Compare
f03be80 to
b6bf880
Compare
| if (hasValidLocation(error)) { | ||
| return { | ||
| type: node.type, | ||
| lines: [error.location.start.line, error.location.end.line], |
There was a problem hiding this comment.
lines is initially set by parser here:
Line 155 in 6b9dc5e
Without overriding the lines in this case, the line numbers in lines would be inconsistent with location.start.line and location.end.line
| "name": "@markdoc/markdoc", | ||
| "author": "Ryan Paul", | ||
| "version": "0.5.6", | ||
| "version": "0.5.7", |
There was a problem hiding this comment.
Can we bump the package separately of this change? I'll bump the version in a separate PR!
There was a problem hiding this comment.
I think this needs to be unbumped too!
There was a problem hiding this comment.
The version in package-lock was originally not matching the package.json (we're on 0.5.6) which Copilot flagged, so this PR still updates it to match- I'm not sure what ramifications there are for bumping this out of band
Summary & motivation
#603 added validation for invalid table syntax. However, all the errors report their location at the first line of the
{% table %}tag, making it hard to pinpoint where the actually invalid syntax is in large complex tables.This change attaches the offending node's location to the
ValidationErrorand updatesvalidateTreeto prefer it over the parent node's location.Also bumps version to 0.5.7 for a future release.
Test plan