babel-plugin-transform-rename-properties

0.1.0 • Public • Published

babel-plugin-transform-rename-properties npm

Rename JavaScript properties.

Installation

$ yarn add --dev babel-plugin-transform-rename-properties

Example

Input file:

const obj = {
  foo: {
    bar: 1
  },
  quux() {
    return 2;
  }
};
 
const { foo } = obj;
 
function quux(obj) {
  return obj.foo.bar + obj.quux();
}

.babelrc:

{
  "plugins": [
    [
      "babel-plugin-transform-rename-properties",
      {
        "rename": {
          "foo": "__FOO__",
          "quux": "I HAVE SPACES"
        }
      }
    ]
  ]
}

Output:

const obj = {
  __FOO__: {
    bar: 1
  },
  "I HAVE SPACES"() {
    return 2;
  }
};
 
const { __FOO__: foo } = obj;
 
function quux(obj) {
  return obj.__FOO__.bar + obj["I HAVE SPACES"]();
}

License

This plugin is licensed under the MIT license. See LICENSE.

Readme

Keywords

Package Sidebar

Install

npm i babel-plugin-transform-rename-properties

Weekly Downloads

868

Version

0.1.0

License

MIT

Unpacked Size

5.03 kB

Total Files

5

Last publish

Collaborators

  • rschristian
  • drewigg
  • reznord
  • preactjs
  • developit
  • marvinhagemeister
  • jdecroock
  • sventschui