storybookjs / eslint-plugin-storybook

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

Rules for forced typing Meta and Stories #137

Open dartess opened 1 year ago

dartess commented 1 year ago

Is your feature request related to a problem? Please describe.

Each default export must be typed as Meta. Each exported story must be typed as StoryObj.

Describe the solution you'd like

export default must be an object and must contain satisfies Meta< ... >

export ... should be typed as StoryObj< ... > or Story (https://storybook.js.org/docs/react/configure/typescript#write-stories-with-typescript)

dartess commented 1 year ago

I made implementations for internal use, they are suitable for our case, but I'm sure they do not cover many edge cases.

https://gist.github.com/dartess/615fd442461db793a417def8e5060681

hjoelh commented 1 year ago

Add meta-satisfies-type rule https://github.com/storybookjs/eslint-plugin-storybook/pull/124