1.0.0 • Published 2 years ago

babel-plugin-jsx-remove-attributes v1.0.0

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

babel-plugin-jsx-remove-attributes

NPM version NPM Weekly Downloads License

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>
  )