fix(js): quote property name as es5 compatible#5157
Merged
duailibe merged 1 commit intoprettier:masterfrom Sep 28, 2018
Merged
Conversation
lydell
approved these changes
Sep 28, 2018
Member
lydell
left a comment
There was a problem hiding this comment.
I think this makes sense. Haven't we said before that by default we don't want to turn es5 into es6 – that's the reason we won't default trailing-comma to "all"?
I think using this kind of identifiers is not very common, so it should be a non-controversial change.
So 👍 from me.
alexander-akait
approved these changes
Sep 28, 2018
duailibe
approved these changes
Sep 28, 2018
Contributor
Author
|
Thank you! |
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.
Currently, Prettier quotes property names if the name isn't es6 compatible.
It means that Prettier might strip the quote for a property name that is es6 compatible but is not es5 compatible.
So this might break scripts on ES5 environments.
For example, the following example doesn't work on some ES5 environments.
You can try the script on Node v0.12.
Prettier 1.14.3
Playground link
Input:
Output:
This PR is to fix this.
docs/directory)