babel-plugin-copy-jsx-attribute
v0.2.1
Published
A babel plugin to copy one JSX attribute to another. Original use cas was copying `testID` to `accessibilityLabel` in non-production builds to enable test automation.
Downloads
38
Maintainers
Readme
babel-plugin-copy-jsx-attribute
🚧 This project is a work in progress 🚧
A babel plugin to copy one JSX attribute to another.
Original use case was copying testID
to accessibilityLabel
in non-production builds to enable test automation.
Example
In
<Label testID={`${props.testID}-error-label`} styles={errorStyles}>
{props.constraints}
</Label>
Out
<Label
testID={`${props.testID}-error-label`}
styles={errorStyles}
accessibilityLabel={`${props.testID}-error-label`}
>
{props.constraints}
</Label>
Installation
$ npm install babel-plugin-copy-jsx-attribute
Usage
Via .babelrc
(Recommended)
.babelrc
{
"plugins": ["copy-jsx-attribute"]
}
Via CLI
$ babel --plugins copy-jsx-attribute script.js
Via Node API
require("@babel/core").transform("code", {
plugins: ["copy-jsx-attribute"],
});