🚧 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.
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>
$ npm install babel-plugin-copy-jsx-attribute
.babelrc
{
"plugins": ["copy-jsx-attribute"]
}
$ babel --plugins copy-jsx-attribute script.js
require("@babel/core").transform("code", {
plugins: ["copy-jsx-attribute"],
});