Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/preactjs/babel-plugin-transform-rename-properties
A Babel plugin for renaming JavaScript properties
https://github.com/preactjs/babel-plugin-transform-rename-properties
babel babel-plugin
Last synced: 30 days ago
JSON representation
A Babel plugin for renaming JavaScript properties
- Host: GitHub
- URL: https://github.com/preactjs/babel-plugin-transform-rename-properties
- Owner: preactjs
- License: mit
- Created: 2019-08-22T11:09:58.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2023-01-09T11:23:05.000Z (almost 2 years ago)
- Last Synced: 2024-04-14T13:08:33.876Z (7 months ago)
- Topics: babel, babel-plugin
- Language: JavaScript
- Homepage:
- Size: 118 KB
- Stars: 19
- Watchers: 1
- Forks: 3
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# babel-plugin-transform-rename-properties ![](https://github.com/preactjs/babel-plugin-transform-rename-properties/workflows/tests/badge.svg) [![npm](https://img.shields.io/npm/v/babel-plugin-transform-rename-properties.svg)](https://www.npmjs.com/package/babel-plugin-transform-rename-properties)
Rename JavaScript properties.
## Installation
```
$ yarn add --dev babel-plugin-transform-rename-properties
```## Example
Input file:
```js
const obj = {
foo: {
bar: 1
},
quux() {
return 2;
}
};const { foo } = obj;
function quux(obj) {
return obj.foo.bar + obj.quux();
}
````.babelrc`:
```json
{
"plugins": [
[
"babel-plugin-transform-rename-properties",
{
"rename": {
"foo": "__FOO__",
"quux": "I HAVE SPACES"
}
}
]
]
}
```Output:
```js
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](./LICENSE).