eslint-plugin-sonarjs
eslint-plugin-sonarjs copied to clipboard
Prevent error of sonarjs/no-duplicate-string with CSS classes (Tailwind, Foundation, Boostrap...)
I want to request a feature.
I want that sonarjs/no-duplicate-string doesn't throw erros with Tailiwnd classes.
const Card = () =>
<div class="flex">
<div class="flex">
<img .../>
</div>
<div class="flex" />
</div>
Would this option meet your needs? https://github.com/SonarSource/eslint-plugin-sonarjs/blob/8e3a6835e646c15bfe76f30fc7f5dd37c49579a1/docs/rules/no-duplicate-string.md#L24
Hi!, thanks but I think that doesn't meet my need because Tailwind has hundreds or thousands of classes 🙈
Thanks a lot - that indeed makes sense, we will look at it.
@alexander-kamushkin-sonarsource great thanks! It would be awesome if the implementation can be made for css classes in general because in this case others CSS frameworks will work
@RodrigoTomeES I analyzed the snippet you provided and the rule doesn't report any issue on it. I also checked the rule implementation and it already makes an exception to all JSX attributes.
Was this a feature suggestion or are you facing an actual false positive from the rule?
@yassin-kammoun-sonarsource now I on vacation and I can't provide you an real example but when I will go back to my work I will show you real code that have this problem
I have the same issue. Mostly happens when for me with tailwind-merge using an array of classes like this:
And yes, it might be an abomination to pass classes as an array, but it lets prettier format them nicely.
To bump, it would be sweet to be able to pass a regex to ignoreStrings
This issue has been migrated to Jira. ESLINTJS-26