Skip to content

fix: move a tag var's trailing line comment into a block comment - #153

Merged
DylanPiercey merged 1 commit into
mainfrom
dpiercey-ws-prettier-marko-async-ulp3vg-tag-var-line-comment
Sep 23, 2026
Merged

DylanPiercey merged 1 commit into
mainfrom
dpiercey-ws-prettier-marko-async-ulp3vg-tag-var-line-comment

Conversation

@DylanPiercey

Copy link
Copy Markdown
Contributor

htmljs-parser folds a trailing // comment into a tag var, which the compiler now accepts (marko-js/marko#4242). The TagVar embed formatted it as var ${code}=_, putting the =_ inside the comment, so it fell back to printing the source, where the comment swallowed the rest of the open tag (<a/x // c/>). A tag var cannot be parenthesized like an attr value, so the comment is split off, using htmljs-parser's validators to find where it starts, and printed as a block comment after the var (<let/count /* total */=0>), which stays valid in both syntaxes, with and without a JS parser.

🤖 Generated with Claude Code

@changeset-bot

changeset-bot Bot commented Sep 23, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 0430259

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
prettier-plugin-marko Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@codecov

codecov Bot commented Sep 23, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.21%. Comparing base (d0ef393) to head (0430259).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #153      +/-   ##
==========================================
+ Coverage   98.17%   98.21%   +0.04%     
==========================================
  Files           8        8              
  Lines         329      337       +8     
  Branches       58       62       +4     
==========================================
+ Hits          323      331       +8     
  Misses          1        1              
  Partials        5        5              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@coderabbitai

coderabbitai Bot commented Sep 23, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Essentials

Run ID: 4d22d563-24ac-494d-8076-fe2c42689038

📥 Commits

Reviewing files that changed from the base of the PR and between 690eebc and 0430259.

⛔ Files ignored due to path filters (6)
  • src/__tests__/fixtures/open-tag-comments/__snapshots__/auto.expected.marko is excluded by !**/__snapshots__/** and included by **
  • src/__tests__/fixtures/open-tag-comments/__snapshots__/concise.expected.marko is excluded by !**/__snapshots__/** and included by **
  • src/__tests__/fixtures/open-tag-comments/__snapshots__/html.expected.marko is excluded by !**/__snapshots__/** and included by **
  • src/__tests__/fixtures/tag-var-line-comment/__snapshots__/auto.expected.marko is excluded by !**/__snapshots__/** and included by **
  • src/__tests__/fixtures/tag-var-line-comment/__snapshots__/concise.expected.marko is excluded by !**/__snapshots__/** and included by **
  • src/__tests__/fixtures/tag-var-line-comment/__snapshots__/html.expected.marko is excluded by !**/__snapshots__/** and included by **
📒 Files selected for processing (3)
  • src/__tests__/fixtures/tag-var-line-comment/template.marko
  • src/index.ts
  • src/utils/to-valid-doc.ts

Included review availability: 2 reviews are currently available. Your included PR review attempts over the past 7 days set your current allowance at 4 reviews per hour.


Walkthrough

The change adds splitTagVarComment to separate qualifying trailing line comments from tag-variable code. Tag-variable printing and JavaScript embedding use the extracted code and include the comment in formatted output. A fixture covers six declarations with line comments. The change also adds a patch changeset and removes the bug report.

Merge Risk: ⚪ Minimal · up to 04302

The formatting change is ready to merge after normal checks; no identified issue remains that would block it.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: moving a trailing tag variable line comment into a block comment.
Description check ✅ Passed The description directly explains the formatting bug, its cause, and the implemented fix. It is related to the changeset.
Docstring Coverage ✅ Passed Docstring coverage is 80.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 2 files. (1 skipped: 1 u…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

Comment @coderabbitai help to get the list of available commands.

htmljs-parser folds a trailing line comment into a tag var, and the embed
formatted it as `var ${code}=_`, putting the `=_` in the comment, so it fell
back to the source text, where the comment swallowed the rest of the open
tag. A tag var cannot be parenthesized like an attr value, so the comment is
split off, using htmljs-parser to find where it starts, and printed as a
block comment after the var, with and without a JS parser. A comment before
a default attr is glued to its `=` the same way, since after a tag var it
joins the var's comments on the next parse.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@DylanPiercey
DylanPiercey force-pushed the dpiercey-ws-prettier-marko-async-ulp3vg-tag-var-line-comment branch from 690eebc to 0430259 Compare September 23, 2026 20:21
@DylanPiercey
DylanPiercey merged commit da5a821 into main Sep 23, 2026
11 checks passed
@github-actions github-actions Bot mentioned this pull request Sep 23, 2026
@DylanPiercey
DylanPiercey deleted the dpiercey-ws-prettier-marko-async-ulp3vg-tag-var-line-comment branch September 23, 2026 20:40
@DylanPiercey DylanPiercey self-assigned this Oct 2, 2026
@DylanPiercey DylanPiercey moved this to Done in Roadmap Oct 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant