website icon indicating copy to clipboard operation
website copied to clipboard

Example in “plugin-transform-property-literals” documentation is wrong

Open d3pi opened this issue 5 years ago • 3 comments

@babel/plugin-transform-property-literals will add quotes for key which name is es3 reserved word. A correct example:

IN

var foo = {
  // changed
  default: 1,
  abstract: 2,

  // not changed
  "bar": function () {},
  "1": function () {},

  [a]: 2,
  foo: 1
};

out

var foo = {
  // changed
  "default": 1,
  "abstract": 2,
  // not changed
  "bar": function bar() {},
  "1": function _() {},
  [a]: 2,
  foo: 1
};

d3pi avatar Feb 28 '20 14:02 d3pi

Hey @d3pi! We really appreciate you taking the time to report an issue. The collaborators on this project attempt to help as many people as possible, but we're a limited number of volunteers, so it's possible this won't be addressed swiftly.

If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack community that typically always has someone willing to help. You can sign-up here for an invite.

babel-bot avatar Feb 28 '20 14:02 babel-bot

Dp you want to open a PR? :pray:

nicolo-ribaudo avatar Mar 01 '20 16:03 nicolo-ribaudo

Hi everyone.

I see the example is correct in this link:

https://babeljs.io/docs/en/babel-plugin-transform-property-literals#example

But incorrect in this link:

https://github.com/babel/minify/tree/master/packages/babel-plugin-transform-property-literals

and incorrect one is inside minify repo.

arminyahya avatar Jan 29 '21 14:01 arminyahya