Skip to content

noUnusedClasses

biome.json
{
"linter": {
"rules": {
"nursery": {
"noUnusedClasses": "error"
}
}
}
}

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.

styles.css
.unused { color: red; } /* Class "unused" is never referenced */
.used { color: blue; }
App.jsx
import "./styles.css";
export default () => <div className="used" />;
styles.css
.button { color: blue; }
.container { padding: 1rem; }
App.jsx
import "./styles.css";
export default () => (
<div className="container">
<button className="button">Click</button>
</div>
);