babel-plugin-copy-jsx-attribute

0.2.1 • Public • Published

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"],
});

Package Sidebar

Install

npm i babel-plugin-copy-jsx-attribute

Weekly Downloads

18

Version

0.2.1

License

none

Unpacked Size

6.57 kB

Total Files

13

Last publish

Collaborators

  • sylvanaar