Skip to content

Commit

Permalink
Merge pull request #26516 from storybookjs/kasper/allow-empty-compone…
Browse files Browse the repository at this point in the history
…nt-title

Bug: Remove redundant component check, as we auto-generate titles from the file system
(cherry picked from commit b389754)
  • Loading branch information
kasperpeulen authored and storybook-bot committed Mar 20, 2024
1 parent e222987 commit 6173a6c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
12 changes: 10 additions & 2 deletions code/lib/csf-tools/src/CsfFile.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -619,15 +619,23 @@ describe('CsfFile', () => {
});

it('no metadata', () => {
expect(() =>
expect(
parse(
dedent`
export default { foo: '5' };
export const A = () => {};
export const B = () => {};
`
)
).toThrow('CSF: missing title/component');
).toMatchInlineSnapshot(`
meta:
title: Default Title
stories:
- id: default-title--a
name: A
- id: default-title--b
name: B
`);
});

it('dynamic titles', () => {
Expand Down
8 changes: 0 additions & 8 deletions code/lib/csf-tools/src/CsfFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -478,14 +478,6 @@ export class CsfFile {
throw new NoMetaError('missing default export', self._ast, self._fileName);
}

if (!self._meta.title && !self._meta.component) {
throw new Error(dedent`
CSF: missing title/component ${formatLocation(self._ast, self._fileName)}
More info: https://storybook.js.org/docs/react/writing-stories#default-export
`);
}

// default export can come at any point in the file, so we do this post processing last
const entries = Object.entries(self._stories);
self._meta.title = this._makeTitle(self._meta?.title as string);
Expand Down

0 comments on commit 6173a6c

Please sign in to comment.