From 30af3c78662a52f17a25af074aa33ce5e74660e6 Mon Sep 17 00:00:00 2001 From: Kasper Peulen Date: Fri, 15 Mar 2024 14:08:11 +0100 Subject: [PATCH] Remove redundant component check, as we auto-generate titles from the file system --- code/lib/csf-tools/src/CsfFile.test.ts | 12 ++++++++++-- code/lib/csf-tools/src/CsfFile.ts | 8 -------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/code/lib/csf-tools/src/CsfFile.test.ts b/code/lib/csf-tools/src/CsfFile.test.ts index 7e0d223a23af..21e902cce52f 100644 --- a/code/lib/csf-tools/src/CsfFile.test.ts +++ b/code/lib/csf-tools/src/CsfFile.test.ts @@ -619,7 +619,7 @@ describe('CsfFile', () => { }); it('no metadata', () => { - expect(() => + expect( parse( dedent` export default { foo: '5' }; @@ -627,7 +627,15 @@ describe('CsfFile', () => { 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', () => { diff --git a/code/lib/csf-tools/src/CsfFile.ts b/code/lib/csf-tools/src/CsfFile.ts index f1cce083da96..4516a293b1cc 100644 --- a/code/lib/csf-tools/src/CsfFile.ts +++ b/code/lib/csf-tools/src/CsfFile.ts @@ -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);