babel-plugin-jsx-remove-attributes
v1.0.0
Published
Babel plugin to remove JSX attributes
Downloads
13
Maintainers
Readme
babel-plugin-jsx-remove-attributes
A Babel plugin to remove JSX attributes.
Install
yarn add -D babel-plugin-jsx-remove-attributes
Usage
In .babelrc
add the plugin and inform your list of attributes to be removed. (You can pass Strings or RegExp)
{
plugins: [
...
[
"babel-plugin-jsx-remove-attributes", {
attributes: ["attribute1", /attribute2/, ...]
}
]
...
]
}
Example
Input JSX Component
const Component = () => (
<h1 className="title" data-test-id="title" data-effect-active="true">Hello World!</h1>
)
Config plugin
{
plugins: [
...
[
"babel-plugin-jsx-remove-attributes", {
attributes: ["data-test-id", /data-effect.*/]
}
]
...
]
}
Output JSX Component
const Component = () => (
<h1 className="title">Hello World!</h1>
)