-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Pure comments missing parentheses #16104
Conversation
liuxingbaoyu
commented
Nov 15, 2023
Q | A |
---|---|
Fixed Issues? | Fixes #14797 |
Patch: Bug Fix? | √ |
Major: Breaking Change? | |
Minor: New Feature? | |
Tests Added + Pass? | √ |
Documentation PR Link | |
Any Dependency Changes? | |
License | MIT |
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/55832/ |
forceParens || | ||
(format.retainFunctionParens && | ||
nodeType === "FunctionExpression" && | ||
node.extra?.parenthesized) || | ||
needsParens(node, parent, this._printStack); | ||
|
||
if ( | ||
!shouldPrintParens && | ||
parent?.type === "MemberExpression" && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we don't have to limit the parent type. If there are leading comments and the node is parenthesized, it suggests that users intend to keep comments within the parentheses. Examples are
(/* @__PURE__ */ f())()
(/* @__PURE__ */ f())?.bar
(/* @__PURE__ */ f())`bar`
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- var c = /*#__PURE__*/function () {
+ var c = ( /*#__PURE__*/function () {
- setTimeout( /*#__PURE__*/function () {
+ setTimeout(( /*#__PURE__*/function () {
Unfortunately there are some unexpected situations.
Updated: I added new logic to solve this problem.
dd62739
to
f0bba77
Compare
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 <[email protected]> Co-authored-by: Renovate Bot <[email protected]> Co-committed-by: Renovate Bot <[email protected]>