-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Porting babel-plugin-transform-for-of-as-array into transform-for-of as option #6914
Conversation
rajasekarm
commented
Nov 27, 2017
Q | A |
---|---|
Fixed Issues? | #6816 |
Patch: Bug Fix? | |
Major: Breaking Change? | |
Minor: New Feature? | Yes |
Tests Added + Pass? | Yes |
Documentation PR | |
Any Dependency Changes? | |
License | MIT |
Usage:- {
"plugins": [["transform-for-of", {
"assumeArray": true
}]
]
} |
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/6042/ |
@@ -1,7 +1,7 @@ | |||
import { template, types as t } from "@babel/core"; | |||
|
|||
export default function(api, options) { | |||
const { loose } = options; | |||
const { loose, forOfAsArray: isForOfAsArray } = options; |
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.
would prefer a little bit more descriptive name - useForAsArray
or something and that name could be used both as the internal flag and the public plugin option
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.
What about just assmeArray
? After all, for of
is already specified in the plugin name.
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.
@nicolo-ribaudo assumeArray?
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.
Yeah, assumeArray
sounds like a great name for this.
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.
yeah, I will update the PR.
|
|
||
if (loose === true && assumeArray === true) { | ||
throw new Error( | ||
`Cannot use loose and assumeArray options together in babel-plugin-transform-for-of`, |
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.
Nit:
The
loose
andassumeArray
options cannot be used together in @babel/plugin-transform-for-of
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.
Can we document the assumeArray
option in the README?
@@ -107,49 +161,6 @@ export default function(api, options) { | |||
} | |||
} | |||
|
|||
return { |
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.
none of the code here is any different right? (just saying this part of the diff isn't necessary as clarification)
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.
looks good (if you are cool with changing the other code back for a simplier diff that would be nice), yeah we should have a readme change to document
We can test this by using it lol, but can be another PR babel/packages/babylon/package.json Line 27 in d8bbaaa
|