fix: Unexpected duplication of comments#16110
Merged
nicolo-ribaudo merged 3 commits intobabel:mainfrom Nov 22, 2023
Merged
Conversation
Member
liuxingbaoyu
commented
Nov 19, 2023
| Q | A |
|---|---|
| Fixed Issues? | Fixes #16106 |
| Patch: Bug Fix? | √ |
| Major: Breaking Change? | |
| Minor: New Feature? | |
| Tests Added + Pass? | √ |
| Documentation PR Link | |
| Any Dependency Changes? | |
| License | MIT |
Collaborator
|
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/55844/ |
liuxingbaoyu
commented
Nov 19, 2023
| if (i < len - 1) separator?.(); | ||
|
|
||
| if (opts.statement) { | ||
| if (!node.trailingComments?.length) { |
Member
Author
There was a problem hiding this comment.
This fixes the extra new line.
{
var t = 20; /*
* This is trailing comment
*/
}
{
var tt = 20; /*
* This is trailing comment
*/
}
liuxingbaoyu
commented
Nov 19, 2023
Comment on lines
49
to
55
| function removeIfExisting<T>(list: T[], toRemove?: T[]): T[] { | ||
| if (!toRemove) return list; | ||
| let lastFoundIndex = -1; | ||
| const set = new Set(toRemove); | ||
| return list.filter(el => { | ||
| const i = toRemove.indexOf(el, lastFoundIndex); | ||
| if (i === -1) return true; | ||
| lastFoundIndex = i; | ||
| return !set.has(el); | ||
| }); | ||
| } |
Member
Author
There was a problem hiding this comment.
The problem is that the order may be reversed.
removeIfExisting([1,2], [2,1])
liuxingbaoyu
commented
Nov 20, 2023
| );`); | ||
| }); | ||
|
|
||
| it("multi-line leading comment after return 2", () => { |
Member
Author
There was a problem hiding this comment.
This test has nothing to do with this PR, it just ensures that #16104 does not cause regressions.
JLHwung
approved these changes
Nov 21, 2023
nicolo-ribaudo
approved these changes
Nov 22, 2023
| ].filter(Boolean), | ||
| }; | ||
|
|
||
| if (jestSnapshot) { |
Member
There was a problem hiding this comment.
Can we configure Jest to just not load the Babel config for snapshots?
Member
Author
There was a problem hiding this comment.
This doesn't seem to be possible at the moment.
Member
Author
There was a problem hiding this comment.
To be honest, I even want to open a pr in jest to avoid using @babel/core.
Vylpes
pushed a commit
to Vylpes/random-bunny
that referenced
this pull request
Dec 4, 2023
This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [@babel/traverse](https://babel.dev/docs/en/next/babel-traverse) ([source](https://github.com/babel/babel)) | resolutions | patch | [`7.23.3` -> `7.23.5`](https://renovatebot.com/diffs/npm/@babel%2ftraverse/7.23.3/7.23.5) | --- ### Release Notes <details> <summary>babel/babel (@​babel/traverse)</summary> ### [`v7.23.5`](https://github.com/babel/babel/blob/HEAD/CHANGELOG.md#v7235-2023-11-29) [Compare Source](babel/babel@v7.23.4...v7.23.5) ##### 👓 Spec Compliance - `babel-plugin-proposal-decorators` - [#​16138](babel/babel#16138) Class binding is in TDZ during decorators initialization ([@​nicolo-ribaudo](https://github.com/nicolo-ribaudo)) - `babel-helpers`, `babel-plugin-proposal-decorators` - [#​16132](babel/babel#16132) Allow addInitializer in field decorator context ([@​JLHwung](https://github.com/JLHwung)) ##### 🐛 Bug Fix - `babel-traverse`, `babel-types` - [#​16131](babel/babel#16131) Do not remove bindings when removing assignment expression path ([@​nicolo-ribaudo](https://github.com/nicolo-ribaudo)) - `babel-plugin-transform-classes` - [#​16135](babel/babel#16135) Require class properties transform when compiling class with private fields ([@​nicolo-ribaudo](https://github.com/nicolo-ribaudo)) - `babel-generator` - [#​16122](babel/babel#16122) fix: Missing parentheses after line break ([@​liuxingbaoyu](https://github.com/liuxingbaoyu)) - `babel-helpers` - [#​16130](babel/babel#16130) Fix helpers internal fns names conflict resolution ([@​nicolo-ribaudo](https://github.com/nicolo-ribaudo)) - `babel-helper-create-class-features-plugin`, `babel-plugin-transform-class-properties`, `babel-plugin-transform-typescript` - [#​16123](babel/babel#16123) Simplify class fields injetion after `super()` ([@​nicolo-ribaudo](https://github.com/nicolo-ribaudo)) - `babel-generator`, `babel-plugin-transform-modules-commonjs`, `babel-plugin-transform-parameters`, `babel-plugin-transform-typescript`, `babel-traverse` - [#​16110](babel/babel#16110) fix: Unexpected duplication of comments ([@​liuxingbaoyu](https://github.com/liuxingbaoyu)) - `babel-eslint-plugin` - [#​16023](babel/babel#16023) Add `@babel/eslint-plugin/no-undef` to fix `no-undef` with accessor props ([@​nicolo-ribaudo](https://github.com/nicolo-ribaudo)) ##### 🔬 Output optimization - `babel-helpers` - [#​16129](babel/babel#16129) Optimize `decorator` helper size ([@​liuxingbaoyu](https://github.com/liuxingbaoyu)) ### [`v7.23.4`](https://github.com/babel/babel/blob/HEAD/CHANGELOG.md#v7234-2023-11-20) [Compare Source](babel/babel@v7.23.3...v7.23.4) ##### 🐛 Bug Fix - `babel-generator` - [#​16104](babel/babel#16104) fix: Pure comments missing parentheses ([@​liuxingbaoyu](https://github.com/liuxingbaoyu)) </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4wLjAiLCJ1cGRhdGVkSW5WZXIiOiIzNy4wLjAiLCJ0YXJnZXRCcmFuY2giOiJkZXZlbG9wIn0=--> Reviewed-on: https://gitea.vylpes.xyz/RabbitLabs/random-bunny/pulls/113 Reviewed-by: Vylpes <ethan@vylpes.com> Co-authored-by: Renovate Bot <renovate@vylpes.com> Co-committed-by: Renovate Bot <renovate@vylpes.com>
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.