Socket
Socket
Sign inDemoInstall

babel-plugin-transform-rename-properties

Package Overview
Dependencies
53
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    babel-plugin-transform-rename-properties

Rename JavaScript properties


Version published
Weekly downloads
436
decreased by-27.69%
Maintainers
1
Install size
6.21 kB
Created
Weekly downloads
 

Readme

Source

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.

Keywords

FAQs

Last updated on 09 Aug 2020

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc