diff --git a/packages/internal/src/generate/typeDefinitions.ts b/packages/internal/src/generate/typeDefinitions.ts index 75cd070e59b2..42227f1c3124 100644 --- a/packages/internal/src/generate/typeDefinitions.ts +++ b/packages/internal/src/generate/typeDefinitions.ts @@ -384,7 +384,7 @@ declare module '@storybook/react' { ) const hasCliStorybookVite = Object.keys( - packageJson['devDependencies'] + packageJson['devDependencies'], ).includes('@redwoodjs/cli-storybook-vite') if (hasCliStorybook || hasCliStorybookVite) { diff --git a/packages/storybook/src/plugins/docgen-handlers/actualNameHandler.ts b/packages/storybook/src/plugins/docgen-handlers/actualNameHandler.ts index 01889ddf9dcf..691d90452bf7 100644 --- a/packages/storybook/src/plugins/docgen-handlers/actualNameHandler.ts +++ b/packages/storybook/src/plugins/docgen-handlers/actualNameHandler.ts @@ -9,46 +9,53 @@ * directly from displayNameHandler, using the same approach as babel-plugin-react-docgen. */ -import type { Handler, NodePath, babelTypes as t } from 'react-docgen'; -import { utils } from 'react-docgen'; +import type { Handler, NodePath, babelTypes as t } from 'react-docgen' +import { utils } from 'react-docgen' -const { getNameOrValue, isReactForwardRefCall } = utils; +const { getNameOrValue, isReactForwardRefCall } = utils -const actualNameHandler: Handler = function actualNameHandler(documentation, componentDefinition) { +const actualNameHandler: Handler = function actualNameHandler( + documentation, + componentDefinition, +) { if ( - (componentDefinition.isClassDeclaration() || componentDefinition.isFunctionDeclaration()) && + (componentDefinition.isClassDeclaration() || + componentDefinition.isFunctionDeclaration()) && componentDefinition.has('id') ) { documentation.set( 'actualName', - getNameOrValue(componentDefinition.get('id') as NodePath) - ); + getNameOrValue(componentDefinition.get('id') as NodePath), + ) } else if ( componentDefinition.isArrowFunctionExpression() || componentDefinition.isFunctionExpression() || isReactForwardRefCall(componentDefinition) ) { - let currentPath: NodePath = componentDefinition; + let currentPath: NodePath = componentDefinition while (currentPath.parentPath) { if (currentPath.parentPath.isVariableDeclarator()) { - documentation.set('actualName', getNameOrValue(currentPath.parentPath.get('id'))); - return; + documentation.set( + 'actualName', + getNameOrValue(currentPath.parentPath.get('id')), + ) + return } if (currentPath.parentPath.isAssignmentExpression()) { - const leftPath = currentPath.parentPath.get('left'); + const leftPath = currentPath.parentPath.get('left') if (leftPath.isIdentifier() || leftPath.isLiteral()) { - documentation.set('actualName', getNameOrValue(leftPath)); - return; + documentation.set('actualName', getNameOrValue(leftPath)) + return } } - currentPath = currentPath.parentPath; + currentPath = currentPath.parentPath } // Could not find an actual name - documentation.set('actualName', ''); + documentation.set('actualName', '') } -}; +} -export default actualNameHandler; +export default actualNameHandler