Repository navigation
Fix detection of newline/dot before this in replace_this_prop - #383
Merged
benoit74 merged 1 commit intoNov 6, 2026
Merged
Conversation
The `this.<prop>` rewriting rule used a regex that could only look 1-2 characters back from `this`, so it would miss a preceding newline (and thus skip the needed ASI-guarding `;`) for any amount of whitespace other than exactly 2 characters, and would wrongly rewrite `this` when it was actually preceded by `.`/`$` with 3 or more spaces in between. Replace that bounded lookback with an explicit backward scan over the original string (done in the rewrite callback rather than the regex, since an earlier rule may already have consumed whatever immediately preceded the whitespace, e.g. in `const location = this.location`). Fixes #381
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
benoit74
deleted the
benoit74/detection-of-new-line-before-this-in-replace_thi
branch
November 6, 2026 15:15
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.
Summary
this.<prop>JS rewriting rule (replace_this_prop/ its regex increate_js_rules) could only look back 1-2 characters fromthis, so:;) when there were exactly 2 whitespace characters between the newline andthis— any other amount (0, 1, 3, 4, ...) silently skipped the;.thiswhen it was actually a property access (preceded by.or$) separated by 3+ spaces, since the regex couldn't see that far back.let/const location =passthrough) has already consumed whatever token immediately preceded the whitespace../$followed by 3 spaces.Fixes #381