1.0.1 • Published 1 year ago

stylelint-no-unused-selectors-umi v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

stylelint-no-unused-selectors

Concepts

stylelint-no-unused-selectors-umi is a stylelint rule to disallow unused CSS selectors for UMI projects.

It works best with component-oriented applications where views are built on top of a lot of small components, each of which contains a template file (e.g., js or ts) and its corresponding scoped CSS file (e.g., CSS Modules or PostCSS with BEM).

Assuming your component consists of following files:

FooComponent
├── index.js
├── FooComponent.js
└── FooComponent.css

when stylelint-no-unused-selectors-umi runs on FooComponent.css, it extracts classes and ids from FooComponent.js and detects unused CSS rules.

Features

If you'd like to jump into code, you can find our examples in the repository that are close to real-world situations.

With the built-in plugins, it supports

See the documentations of built-in plugins for more details.

Installation

yarn add stylelint stylelint-no-unused-selectors-umi

Usage

It works as a stylelint rule, and its plugin name is plugin/no-unused-selectors-umi. An example configuration of stylelint would look like:

{
  "plugins": [
    "stylelint-no-unused-selectors-umi"
  ],
  "rules": {
    "plugin/no-unused-selectors-umi": true
  }
}

See stylelint's documentation for more details.