This repository was archived by the owner on Feb 6, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +7
-6
lines changed
__tests__/fixtures/feature-storybook-ref Expand file tree Collapse file tree 4 files changed +7
-6
lines changed Original file line number Diff line number Diff line change 11// Copyright 2021 Canva Inc. All Rights Reserved.
22
3- import { storiesOf } from "@storybook/react" ;
43import * as React from "react" ;
54
65export default {
Original file line number Diff line number Diff line change 11// Copyright 2021 Canva Inc. All Rights Reserved.
22
3- import { storiesOf , type Meta } from "@storybook/react" ;
3+ import { type Meta } from "@storybook/react" ;
44import * as React from "react" ;
55
66export default {
Original file line number Diff line number Diff line change 11// Copyright 2021 Canva Inc. All Rights Reserved.
22
3- import { storiesOf , type Meta } from "@storybook/react" ;
3+ import { type Meta } from "@storybook/react" ;
44import * as React from "react" ;
55
66export default {
Original file line number Diff line number Diff line change @@ -88,6 +88,8 @@ export class FeatureFileProcessor extends TypeScriptFileProcessor {
8888
8989 const walkTree = ( node : ts . Node ) : void => {
9090 if (
91+ // storiesOf syntax is used
92+ importFound &&
9193 ts . isCallExpression ( node ) &&
9294 FeatureFileProcessor . isStoriesOf ( node . expression )
9395 ) {
@@ -102,7 +104,8 @@ export class FeatureFileProcessor extends TypeScriptFileProcessor {
102104 return ;
103105 }
104106
105- if ( ts . isExportAssignment ( node ) ) {
107+ // no storiesOf syntax found, csf3 is assumed
108+ if ( ! importFound && ts . isExportAssignment ( node ) ) {
106109 let { expression } = node ;
107110 if (
108111 ts . isAsExpression ( expression ) ||
@@ -136,8 +139,7 @@ export class FeatureFileProcessor extends TypeScriptFileProcessor {
136139 // Look for stories import first
137140 if ( ! importFound && FeatureFileProcessor . isStoriesImport ( node ) ) {
138141 importFound = true ;
139- } else if ( importFound && ! ts . isImportDeclaration ( node ) ) {
140- // Look for `storiesOf` calls only if there was import
142+ } else if ( ! ts . isImportDeclaration ( node ) ) {
141143 walkTree ( node ) ;
142144 }
143145 } ;
You can’t perform that action at this time.
0 commit comments