Prettier plugin that removes duplicate class names from className (JSX/TSX/React), class (HTML, Angular, Vue), and similar attributes in your code, ensuring clean and consistent class usage.
Supports the following:
- React (JSX/TSX) –
className - Angular –
class - Vue –
class - HTML –
class
By eliminating duplicate class names, this plugin helps maintain cleaner, more efficient markup.
You can install the plugin using any of the following package managers:
bun add -D @softonus/prettier-plugin-duplicate-removeryarn add -D @softonus/prettier-plugin-duplicate-removernpm install --save-dev @softonus/prettier-plugin-duplicate-removerOnce installed, you need to add this plugin to your Prettier configuration file (.prettierrc).
- Create a
.prettierrcfile in your project's root directory (if you don't have one). - Add the plugin configuration to your
.prettierrcfile:
{
"plugins": ["@softonus/prettier-plugin-duplicate-remover"]
}This will enable the plugin, and Prettier will automatically remove duplicate class names during formatting.
Before formatting:
<div class="btn btn btn-primary btn btn-large">Button</div>After formatting:
<div class="btn btn-primary btn-large">Button</div>- React (JSX/TSX): Removes duplicate
classNameattributes. - Angular, Vue, HTML: Removes duplicate
classattributes. - Ensures clean and consistent markup: Prevents unnecessary repetition of class names.
- React (
.jsx,.tsx) – HandlesclassName - Vue (
.vue) – Handlesclass - Angular (
.html,.ts) – Handlesclass - HTML (
.html) – Handlesclass
If you’d like to contribute to this project, feel free to fork it, make changes, and open a pull request. Your contributions are always welcome!
For any questions or issues, please contact me at:
ebo@softonus.com
This project is licensed under the MIT License - see the LICENSE file for details.