1.0.0 • Published 7 years ago

babel-plugin-jsx-attrs v1.0.0

Weekly downloads
2
License
MIT
Repository
github
Last release
7 years ago

babel-plugin-jsx-attrs

Travis npm package

Transforms JSX any attributes according to specified rules .

Example

Converts

<div id="test" class="test">
  <label for="test">Test</label>
</div>

(roughly) to

<div id="test" className="prefix-test">
  <label htmlFor="test">Test</label>
</div>;

Installation & Usage

Install the plugin:

npm install --save-dev babel-plugin-jsx-attrs

Then edit your .babelrc to include jsx-attrs:

{
  "plugins": [["jsx-attrs",options]]
}

options

options must be object.

{
  "for":"htmlFor"  // replace attribute name only
}
{
  "class":{       // replace attribute name & value
    "name":"className",
    "value":"prefix-{value}"   //  "{value}" will be replaced by the real value
  }
}