Repository navigation
Detecting broken utility classes in Tailwind v4 #19579
Replies: 3 comments 2 replies
|
You could consider using some kind of regex pattern, like |
|
For finding every place that still uses an old token, you want a rule that checks classes against your current theme. Once the apps are migrated, the next thing that bites is drift: people (and AI agents) reaching for |
|
Tailwind can’t flag these at build time because an unknown class is just a normal HTML class; the scanner only emits CSS for candidates that resolve. I’d add
settings: {
"better-tailwindcss": { entryPoint: "src/styles.css" },
},
rules: {
"better-tailwindcss/no-unknown-classes": "error",
},That should report — |
Uh oh!
There was an error while loading. Please reload this page.
Our system is made up of a common library that makes use of Tailwind v4, and a number of consuming projects.
We have just made quite a large change to our library where we renamed some of our semantic tokens.
The previous tokens were being exported and published on npm for the consuming applications to import and make use of.
We are now in the process up migrating the consuming projects. I was expecting building (using vite) the project, or using the tailwind cli to flag the broken utility classes, however this has not happened, and we're now having to go through the projects file by file.
For example, we use to have the semantic token
--color-primary. This has now been rename to--color-cta-primary.Is there any way for us to quickly identify these broken utility classes?
All reactions