# symdiff-css-autoremove

> Removes classes from a CSS file.

Latest version **0.0.1** (published 2015-09-26) · Apache 2.0 license · 0 weekly downloads

## Install

```sh
npm install symdiff-css-autoremove
pnpm add symdiff-css-autoremove
yarn add symdiff-css-autoremove
bun add symdiff-css-autoremove
```

## 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.0.1 |
| Published | 2015-09-26 |
| First published | 2015-09-26 |
| Weekly downloads | 0 |
| License | Apache 2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Nikolaus Piccolotto |
| Maintainers | prayerslayer |

## Links

- npm: https://www.npmjs.com/package/symdiff-css-autoremove
- Repository: https://github.com/symdiff/symdiff-css-autoremove
- Homepage: https://symdiff.github.io
- Issues: https://github.com/symdiff/symdiff-css-autoremove/issues
- npm.io page: https://npm.io/package/symdiff-css-autoremove

## Dependencies (2)

- [css](https://npm.io/package/css.md) 2.2.0
- [extend](https://npm.io/package/extend.md) 3.0.0

## Recent versions

- 0.0.1 (latest) — 2015-09-26

## README

# symdiff-css-autoremove

[![Build Status](http://img.shields.io/travis/symdiff/symdiff-css-autoremove.svg)](https://travis-ci.org/symdiff/symdiff-css-autoremove) [![Coverage Status](https://coveralls.io/repos/symdiff/symdiff-css-autoremove/badge.svg?branch=master)](https://coveralls.io/r/symdiff/symdiff-css-autoremove?branch=master)

Gets rid of classes in your CSS.

## Algorithm

It removes all selectors that contain the class and removes the rule altogether if it doesn’t have any selectors left.

This does not seem very smart, but it’s by design. For instance, what would you expect after processing `div > .remove > .keep`? Should it rather be `div > * > .keep` or should the rule be discarded? `symdiff-css-autoremove` does not try to guess.

## Usage

The module exports a function that takes the following arguments:

* The css string
* An array of the classes to remove
* (optional) An object containing some options

### Options

* replaceSelectorFn: A function that takes the selector (string) and the classes to remove as argument and should return a string. Here you can implement custom logic if the default behavior doesn’t work for you. If you want the selector to be discarded, return the empty string.

Also all options that [`css.stringify`](https://www.npmjs.com/package/css#css-stringify-object-options) takes.


## Example

    removeCss(input, ['remove-me']);

Transforms this:

~~~ css
.remove-me {
    border: 1px solid;
    color: red:
}

.keep-me,
div > .remove-me {
    color: blue;
}
~~~

...to this:

~~~ css
.keep-me {
    color: blue;
}
~~~

---
_Source: https://npm.io/package/symdiff-css-autoremove · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
