eslint-plugin-tailwindcss: [BUG] Support eslint's new config file (flat) for recommended rules
When using eslint’s new config file format, such as this eslint.config.js:
import tw from "eslint-plugin-tailwindcss"
export default [
tw.configs.recommended
]
Errors out:
Oops! Something went wrong! 😦 ESLint: 8.50.0 A config object has a “plugins” key defined as an array of strings. Flat config requires “plugins” to be an object in this form: { plugins: { tailwindcss: pluginObject } } Please see the following page for information on how to convert your config object into the correct format: https://eslint.org/docs/latest/use/configure/migration-guide#importing-plugins-and-custom-parsers If you’re using a shareable config that you cannot rewrite in flat config format, then use the compatibility utility: https://eslint.org/docs/latest/use/configure/migration-guide#using-eslintrc-configs-in-flat-config
Is there a way to add recommended tailwind rules using ESlint’s new config format?
About this issue
- Original URL
- State: open
- Created 9 months ago
- Reactions: 13
- Comments: 17 (2 by maintainers)
Just some stranger on the internet here to say thanks to all of you above - this is such a niche issue (“I want to sort my TailwindCSS classes with Antfu, but Antfu and Tailwind had a public falling out so there’s no official support and now I’m down into a github issue”)
And it works! This is what makes the internet great. Thanks everyone!
Hi @francoismassart The @antfu/eslint-config widely used in vue or nuxt is flat style, maybe you can refer to how he does the convert? It would be great to be able to combine them!
@awdr74100, this is my temporary method.
https://github.com/Sun-ZhenXing/algo-code-mgr/blob/main/eslint.config.js
I was using
eslint@^9.0.0withFlatCompatwhen I encountered the same issue. I reverted toeslint@^8.0.0(v8.57.0; with FlatCompat) and it worked fine so it seems to be an issue that occurred with the latesteslintversion.@Sun-ZhenXing I can’t seem to get @antfu/eslint-config to work with tailwind class sorting in
.vuefiles. I’ve tried everything, is there anything special you did?A migration guide has been added to eslint’s docs: https://eslint.org/docs/latest/extend/plugin-migration-flat-config
Here’s my config, using antfu’s v2.11 eslint config
Be careful you need to use
...compat.config({...})and not...compat.extends({...})