Skip to content

leoavelino7/babel-plugin-jsx-remove-attributes

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Babel plugin to remove JSX attributes

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published