babel-plugin-remove-data-test-id-attribute

1.0.0 • Public • Published

babel-plugin-remove-data-test-id-attribute

Removes data-test-id attribute from jsx html elements.

The data-test-id is normally added for testing as a helper attribute to quickly grab an element by id and simualte events or do other stuff. The data-test-id not required in the production builds and should be removed in production builds.

Usage -

$ npm i -D babel-plugin-remove-data-test-id-attribute

In your .babelrc file, or whereever you setup babel preferences, add the plugin to the plugins array, inside the production environment -

{
    "env": {
    "production": {
      "plugins": ["babel-plugin-remove-data-test-id-attribute" ]
    }
  }
}

E.g. - If your jsx code looks like this

<div data-id="pqr" data-test-id='abc'>
    abc
    <p>para</p>
    <Custom data-test-id='blah' />
</div>

When the code is passed through this plugin, it will change to -

<div data-id="pqr">
    abc
    <p>para</p>
    <Custom />
</div>

Package Sidebar

Install

npm i babel-plugin-remove-data-test-id-attribute

Weekly Downloads

6

Version

1.0.0

License

MIT

Unpacked Size

2.33 kB

Total Files

3

Last publish

Collaborators

  • mukeshsoni