Skip to content

fix(lint): never throw on odd frontmatter or huge entities, and place and find diagnostics correctly - #43

Merged
vitehub-bot[bot] merged 3 commits into
mainfrom
fix/lint-review
Oct 20, 2026
Merged

vitehub-bot[bot] merged 3 commits into
mainfrom
fix/lint-review

Conversation

@onmax

@onmax onmax commented Oct 20, 2026

Copy link
Copy Markdown
Owner

Follows #38. Fixes the review findings on comark-lint. Each one has a regression test that goes through lint().

  1. Crash on ---title: x\n---\n::bad. source.ts now applies Comark's frontmatter rule: the YAML starts at the fifth character, even on the first line, and an empty block isn't stripped. Token lines are offset by the closing --- line, the line Comark's remaining content starts on, instead of state.parsedLines, which miscounts this case. The token-to-source lookups are guarded. lint() also runs each rule on its own, so a rule that crashes reports one diagnostic under its own rule id (naming the error and where to report it) and the other rules still run.
  2. Crash on &#99999999999…;. A character reference past U+10FFFF, including one so long it parses as Infinity, decodes to U+FFFD as in a browser. Before, % 0x110000 turned Infinity into NaN.
  3. comark/unclosed-block false positives. Lines in html_block, code_block, and fence tokens are skipped by comark/unclosed-block and comark/malformed-attributes. I couldn't trigger the indented-code case, because the opener pattern already needs three spaces or fewer. The skip covers it anyway, and it also covers fences nested deeper than the source scan sees.
  4. Unknown component misses. mdc_block_shorthand openers count as block components, so :badge[x] at the start of a line, nested or not, gets reported. An inline token without a map takes its block's map, so :chip inside :pill[see :chip[y]] is found too. This also numbers shorthand blocks for comark/plugin-issue placement.
  5. Diagnostics on the first match in the source. Unsafe URLs and broken anchors are now matched only where the value starts an attribute or link, after ", ', =, (, or <. The same text in prose is skipped. I chose this over tracking element line ranges because Comark nodes carry no positions, and mapping elements back to tokens would take far more code. The check also gets two links on the same line right, which line ranges wouldn't.
  6. Duplicate attributes after a nested brace value. The {…} scanner understands nesting and \ escapes inside quotes. It both finds the closing } and splits the attributes, so [x]{foo={"x":"}"} foo=2} reports foo twice. This matches how Comark parses it (it keeps foo=2).

The docs page says how a crashing rule reports itself, that HTML blocks are skipped, and how URLs are placed.

pnpm ready passes: 156 tests, Vite Doctor clean. The two unbound-method warnings in e2e/annotate.e2e.ts are already on main.

🤖 Generated with Claude Code

… and find diagnostics correctly

- Take the frontmatter's closing line the way Comark does, so YAML on the `---` line no longer shifts token lines past the source.
- Run each rule on its own; a rule that crashes reports one diagnostic and the others still run.
- Read character references past U+10FFFF as U+FFFD instead of throwing.
- Skip HTML blocks and code in comark/unclosed-block and comark/malformed-attributes.
- Report `:name[…]` shorthand blocks and components inside them as unknown components.
- Place unsafe URLs and broken anchors where they start an attribute or link, not on the same text in prose.
- Read attribute values with nested braces and escaped quotes, so a key set twice after one is still found.
@vitehub-bot

vitehub-bot Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor
Session Status Started Duration
Pending Completed Not started —

Latest result

Pull request merged.

Final answers

Session

Pull request merged.

Session

Waiting for GitHub merge request 244d772d-0d09-4ab6-af06-f57770db79b5.

Session

Updated the branch with main because main changed packages/lint/test/lint.test.ts after its checks ran; waiting for checks on the new head.

Session

Updated the branch with main because main changed packages/lint/test/lint.test.ts after its checks ran; waiting for checks on the new head.

Session

Updated the branch with main because main changed packages/lint/test/lint.test.ts after its checks ran; waiting for checks on the new head.

Session

Updated the branch with main because main changed packages/lint/test/lint.test.ts after its checks ran; waiting for checks on the new head.

Session

Updated the branch with main because main changed packages/lint/test/lint.test.ts after its checks ran; waiting for checks on the new head.

Session

Updated the branch with main because main changed packages/lint/test/lint.test.ts after its checks ran; waiting for checks on the new head.

Session

Updated the branch with main because main changed packages/lint/test/lint.test.ts after its checks ran; waiting for checks on the new head.

Session

Updated the branch with main because main changed packages/lint/test/lint.test.ts after its checks ran; waiting for checks on the new head.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

  • Rule isolation — Crashing lint rules now produce a diagnostic while allowing the remaining rules to run.
  • Source and token mapping — Frontmatter offsets, raw HTML/code ranges, shorthand components, and nested attribute scanning now follow Comark's parser behavior.
  • Diagnostic placement and URL decoding — Anchor and unsafe URL matches are constrained to attribute values, and oversized numeric entities decode safely.
  • Regression coverage and documentation — The changed behaviors are covered through the public lint() interface and described in the lint docs.

Pullfrog  | View workflow run | Using gpt-5.6-sol | 𝕏

@pkg-pr-new

pkg-pr-new Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

comark-annotate

pnpm add https://pkg.pr.new/onmax/comark-plugins/comark-annotate@43

comark-carousel

pnpm add https://pkg.pr.new/onmax/comark-plugins/comark-carousel@43

comark-embed

pnpm add https://pkg.pr.new/onmax/comark-plugins/comark-embed@43

comark-github-callouts

pnpm add https://pkg.pr.new/onmax/comark-plugins/comark-github-callouts@43

comark-include

pnpm add https://pkg.pr.new/onmax/comark-plugins/comark-include@43

comark-lint

pnpm add https://pkg.pr.new/onmax/comark-plugins/comark-lint@43

comark-tabs

pnpm add https://pkg.pr.new/onmax/comark-plugins/comark-tabs@43

comark-zoom

pnpm add https://pkg.pr.new/onmax/comark-plugins/comark-zoom@43

commit: 1cda18f

@vitehub-bot
vitehub-bot Bot merged commit 4c57fb5 into main Oct 20, 2026
9 checks passed
@github-actions github-actions Bot mentioned this pull request Oct 20, 2026
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