tailwind-ppx icon indicating copy to clipboard operation
tailwind-ppx copied to clipboard

Idea: Add underscore at the beginning to dissable a class easily

Open d4h0 opened this issue 4 years ago • 1 comments

Hi,

Something I often use with "vanilla Tailwind" is to prefix a class with an underscore to disable it temporarily.

For example this:

<div class="text-red">...</div>

becomes this:

<div class="_text-red">...</div>

At the moment, this is handles like an error. What I propose, is to treat this special case as a warning (a warning would still be useful, so these classes don't end up in production). This would be similar to how we use an underscore-prefix to disable warnings about unused variables.

d4h0 avatar Jan 08 '21 10:01 d4h0

Hey @d4h0, this is an interesting feature request. I personally haven't done this during development in JS, for instance, but I can see the use case pretty clearly: It would speed up development for the same reasons that prefixing unused variables with an underscore causes less headache.

I don't know when/if I'll get around to implementing this feature, though it seems fairly trivial. If anyone who sees this is interested in taking it on, do follow up on this issue. I'm thinking that the scope/dev work would roughly look like this:

  • An optional flag you put in your configuration; for instance, it could be disable_underscore.
  • Add another function before the actual validators that removes class names with an underscore from consideration (see here/utils.re#L232)

I'm open to suggestions from others! Thanks again for the idea.

dylanirlbeck avatar Jan 14 '21 21:01 dylanirlbeck