Skip to content

noDuplicateClasses (JavaScript)

.vscode/settings.json
{
"editor.codeActionsOnSave": {
"source.action.noDuplicateClasses.biome": "explicit",
"source.fixAll.biome": "explicit"
}
}
biome.json
{
"assist": {
"actions": {
"source": {
"noDuplicateClasses": "on"
}
}
}
}

Remove duplicate CSS classes.

Detects and removes duplicate CSS classes in JSX class and className attributes, as well as in utility function calls like clsx, cn, cva, etc.

Duplicate classes are redundant and can indicate copy-paste errors or merge conflicts.

<div class="flex flex" />;
code-block.jsx ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Source action diff:

1 │ <div·class="flex·flex"·/>;
-----
<div class="p-4 text-red-500 p-4 bg-white" />;
code-block.jsx ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Source action diff:

1 │ <div·class="p-4·text-red-500·p-4·bg-white"·/>;
----

Use the attributes option to specify additional JSX attributes to check. Use the functions option to specify utility functions to check (e.g., clsx, cn, cva).