storybookjs / eslint-plugin-storybook

🎗Official ESLint plugin for Storybook
MIT License
245 stars 52 forks source link

Support for the new FlatConfig format #135

Open AndreaPontrandolfo opened 1 year ago

AndreaPontrandolfo commented 1 year ago

Any plans to support the new Eslint FlatConfig format, eslint.config.js? In the next major release of Eslint, the new format is gonna be the default and the old format deprecated, so it should be updated.

jaydenseric commented 1 year ago

The most obvious thing that needs to happen is to publish TypeScript typings for the package, so that you can programmatically import and use this ESLint plugin with type safety when your eslint.config.js file is type-checked:

// @ts-check

// Currently `any` :(
// Even worse, it's actually a TypeScript error if `compilerOptions.moduleResolution`
// is configured to `bundler` instead of `nodenext`, about there being no default export.
import eslintPluginStorybook from "eslint-plugin-storybook";
yannbf commented 1 year ago

Hey there! Thanks for opening this issue.

Are you willing to contribute to make this happen? I'm happy to guide in the process if needed!

waldemarfm commented 1 year ago

@yannbf I'm interested in helping with this. I don't think it'll be too complicated.

Would the approach be a major version bump and go all in on the change, or do we somehow offer support for both formats and make it opt-in for projects using flag configs?

AndreaPontrandolfo commented 1 year ago

I would love to contribute but i also have my hands-full with OSS projects right now.

yannbf commented 11 months ago

Hey @AndreaPontrandolfo @waldemarfm contributions are definitely welcome. If this change can be done in a backwards compatible way, that'd be definitely preferred! If you know what are the steps to support this format, describing those would already be quite helpful as well!

mheob commented 8 months ago

Some more information: Plugin Migration to Flat Config - ESLint

xdebbie commented 3 months ago

Do we have any new updates on this issue?

yannbf commented 3 months ago

Hey everyone! There is a canary version that introduced support to the flat config file while trying to maintain it backwards compatible. We are not 100% confident of merging it yet, so please give it a try:

npm install eslint-plugin-storybook@0.9.0--canary.156.da7873a.0
# or 
yarn add eslint-plugin-storybook@0.9.0--canary.156.da7873a.0

Feedback is truly appreciated.

jerkovicl commented 3 months ago

@yannbf Tested on project and linting works with flat config, only thing to improve is types but that's already mentioned in PR

Adamlb commented 3 months ago

eslint-plugin-storybook@0.9.0--canary.156.da7873a.0 Works for me with eslint 8.57

bmulholland commented 3 months ago

canary has been working for us with eslint 9 & flat config

rikisamurai commented 3 months ago

Hey everyone! There is a canary version that introduced support to the flat config file while trying to maintain it backwards compatible. We are not 100% confident of merging it yet, so please give it a try:

npm install eslint-plugin-storybook@0.9.0--canary.156.da7873a.0
# or 
yarn add eslint-plugin-storybook@0.9.0--canary.156.da7873a.0

Feedback is truly appreciated.

hello,could you tell how to configure this plugin in the flat config?

bmulholland commented 3 months ago

eslint.config.js:

import eslintPluginStorybook from "eslint-plugin-storybook"

export default [
   // other config here
  ...eslintPluginStorybook.configs["flat/recommended"],
  // more config
]
stevezhu commented 3 months ago

Not sure if anyone is running into this, but it seems I had to make this change when using eslint-plugin-storybook@0.9.0--canary.156.da7873a.0 in dist/configs/flat/recommended.js

     {
         name: 'storybook:recommended:stories-rules',
-        files: ['*.stories.@(ts|tsx|js|jsx|mjs|cjs)', '*.story.@(ts|tsx|js|jsx|mjs|cjs)'],
+        files: ['**/*.stories.@(ts|tsx|js|jsx|mjs|cjs)', '**/*.story.@(ts|tsx|js|jsx|mjs|cjs)'],
kuschti commented 3 months ago

Not sure if anyone is running into this, but it seems I had to make this change when using eslint-plugin-storybook@0.9.0--canary.156.da7873a.0 in dist/configs/flat/recommended.js

     {
         name: 'storybook:recommended:stories-rules',
-        files: ['*.stories.@(ts|tsx|js|jsx|mjs|cjs)', '*.story.@(ts|tsx|js|jsx|mjs|cjs)'],
+        files: ['**/*.stories.@(ts|tsx|js|jsx|mjs|cjs)', '**/*.story.@(ts|tsx|js|jsx|mjs|cjs)'],

we have the same problem, it's already mentioned in the flat-config PR #156

maxpatiiuk commented 3 months ago

Thank you for updating this package to support flat config. However, I encountered an issue as this package depends on a very old version of @typescript-eslint/utils ^5.62.0. That version of @typescript-eslint/utils does not support ESLint 9, which causes yarn dependency resolution to fail

stevezhu commented 3 months ago

Not sure if anyone is running into this, but it seems I had to make this change when using eslint-plugin-storybook@0.9.0--canary.156.da7873a.0 in dist/configs/flat/recommended.js

     {
         name: 'storybook:recommended:stories-rules',
-        files: ['*.stories.@(ts|tsx|js|jsx|mjs|cjs)', '*.story.@(ts|tsx|js|jsx|mjs|cjs)'],
+        files: ['**/*.stories.@(ts|tsx|js|jsx|mjs|cjs)', '**/*.story.@(ts|tsx|js|jsx|mjs|cjs)'],

we have the same problem, it's already mentioned in the flat-config PR #156

Ah great didn't catch that, thanks!