stylelint-unused-classes
Purpose
Finds out possibly unused class selectors (.my-class
) and id selectors (#my-element
) by statically analyzing the source code that generates HTML.
Currently Erb and Haml are supported.
Getting started
First, configure unused-classes
.
Then install stylelint and stylelint-unused-classes:
npm install -D stylelint stylelint-unused-classes
# OR
yarn add -D stylelint stylelint-unused-classes
Configure .stylelintrc.js
:
module.exports = {
plugins: ["stylelint-unused-classes"],
rules: {
"unused-classes/unused-classes": [
require.resolve("./classes.json"),
{
severity: "warning",
},
],
},
};
Options
Primary option
A string pointing to the file generated by unused-classes
.