storybookjs / eslint-plugin-storybook

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

importing story meta from another module and re-exporting it is not working #158

Open pkyeck opened 3 months ago

pkyeck commented 3 months ago

Describe the bug I split up my stories for a certain component b/c the file was just getting bigger and bigger but I wanted to have a central file with the meta information like so:

// ComponentA.meta.ts

export const meta: Meta<Props> = {
  title: 'Templates/Common/ComponentA',
  render: (args) => ComponentA(args),
  tags: ['tag1'],
  // ...
}

// ComponentAExtra1.stories.ts

export { meta as default } from './ComponentA.meta'
export const ComponentAExtra1Story: StoryObj<Props> = {
  // ...
}

// ComponentAExtra2.stories.ts

export { meta as default } from './ComponentA.meta'
export const ComponentAExtra2Story: StoryObj<Props> = {
  // ...
}

but the plugin is complaining that

The file should have a default export. eslint(storybook/default-exports)

Should this be working? I also tried to import first and then export default meta then the plugin is not complaining but storybook will tell me: CSF: missing default export

Is it possible to share the meta object and how?

yannbf commented 2 months ago

Hey @pkyeck throughout the years I've never seen users do what you just did! 🤔 I would honestly not recommend doing what you're doing because the Storybook team doesn't really test this internally, so it's possible that some tools in the ecosystem might miss it. But if you feel strongly about it, you could make a PR to the eslint plugin to support this use case, and I can help you get it merged.