eslint-plugin-tailwindcss icon indicating copy to clipboard operation
eslint-plugin-tailwindcss copied to clipboard

[Feature request] classname value likes arbitrary colors `text-[#fff]` should be replace predefined tailwind classname `text-white`

Open ihavecoke opened this issue 1 year ago • 2 comments

Is your feature request related to a problem? Please describe. Our team is working on a large frontend project involving multiple frontend developers. During development on different branches, we often encounter inconsistencies in Tailwind CSS class names, especially when using dynamic arbitrary values, such as:


<div className="text-[#fff]">foo</div>

Where text-[#fff] corresponds to a color defined in the original tailwind.config.js file, for example: text-white.

Therefore, we would like to request support for adding additional parameters to the no-arbitrary-values rule. This would automatically replace occurrences of patterns like text-[#fff] with text-white.

Describe the solution you'd like

We propose enabling this feature through the following configuration:

{
  "rules": {
    "no-arbitrary-values": [
      "warn",
      ["colors"]
    ]
  }
}

This configuration would allow us to activate the feature and search for dynamic arbitrary values within the Tailwind configuration's theme colors.

Describe alternatives you've considered We can suggest replacing this value with text-white, but it should also be possible to eignore it.

ihavecoke avatar Oct 10 '23 14:10 ihavecoke

I think this is a duplicate of https://github.com/francoismassart/eslint-plugin-tailwindcss/issues/175

bezbac avatar Oct 12 '23 08:10 bezbac

@bezbac Yes, it has a similar function to the issue you mentioned, so is it possible to implement and integrate this function into the current plugin @francoismassart ?

ihavecoke avatar Oct 12 '23 10:10 ihavecoke

The new rule has been added since v3.15.0

npm i eslint-plugin-tailwindcss@latest -D

francoismassart avatar Mar 25 '24 12:03 francoismassart