Skip to content

feat: read types in scriptlets and after extra whitespace - #254

Merged
DylanPiercey merged 1 commit into
dpiercey-ws-marko-invariants-jcdpv7-parserfixes-operatorsfrom
dpiercey-ws-marko-invariants-jcdpv7-parserfixes-types
Sep 28, 2026
Merged

DylanPiercey merged 1 commit into
dpiercey-ws-marko-invariants-jcdpv7-parserfixes-operatorsfrom
dpiercey-ws-marko-invariants-jcdpv7-parserfixes-types

Conversation

@DylanPiercey

@DylanPiercey DylanPiercey commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

A scriptlet never looked for declare/interface/type, so $ type H = () => void or $ type A = B<C> swallowed the next line, and a statement missed the keyword after extra spaces (static type F = () => void). Scriptlets and statements now share one look-ahead that skips spaces and requires a name after the keyword (or {/* after type), so $ type = a < b and $ type in obj stay JavaScript. isValidScriptlet uses it too.

🤖 Generated with Claude Code

A scriptlet never looked for `declare`/`interface`/`type`, so a type in one
was lexed as JavaScript and a line-final `void` or `>` carried it into the
next line: `$ type H = () => void` followed by `<div/>` became one scriptlet.
Statements looked for the keyword only exactly one character past the tag
name, so `static  type F = () => void` missed it the same way.

Scriptlets and statements now share `prepareScriptlet`, which skips spaces
before the keyword and requires a name after it (or `{`/`*` after `type`,
as in `import type { A }`), so `$ type = a < b` and `$ type in obj` stay
JavaScript. `isValidScriptlet` uses it too.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@changeset-bot

changeset-bot Bot commented Sep 28, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 6109ab6

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

This PR includes changesets to release 1 package
Name Type
htmljs-parser Minor

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

@DylanPiercey
DylanPiercey added this pull request to stack #257 September 28, 2026 16:36
@coderabbitai

coderabbitai Bot commented Sep 28, 2026

Copy link
Copy Markdown

Warning

Review limit reached

  • Run on-demand review

This review includes 9 billable files and costs up to $2.25.

  • Ask an admin to make reviews automatic

Open in CodeRabbit

Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing.

Or wait 59 minutes for your next included review.

Check out review usage here.

View limit details

Limit details: You’ve used all 2 included reviews currently available. Your 51 included PR review attempts over the past 7 days set your current allowance at 2 reviews per hour.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Essentials

Run ID: 323fa3fd-7b86-4bc2-bfb2-7b35c3b503ee

📥 Commits

Reviewing files that changed from the base of the PR and between c821771 and 6109ab6.

⛔ Files ignored due to path filters (3)
  • src/__tests__/fixtures/scriptlet-type-name-guard/__snapshots__/scriptlet-type-name-guard.expected.txt is excluded by !**/__snapshots__/** and included by **
  • src/__tests__/fixtures/scriptlet-type-void/__snapshots__/scriptlet-type-void.expected.txt is excluded by !**/__snapshots__/** and included by **
  • src/__tests__/fixtures/ts-type-statement-extra-whitespace/__snapshots__/ts-type-statement-extra-whitespace.expected.txt is excluded by !**/__snapshots__/** and included by **
📒 Files selected for processing (9)
  • .changeset/scriptlet-and-spaced-type-statements.md
  • src/__tests__/fixtures/scriptlet-type-name-guard/input.marko
  • src/__tests__/fixtures/scriptlet-type-void/input.marko
  • src/__tests__/fixtures/ts-type-statement-extra-whitespace/input.marko
  • src/__tests__/validate.test.ts
  • src/states/EXPRESSION.ts
  • src/states/INLINE_SCRIPT.ts
  • src/states/TAG_NAME.ts
  • src/util/validators.ts

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

@codecov

codecov Bot commented Sep 28, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.38462% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 99.89%. Comparing base (c821771) to head (6109ab6).

Files with missing lines Patch % Lines
src/states/INLINE_SCRIPT.ts 95.08% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@                                      Coverage Diff                                      @@
##           dpiercey-ws-marko-invariants-jcdpv7-parserfixes-operators     #254      +/-   ##
=============================================================================================
- Coverage                                                      99.95%   99.89%   -0.07%     
=============================================================================================
  Files                                                             35       35              
  Lines                                                           4652     4695      +43     
  Branches                                                         896      907      +11     
=============================================================================================
+ Hits                                                            4650     4690      +40     
- Misses                                                             2        4       +2     
- Partials                                                           0        1       +1     

☔ 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.

@DylanPiercey
DylanPiercey merged commit 0602e70 into main Sep 28, 2026
9 of 11 checks passed
@github-actions github-actions Bot mentioned this pull request Sep 28, 2026
@DylanPiercey DylanPiercey self-assigned this Oct 2, 2026
@github-project-automation github-project-automation Bot moved this to Todo 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