# postcss-pseudo-companion-classes

> PostCSS plugin to add companion classes to pseudo-classes for testing purposes (works with css modules)

Latest version **0.1.1** (published 2022-03-25) · MIT license · 0 weekly downloads

## Install

```sh
npm install postcss-pseudo-companion-classes
pnpm add postcss-pseudo-companion-classes
yarn add postcss-pseudo-companion-classes
bun add postcss-pseudo-companion-classes
```

## 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.1.1 |
| Published | 2022-03-25 |
| First published | 2022-03-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=12.0.0 |
| Dependencies | 0 |
| Unpacked size | 29.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Michael Foley |
| Maintainers | mikefoley |
| Keywords | postcss, css, postcss-plugin, css test, pseudo classes, css modules |

## Links

- npm: https://www.npmjs.com/package/postcss-pseudo-companion-classes
- Repository: https://github.com/michaeldfoley/postcss-pseudo-companion-classes
- Issues: https://github.com/michaeldfoley/postcss-pseudo-companion-classes/issues
- npm.io page: https://npm.io/package/postcss-pseudo-companion-classes

## Alternatives

- [style-dictionary](https://npm.io/package/style-dictionary.md) — 2.0M weekly downloads
- [postcss-merge-idents](https://npm.io/package/postcss-merge-idents.md) — 1.7M weekly downloads
- [@fontsource/noto-sans](https://npm.io/package/@fontsource/noto-sans.md) — 93.0K weekly downloads
- [uglifycss](https://npm.io/package/uglifycss.md) — 71.6K weekly downloads
- [mat4-interpolate](https://npm.io/package/mat4-interpolate.md) — 23.3K weekly downloads

## Recent versions

- 0.1.1 (latest) — 2022-03-25
- 0.1.0 — 2022-03-25

## README

# PostCSS Pseudo Companion Classes

[PostCSS] plugin to add companion classes to pseudo-classes for testing purposes. This allows you to add the class name to force the styling of a pseudo-class,
which can be helpful for visual QA and building sticker sheets of all style states.
### Input

```css
.some-selector:hover {
  text-decoration: underline;
}
```
### Output

```css
.some-selector:hover,
.some-selector.\:hover {
  text-decoration: underline;
}
```

[PostCSS]: https://github.com/postcss/postcss

## Credits
This plugin is a fork of [postcss-pseudo-classes](https://github.com/giuseppeg/postcss-pseudo-classes) and adds support for css modules.

## Usage

**Step 1:** Install plugin:

```sh
npm install --save-dev postcss postcss-pseudo-companion-classes
```
or

```sh
yarn add --dev postcss postcss-pseudo-companion-classes
```

**Step 2:** Check you project for existed PostCSS config: `postcss.config.js`
in the project root, `"postcss"` section in `package.json`
or `postcss` in bundle config.

If you do not use PostCSS, add it according to [official docs]
and set this plugin in settings.

**Step 3:** Add the plugin to plugins list:

```diff
module.exports = {
  plugins: [
+   require('postcss-pseudo-companion-classes'),
    require('autoprefixer')
  ]
}
```

[official docs]: https://github.com/postcss/postcss#usage

## Options
| Property | Description | Default Value |
| --- | --- | --- |
| `exclude` | An array of pseudo-classes to skip when generating companion classes | `[':before', ':after']` |
| `restrictTo` | Limit the companion classes to an array of pseudo-classes | |
| `allCombinations` | When multiple pseudo-classes are present (ie `.selector:hover:focus`), output classes for each combination <br><br> <pre lang="css"><code>.selector:hover:focus,&#13;.selector:hover.\\:focus,&#13;.selector.\\:hover:focus,&#13;.selector.\\:hover.\\:focus</code></pre> | `false` |
| `isModule` | Wrap companion classes in `:global()` to prevent them from being renamed when CSS modules are being used | `false`
| `prefix` | The prefix for the companion class | `\\:` |

---
_Source: https://npm.io/package/postcss-pseudo-companion-classes · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
