Skip to content

noUndeclaredClasses (JavaScript)

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

Reports CSS class names in JSX className or class attributes that are not defined in any imported CSS file.

When a JSX file imports CSS files, every class name used in className= or class= attributes is checked against the available class definitions. Classes that are not defined are reported.

This rule checks string literals, variable references (resolved through the semantic model), call expressions like clsx(...) / classnames(...), object expression keys, and array expressions. Dynamic class names that cannot be statically resolved are silently skipped.

In Astro files, class:list={...} directives and class={...} attribute expressions are also checked. CSS files imported in the frontmatter (import "./styles.css") are included in the class resolution.

import "./styles.css";
export default () => <div className="missing" />;
import "./styles.css";
export default () => <div className="header" />;