-
-
Notifications
You must be signed in to change notification settings - Fork 107
Description
Is your feature request related to a problem? Please describe.
I'm working on a team of about 30 people on a medium-sized codebase. It's common to see an arbitrary value like this:
text-[14px]
This is exactly the same as:
text-md
However, it creates duplicate CSS. Over time, this adds up to a significant amount of extra CSS for no benefit.
Describe the solution you'd like
Detect when an arbitrary value is identical to a configured value, and offer to replace it.
bg-[#f8f8f8]
// fixes to
bg-light
text-[var(--gray)]
// fixes to
text-dark
This is all dependent on the project's configuration.
Out of scope:
- Similar (but not exact) colors are not flagged. Only exact matches are done.
- No unit conversion is done to/from rem/px, for example.
Describe alternatives you've considered
- The current rule is
no-arbitrary-value, but that shuts them off completely. - More granularity on
no-arbitrary-value. There are specific things that tend to get duplicated, liketext-,bg-, andborder-. Disabling arbitrary values on these could help prevent these from spreading. - Instead of going completely for the "all values", make a very targeted rule for the most common offenders.
**Risks:
Arbitrary values come later in the stylesheet, so a fixer will not be 100% safe to run. However, these should already be considered bugs, hopefully caught by no-contradicting-classname.
Additional context
I'm working on this right now for a private project, so I'll get it done regardless in the next couple weeks, but I thought it may be useful to have it more broadly available.