Comment flush edge cases: EOF trailing comment moves to its own line; pad-space artifacts break print idempotency
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 139
- Forks
- 18
- Avg merge
- 1d 20h
- Merged PRs (30d)
- 7
Description
Three boundary conditions in the comment flush machinery (all with parser-native locs):
-
A trailing comment at EOF without a final newline moves onto its own line:
console.log(1); // keep me(no trailing
\n) printsconsole.log(1); // keep meLine-bound directives (
eslint-disable-lineand friends) stop covering their statement. Root:flush_trailing_commentsrequiresbefore(comment.loc.end, next)STRICTLY, and at EOF-no-newline the comment ends exactly atProgram.loc.end. -
Multiline block comment before a statement leaves a stray pad space (the newline after
*/is intentional per #82 - the leftover is the pad):/* lead */ console.log(1);prints
*/\n console.log(1);- note the leading space. The next print of that output drops it, so the first print is not a fixed point. -
Comment-only file without a final newline grows a space per print:
// alone(no trailing
\n) prints// alone- the pad space intended for a following statement lands INSIDE the line-comment token, so every reprint grows the comment's text by one space (non-converging).
Context: found by a parse -> print -> reparse structural gate over a ~8.5k-file TS/JS corpus while adopting esrap in core-js's build plugin, then re-verified in isolation. esrap 2.3.5; the ASTs below come from @typescript-eslint/typescript-estree 8.67 with loc/range enabled, so the repros are independent of our own (oxc-based) pipeline.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the flush_trailing_comments machinery and reproduce the three snippets described in the issue, including the EOF and multiline-comment boundaries. Verify that trailing comments stay on the intended line, block-comment padding is not emitted, and comment-only files print to the same text on repeated runs.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 58/100