-
-
Notifications
You must be signed in to change notification settings - Fork 75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] Support eslint's new config file (flat) for recommended rules #280
Comments
Hi @beorn |
Hi, @beorn npm install @eslint/eslintrc --save-dev
import { FlatCompat } from '@eslint/eslintrc'
const compat = new FlatCompat()
export default [
// mimic ESLintRC-style extends
...compat.extends({
extends: ['plugin:tailwindcss/recommended'],
rules: {
'tailwindcss/no-custom-classname': 'off',
'tailwindcss/migration-from-tailwind-2': 'off',
},
}),
] |
Hi @francoismassart |
@awdr74100, this is my temporary method. https://github.com/Sun-ZhenXing/algo-code-mgr/blob/main/eslint.config.js |
@Sun-ZhenXing Yes, thanks, it seems like using |
A migration guide has been added to eslint's docs: https://eslint.org/docs/latest/extend/plugin-migration-flat-config |
We only use project that use eslint flat config at this point, any updates to this being supported? |
@itpropro you can use this workaround: #280 (comment). There is no need to wait till all plugins have migrated to flat config. |
Be careful you need to use |
@Sun-ZhenXing I can't seem to get @antfu/eslint-config to work with tailwind class sorting in |
Here's my config, using antfu's v2.11 eslint config // https://github.com/antfu/eslint-config#customization
import antfu from "@antfu/eslint-config";
// workaround for flat config not being supported yet by eslint-plugin-tailwindcss
// https://github.com/francoismassart/eslint-plugin-tailwindcss/issues/280
import { FlatCompat } from "@eslint/eslintrc";
const compat = new FlatCompat();
export default antfu(
{
// Customize the stylistic rules
stylistic: {
quotes: "double", // or 'double'
semi: true,
},
rules: {
// Changing the default, we don't like this because when you rename ie. a field then things break
"object-shorthand": ["warn", "never"],
// We like our curly braces. Always.
"curly": ["warn", "all"],
// Keep line length below 120 characters
"max-len": ["error", { code: 120 }],
// Experimenting too much for now.
// TODO evaluate if we need to enable this again
"no-console": "warn",
},
formatters: {
graphql: "prettier",
css: "prettier",
markdown: "prettier",
html: "prettier",
prettierOptions: {
},
},
},
{
files: ["*.json"],
rules: {
"max-len": "off",
},
},
...compat.config({
// https://github.com/francoismassart/eslint-plugin-tailwindcss
extends: ["plugin:tailwindcss/recommended"],
rules: {
"tailwindcss/no-custom-classname": "off",
},
}),
{
ignores: ["**/generated.*", "**/locales/generated/**"],
},
); |
I have this, and many other changes, in {
/****************************************
* Ant Fu eslint
****************************************/
// https://github.com/antfu/eslint-config#vs-code-support-auto-fix
// Enable the ESlint flat config support
"eslint.experimental.useFlatConfig": true,
..........
} |
Still can't get |
@tylerolson it definitely works in VS Code via compat as already confirmed by several others in this thread. It's hard to help you without seeing the full code of your configuration. Please submit a minimal repro. |
I was using |
Just some stranger on the internet here to say thanks to all of you above - this is such a niche issue And it works! |
When using eslint's new config file format, such as this
eslint.config.js
:Errors out:
Is there a way to add recommended tailwind rules using ESlint's new config format?
The text was updated successfully, but these errors were encountered: