Skip to content

Latest commit

 

History

History
66 lines (52 loc) · 1.34 KB

File metadata and controls

66 lines (52 loc) · 1.34 KB

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