schoero / eslint-plugin-readable-tailwind

ESLint plugin to automatically break up long tailwind class strings into multiple lines for better readability.
MIT License
93 stars 3 forks source link

ESLint 9 support? #41

Closed pcboy closed 3 months ago

pcboy commented 4 months ago

https://eslint.org/blog/2024/04/eslint-v9.0.0-released/

Is there any plan to support eslint 9 flat config format?

Or is it already working and I'm missing it? I tried to do:

import readableTailwind from 'eslint-plugin-readable-tailwind';

export default tseslint.config(
  ...eslintPluginReadableTailwind.configs.warning
)

But then I get:

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: {
            readable-tailwind: pluginObject
        }
    }

Seems like the format changed so I suppose there is no ESLint 9 support yet.

schoero commented 4 months ago

I think this is a bug.

The plugins in the shared configs are indeed defined as a string[]. For the .esm export, this should be changed to an object as described in the error message you have posted.

https://github.com/schoero/eslint-plugin-readable-tailwind/blob/b33d458bcd3ea39a8e5a59c12fed4e2f880d7bde/src/configs/config.ts#L13


I should have time to fix and test this on the weekend. Until then you should be able work around this by defining the rules manually.

import eslintPluginReadableTailwind from "eslint-plugin-readable-tailwind";

 export default [{
    plugins: {
      "readable-tailwind": eslintPluginReadableTailwind
    },
    rules: {
      "readable-tailwind/multiline": "warn",
      "readable-tailwind/no-unnecessary-whitespace": "warn",
      "readable-tailwind/sort-classes": "warn"
    }
  }]