Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

babel-plugin-jsx-remove-qa

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-plugin-jsx-remove-qa

babel plugin to remove-qa-classes

  • 0.2.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
4
decreased by-33.33%
Maintainers
1
Weekly downloads
 
Created
Source

babel-pluginn-remove-qa-classes

Remove QA classes from your production builds.

Motivation

It's not a good idea to hang unit tests off production CSS classes or DOM elements for a couple of reasons:

  • Finding by an .o-some-class selector couples our test to the CSS; making changes can be expensive from a maintainance point of view, whether they are coming from the CSS or the tests
  • Finding elements by DOM tag, such as <span /> or <p> can be equally as difficult to maintain; these things move around so if your looking for .first() you might get a nasty surprise

We wanted to decouple our tests from the production CSS, but quite liked what class selectors gave us, so we started to add className="qa-some-class" to our React components.

This is good because, by convention, our UI guys never style to these classes so when we want to move stuff around - we just do it, and so do they.

The problem is, left untreated, these things can makes their way into your production code. Not good.

Install

npm install babel-plugin-jsx-remove-qa --save-dev

Add this to you babel config plugins

plugins: [
    'babel-plugin-jsx-remove-qa',
    {
        attributes: ['cssClassName'] // Another attribute you might want to remove
    }
]

How to use

Add classnames to your react components

return (
    <div>
        <p className="qa-component-text">{someText}</p>
        <ChildComponent cssClassName="qa-child-component" {...props] />
    </div>
);

Make sure the plugins are part of your webpack build, and that's it. .qa-classes will be stripped.

At the moment this only works on string literals, but at some point we'll be adding support for expressions too.

Impotant

Please use with care, this is an experimental plugin, intended to be replaced with a full featured version.

FAQs

Package last updated on 12 Oct 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc