Repository navigation
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #536.
Formatting
{#if true /* condition */}{/if}currently removes the comment. Svelte attaches it totrailingComments, outside the expression'sendposition. Include those comments in the text passed to Prettier. Add a line-suffix boundary so a trailing//comment stays inside the Svelte expression instead of becoming literal markup after its closing brace.The new JS and TS fixtures cover conditionals, each/await/key blocks, attributes, HTML tags, multiple trailing comments, comments inside parentheses, and line comments. The formatting harness also checks a second formatting pass.
Validation on Node 20.19.5, locked Svelte 5.56.0 and Prettier 3.8.3:
7809486and pass with the fix.pnpm test: 311 tests passed.pnpm build,pnpm lint, andgit diff --check: passed.pnpm checkfails with missingestreedeclarations and three resulting implicit-any errors. The unchanged base has the same four errors with the same installed dependencies.Scope: this preserves trailing comments attached to embedded nodes by the Svelte compiler. Comments the compiler leaves unattached, such as a comment after an expression's closing parenthesis, are outside this fix. The additional CI dependency versions have not been run locally.
AI disclosure: OpenAI Codex investigated the issue, prepared the code and tests, and wrote this PR description at the account owner's request. No human code review took place during this session.