# babel-plugin-jsx-remove-qa

> babel plugin to remove-qa-classes

Latest version **0.3.3** (published 2017-03-31) · MIT license · 0 weekly downloads

## Install

```sh
npm install babel-plugin-jsx-remove-qa
pnpm add babel-plugin-jsx-remove-qa
yarn add babel-plugin-jsx-remove-qa
bun add babel-plugin-jsx-remove-qa
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.3.3 |
| Published | 2017-03-31 |
| First published | 2016-10-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | yes |
| Author | Rich Gorman |
| Maintainers | coderas |
| Keywords | babel, plugin, tdd, tests, specs, qa, strip, className, jsx, react |

## Links

- npm: https://www.npmjs.com/package/babel-plugin-jsx-remove-qa
- Repository: https://github.com/coderas/babel-plugin-jsx-remove-qa
- Homepage: https://github.com/coderas/babel-plugin-jsx-remove-qa#readme
- Issues: https://github.com/coderas/babel-plugin-jsx-remove-qa/issues
- npm.io page: https://npm.io/package/babel-plugin-jsx-remove-qa

## Dependencies (2)

- [babel-cli](https://npm.io/package/babel-cli.md) ^6.16.0
- [babel-core](https://npm.io/package/babel-core.md) ^6.17.0

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 0.3.3 (latest) — 2017-03-31
- 0.0.1 (beta) — 2016-10-09
- 0.3.2 — 2017-03-30
- 0.3.1 — 2016-11-02
- 0.3.0 — 2016-10-17
- 0.2.4 — 2016-10-13
- 0.2.3 — 2016-10-12
- 0.2.2 — 2016-10-12
- 0.2.1 — 2016-10-12
- 0.2.0 — 2016-10-12
- 0.1.1 — 2016-10-09
- 0.1.0 — 2016-10-09

## README

## babel-plugin-jsx-remove-qa

> You may want to consider using
[`babel-plugin-jsx-remove-data-test-id`](https://www.npmjs.com/package/babel-plugin-jsx-remove-data-test-id)
over this package, since we believe it is more delcarative and works
well as a uniform approach for both unit testing, and end to end.

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

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

Add this to you babel config plugins

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

### How to use
Add classnames to your react components

```javascript
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.

---
_Source: https://npm.io/package/babel-plugin-jsx-remove-qa · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
