noUnusedClasses
Summary
Section titled “Summary”- Diagnostic Category:
lint/nursery/noUnusedClasses - This rule doesn’t have a fix.
- The default severity of this rule is information.
- This rule belongs to the following domains:
How to configure
Section titled “How to configure”{ "linter": { "rules": { "nursery": { "noUnusedClasses": "error" } } }}Description
Section titled “Description”Reports CSS class selectors that are never referenced in any JSX or HTML file.
This rule checks all CSS class selectors (.foo) in a CSS file and verifies
that each class name is referenced somewhere in a class= or className=
attribute in an HTML or JSX file that imports (directly or transitively) the
CSS file.
Classes inside :global(.foo) are excluded from this check, as they are
intended to be used by external consumers without explicit imports.
Examples
Section titled “Examples”Invalid
Section titled “Invalid”.unused { color: red; } /* Class "unused" is never referenced */.used { color: blue; }import "./styles.css";export default () => <div className="used" />;.button { color: blue; }.container { padding: 1rem; }import "./styles.css";export default () => ( <div className="container"> <button className="button">Click</button> </div>);Related links
Section titled “Related links”Copyright (c) 2023-present Biome Developers and Contributors.