From 2994f88bad69366392cc18cb37fe0561fda82c2e Mon Sep 17 00:00:00 2001 From: Yadong Zhang Date: Sun, 14 Aug 2022 06:02:40 +0000 Subject: [PATCH 1/5] fix: handled external 'add' method. --- .../source-loader/src/abstract-syntax-tree/parse-helpers.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code/lib/source-loader/src/abstract-syntax-tree/parse-helpers.js b/code/lib/source-loader/src/abstract-syntax-tree/parse-helpers.js index 5b2aa2dc2292..f4f21284b496 100644 --- a/code/lib/source-loader/src/abstract-syntax-tree/parse-helpers.js +++ b/code/lib/source-loader/src/abstract-syntax-tree/parse-helpers.js @@ -103,7 +103,7 @@ export function handleExportedName(storyName, originalNode, parent) { } export function handleADD(node, parent, storiesOfIdentifiers) { - if (!node.property || !node.property.name || node.property.name !== 'add') { + if (!node.property || !node.property.name) { return {}; } @@ -130,7 +130,7 @@ export function handleADD(node, parent, storiesOfIdentifiers) { return {}; } - if (storyName.value) { + if (storyName.value && typeof storyName.value !== 'number') { const key = sanitize(storyName.value); let idToFramework; if (key && framework) { From 9f022f6f05d31e7be45972d8bcaa54356840e408 Mon Sep 17 00:00:00 2001 From: Yadong Zhang Date: Sun, 14 Aug 2022 06:35:02 +0000 Subject: [PATCH 2/5] test: updated snapshot. --- ...rator.csf.test.js.injectStoryParameters-posix.snapshot | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/code/lib/source-loader/src/abstract-syntax-tree/__snapshots__/inject-decorator.csf.test.js.injectStoryParameters-posix.snapshot b/code/lib/source-loader/src/abstract-syntax-tree/__snapshots__/inject-decorator.csf.test.js.injectStoryParameters-posix.snapshot index 5b50732e7967..3594fffcb172 100644 --- a/code/lib/source-loader/src/abstract-syntax-tree/__snapshots__/inject-decorator.csf.test.js.injectStoryParameters-posix.snapshot +++ b/code/lib/source-loader/src/abstract-syntax-tree/__snapshots__/inject-decorator.csf.test.js.injectStoryParameters-posix.snapshot @@ -4,11 +4,5 @@ exports[`inject-decorator injectStoryParameters - ts - csf includes storySource " -Basic.parameters = { storySource: { source: \\"() => (\\\\n \\\\n)\\" }, ...Basic.parameters }; -WithParams.parameters = { storySource: { source: \\"() => \\" }, ...WithParams.parameters }; -WithDocsParams.parameters = { storySource: { source: \\"() => \\" }, ...WithDocsParams.parameters }; -WithStorySourceParams.parameters = { storySource: { source: \\"() => \\" }, ...WithStorySourceParams.parameters }; -WithTemplate.parameters = { storySource: { source: \\"(args: Args) => \\\\n)\\" }, ...Basic.parameters }; +WithParams.parameters = { storySource: { source: \\"() => \\" }, ...WithParams.parameters }; +WithDocsParams.parameters = { storySource: { source: \\"() => \\" }, ...WithDocsParams.parameters }; +WithStorySourceParams.parameters = { storySource: { source: \\"() => \\" }, ...WithStorySourceParams.parameters }; +WithTemplate.parameters = { storySource: { source: \\"(args: Args) =>