0.2.1 ⢠Published 5 years ago
babel-plugin-copy-jsx-attribute v0.2.1
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-attributeUsage
Via .babelrc (Recommended)
.babelrc
{
"plugins": ["copy-jsx-attribute"]
}Via CLI
$ babel --plugins copy-jsx-attribute script.jsVia Node API
require("@babel/core").transform("code", {
plugins: ["copy-jsx-attribute"],
});