Extract parser into new @marko/parse package - #586
Conversation
🦋 Changeset detectedLatest commit: b5aee91 The changes in this PR will be included in the next version bump. This PR includes changesets to release 4 packages
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 |
|
Warning Review limit reachedYou’ve reached a temporary PR review limit under our Fair Usage Limits Policy. Next review available in: 40 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (48)
📒 Files selected for processing (1)
WalkthroughThe parser was extracted into the new 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Comment |
333087e to
8c40f42
Compare
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/language-tools/src/extractors/script/index.ts`:
- Around line 520-533: The comment lookup used by the script extractor and
getRuntimeAPI must use one document-order traversal of program.body before
runtime heuristics, rather than relying on program.static[0].comments or
program.comments. Update the relevant logic in
packages/language-tools/src/extractors/script/index.ts (lines 520-533) and
packages/language-tools/src/extractors/script/util/get-runtime-api.ts (lines
100-112) so both consumers share this lookup and detect comments following
earlier static nodes; add regression coverage for an import preceding /* use
tags */ or /* use class */.
In `@packages/parse/package.json`:
- Around line 32-35: Update the package.json test script so it runs the existing
build script before invoking Mocha, ensuring package tests cannot execute
against stale or failed build output. Preserve the current Mocha test pattern
and reuse the existing build script rather than duplicating its command.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: e608d9e0-d644-4b8b-a4b5-a6e2d2886941
⛔ Files ignored due to path filters (29)
packages/language-server/src/__tests__/fixtures/script/attr-tags-dynamic-for-typed/__snapshots__/attr-tags-dynamic-for-typed.expected/index.tsis excluded by!**/__snapshots__/**and included by**packages/language-server/src/__tests__/fixtures/script/attr-tags-dynamic-for/__snapshots__/attr-tags-dynamic-for.expected/index.tsis excluded by!**/__snapshots__/**and included by**packages/language-server/src/__tests__/fixtures/script/attr-tags-dynamic-while/__snapshots__/attr-tags-dynamic-while.expected/index.tsis excluded by!**/__snapshots__/**and included by**packages/language-server/src/__tests__/fixtures/script/attr-tags-dynamic-with-scriptlets/__snapshots__/attr-tags-dynamic-with-scriptlets.expected/index.tsis excluded by!**/__snapshots__/**and included by**packages/language-server/src/__tests__/fixtures/script/attr-tags-for-narrowing/__snapshots__/attr-tags-for-narrowing.expected/index.tsis excluded by!**/__snapshots__/**and included by**packages/language-server/src/__tests__/fixtures/script/attr-tags-generic/__snapshots__/attr-tags-generic.expected/index.tsis excluded by!**/__snapshots__/**and included by**packages/language-server/src/__tests__/fixtures/script/attr-tags-nested-dynamic-for-typed/__snapshots__/attr-tags-nested-dynamic-for-typed.expected/index.tsis excluded by!**/__snapshots__/**and included by**packages/language-server/src/__tests__/fixtures/script/attr-tags-nested-type/__snapshots__/attr-tags-nested-type.expected/index.tsis excluded by!**/__snapshots__/**and included by**packages/language-server/src/__tests__/fixtures/script/attr-tags-params-js/__snapshots__/attr-tags-params-js.expected/index.jsis excluded by!**/__snapshots__/**and included by**packages/language-server/src/__tests__/fixtures/script/attr-tags-params/__snapshots__/attr-tags-params.expected/index.tsis excluded by!**/__snapshots__/**and included by**packages/language-server/src/__tests__/fixtures/script/attr-tags-static-dynamic-renderbody/__snapshots__/attr-tags-static-dynamic-renderbody.expected/index.tsis excluded by!**/__snapshots__/**and included by**packages/language-server/src/__tests__/fixtures/script/basic/__snapshots__/basic.expected/index.tsis excluded by!**/__snapshots__/**and included by**packages/language-server/src/__tests__/fixtures/script/el-ref-hoist/__snapshots__/el-ref-hoist.expected/index.tsis excluded by!**/__snapshots__/**and included by**packages/language-server/src/__tests__/fixtures/script/for-tag-input/__snapshots__/for-tag-input.expected/index.tsis excluded by!**/__snapshots__/**and included by**packages/language-server/src/__tests__/fixtures/script/for-tag/__snapshots__/for-tag.expected/index.tsis excluded by!**/__snapshots__/**and included by**packages/language-server/src/__tests__/fixtures/script/leading-comment-pragma/__snapshots__/leading-comment-pragma.expected/index.htmlis excluded by!**/__snapshots__/**and included by**packages/language-server/src/__tests__/fixtures/script/leading-comment-pragma/__snapshots__/leading-comment-pragma.expected/index.mdis excluded by!**/__snapshots__/**and included by**packages/language-server/src/__tests__/fixtures/script/leading-comment-pragma/__snapshots__/leading-comment-pragma.expected/index.tsis excluded by!**/__snapshots__/**and included by**packages/language-server/src/__tests__/fixtures/script/mutate-within-attr-tag/__snapshots__/mutate-within-attr-tag.expected/index.tsis excluded by!**/__snapshots__/**and included by**packages/language-server/src/__tests__/fixtures/script/recursive-define-tag/__snapshots__/recursive-define-tag.expected/index.tsis excluded by!**/__snapshots__/**and included by**packages/language-server/src/__tests__/fixtures/script/return-as-type/__snapshots__/return-as-type.expected/index.tsis excluded by!**/__snapshots__/**and included by**packages/language-server/src/__tests__/fixtures/script/return-tag-nested/__snapshots__/return-tag-nested.expected/index.tsis excluded by!**/__snapshots__/**and included by**packages/language-server/src/__tests__/fixtures/script/tag-params-basic/__snapshots__/tag-params-basic.expected/index.tsis excluded by!**/__snapshots__/**and included by**packages/language-server/src/__tests__/fixtures/script/tag-params-with-generics/__snapshots__/tag-params-with-generics.expected/index.tsis excluded by!**/__snapshots__/**and included by**packages/language-server/src/__tests__/fixtures/script/tag-type-params/__snapshots__/tag-type-params.expected/index.tsis excluded by!**/__snapshots__/**and included by**packages/language-server/src/__tests__/fixtures/script/tag-var-hoisting-from-control-flow/__snapshots__/tag-var-hoisting-from-control-flow.expected/index.tsis excluded by!**/__snapshots__/**and included by**packages/language-server/src/__tests__/fixtures/script/tags-api-basic/__snapshots__/tags-api-basic.expected/index.tsis excluded by!**/__snapshots__/**and included by**packages/language-server/src/__tests__/fixtures/script/while-tag/__snapshots__/while-tag.expected/index.tsis excluded by!**/__snapshots__/**and included by**pnpm-lock.yamlis excluded by!**/pnpm-lock.yamland included by**
📒 Files selected for processing (31)
.changeset/language-tools-parse.md.changeset/parse-package.mdpackages/language-server/src/__tests__/fixtures/script/leading-comment-pragma/index.markopackages/language-server/src/service/marko/document-links.tspackages/language-server/src/service/marko/document-symbols.tspackages/language-server/src/service/script/index.tspackages/language-tools/package.jsonpackages/language-tools/src/extractors/css-module/index.tspackages/language-tools/src/extractors/html/index.tspackages/language-tools/src/extractors/script/index.tspackages/language-tools/src/extractors/script/util/attach-scopes.tspackages/language-tools/src/extractors/script/util/get-runtime-api.tspackages/language-tools/src/extractors/script/util/is-text-only-script.tspackages/language-tools/src/extractors/script/util/jsdoc-input-type.tspackages/language-tools/src/extractors/script/util/script-parser.tspackages/language-tools/src/extractors/style/index.tspackages/language-tools/src/index.tspackages/language-tools/src/processors/marko.tspackages/language-tools/src/util/extractor.tspackages/language-tools/src/util/find-style-selectors.tspackages/language-tools/tsconfig.jsonpackages/parse/.mocharc.jsonpackages/parse/README.mdpackages/parse/build.mtspackages/parse/package.jsonpackages/parse/src/__tests__/parse.test.tspackages/parse/src/get-node-at-offset.tspackages/parse/src/index.tspackages/parse/src/normalize-path.tspackages/parse/tsconfig.jsontsconfig.json
| "scripts": { | ||
| "build": "tsx build.mts", | ||
| "test": "mocha './src/**/__tests__/*.test.ts'" | ||
| }, |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Build before running this package test.
Line 34 starts Mocha without running the package build. A direct package test can pass when build.mts fails. Run the build script before Mocha.
Proposed fix
- "test": "mocha './src/**/__tests__/*.test.ts'"
+ "test": "npm run build && mocha './src/**/__tests__/*.test.ts'"As per coding guidelines, “Build before testing; the root test command performs a build first, and package tests must not be run against stale build output.”
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| "scripts": { | |
| "build": "tsx build.mts", | |
| "test": "mocha './src/**/__tests__/*.test.ts'" | |
| }, | |
| "scripts": { | |
| "build": "tsx build.mts", | |
| "test": "npm run build && mocha './src/**/__tests__/*.test.ts'" | |
| }, |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@packages/parse/package.json` around lines 32 - 35, Update the package.json
test script so it runs the existing build script before invoking Mocha, ensuring
package tests cannot execute against stale or failed build output. Preserve the
current Mocha test pattern and reuse the existing build script rather than
duplicating its command.
Source: Coding guidelines
358b932 to
3c20738
Compare
3c20738 to
b5aee91
Compare
Extracts the CST parser from
@marko/language-toolsinto a new@marko/parsepackage so it can be shared by other tooling. Node types become strings, syntax errors and comments are exposed on the parse result, comments/static statements joinprogram.bodyin document order, and agetTagTypeoption allows overriding how tags parse (taking precedence over the built in core tag handling).@marko/language-toolsre-exports the new package (major:NodeTypevalues changed from numbers to strings).