diff --git a/code/.eslintrc.js b/code/.eslintrc.js index efb47a4e193..baac3337d8d 100644 --- a/code/.eslintrc.js +++ b/code/.eslintrc.js @@ -19,6 +19,10 @@ module.exports = { }, plugins: ['local-rules'], rules: { + 'import/no-extraneous-dependencies': [ + 'error', + { devDependencies: true, peerDependencies: true }, + ], 'import/no-unresolved': 'off', // covered by typescript 'eslint-comments/disable-enable-pair': ['error', { allowWholeFile: true }], 'eslint-comments/no-unused-disable': 'error', @@ -55,7 +59,13 @@ module.exports = { }, }, { - files: ['**/template/**/*', '**/vitest.config.ts', '**/addons/docs/**/*'], + files: [ + '*.test.*', + '*.spec.*', + '**/template/**/*', + '**/vitest.config.ts', + '**/addons/docs/**/*', + ], rules: { 'import/no-extraneous-dependencies': 'off', }, diff --git a/code/.storybook/main.ts b/code/.storybook/main.ts index 6a1f51f62f7..b72d89e61a6 100644 --- a/code/.storybook/main.ts +++ b/code/.storybook/main.ts @@ -1,6 +1,7 @@ import path from 'path'; // eslint-disable-next-line @typescript-eslint/no-restricted-imports import { mergeConfig } from 'vite'; + import type { StorybookConfig } from '../frameworks/react-vite'; const componentsPath = path.join(__dirname, '../core/src/components'); diff --git a/code/.storybook/manager.tsx b/code/.storybook/manager.tsx index 0bf39f832e2..b6c5ed75c34 100644 --- a/code/.storybook/manager.tsx +++ b/code/.storybook/manager.tsx @@ -1,4 +1,5 @@ import { addons } from 'storybook/internal/manager-api'; + import startCase from 'lodash/startCase.js'; addons.setConfig({ diff --git a/code/.storybook/preview-head.html b/code/.storybook/preview-head.html index 4037d732ffe..6bd5bc77dbe 100644 --- a/code/.storybook/preview-head.html +++ b/code/.storybook/preview-head.html @@ -1,3 +1,2 @@ - +; diff --git a/code/.storybook/preview.tsx b/code/.storybook/preview.tsx index 548f29473ef..07d79f19474 100644 --- a/code/.storybook/preview.tsx +++ b/code/.storybook/preview.tsx @@ -1,24 +1,26 @@ -import { global } from '@storybook/global'; import React, { Fragment, useEffect } from 'react'; -import { isChromatic } from './isChromatic'; + +import type { Channel } from 'storybook/internal/channels'; +import { DocsContext as DocsContextProps, useArgs } from 'storybook/internal/preview-api'; +import type { PreviewWeb } from 'storybook/internal/preview-api'; import { Global, ThemeProvider, - themes, - createReset, convert, + createReset, styled, + themes, useTheme, } from 'storybook/internal/theming'; -import { useArgs, DocsContext as DocsContextProps } from 'storybook/internal/preview-api'; -import type { PreviewWeb } from 'storybook/internal/preview-api'; -import type { ReactRenderer, Decorator } from '@storybook/react'; -import type { Channel } from 'storybook/internal/channels'; import { DocsContext } from '@storybook/blocks'; +import { global } from '@storybook/global'; +import type { Decorator, ReactRenderer } from '@storybook/react'; + import { MINIMAL_VIEWPORTS } from '@storybook/addon-viewport'; import { DocsPageWrapper } from '../lib/blocks/src/components'; +import { isChromatic } from './isChromatic'; const { document } = global; diff --git a/code/addons/a11y/README.md b/code/addons/a11y/README.md index 64730ef6103..a6c984d21f6 100755 --- a/code/addons/a11y/README.md +++ b/code/addons/a11y/README.md @@ -168,7 +168,7 @@ You can override these options [at story level too](https://storybook.js.org/doc ```js import React from 'react'; -import { storiesOf, addDecorator, addParameters } from '@storybook/react'; +import { addDecorator, addParameters, storiesOf } from '@storybook/react'; export default { title: 'button', diff --git a/code/addons/a11y/src/a11yRunner.test.ts b/code/addons/a11y/src/a11yRunner.test.ts index 15d99c41002..402ff24f6cb 100644 --- a/code/addons/a11y/src/a11yRunner.test.ts +++ b/code/addons/a11y/src/a11yRunner.test.ts @@ -1,6 +1,8 @@ import type { Mock } from 'vitest'; -import { describe, beforeEach, it, expect, vi } from 'vitest'; +import { beforeEach, describe, expect, it, vi } from 'vitest'; + import { addons } from 'storybook/internal/preview-api'; + import { EVENTS } from './constants'; vi.mock('storybook/internal/preview-api'); diff --git a/code/addons/a11y/src/a11yRunner.ts b/code/addons/a11y/src/a11yRunner.ts index 44bac1ee093..e1cae2ec96b 100644 --- a/code/addons/a11y/src/a11yRunner.ts +++ b/code/addons/a11y/src/a11yRunner.ts @@ -1,5 +1,7 @@ -import { global } from '@storybook/global'; import { addons } from 'storybook/internal/preview-api'; + +import { global } from '@storybook/global'; + import { EVENTS } from './constants'; import type { A11yParameters } from './params'; diff --git a/code/addons/a11y/src/components/A11YPanel.test.tsx b/code/addons/a11y/src/components/A11YPanel.test.tsx index 7c621b6a377..a88e3b67828 100644 --- a/code/addons/a11y/src/components/A11YPanel.test.tsx +++ b/code/addons/a11y/src/components/A11YPanel.test.tsx @@ -1,14 +1,14 @@ // @vitest-environment happy-dom +import { act, cleanup, fireEvent, render, waitFor } from '@testing-library/react'; +import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'; -import { describe, beforeEach, afterEach, it, expect, vi } from 'vitest'; import React from 'react'; -import { render, waitFor, fireEvent, act, cleanup } from '@testing-library/react'; -import { ThemeProvider, themes, convert } from 'storybook/internal/theming'; import * as api from 'storybook/internal/manager-api'; +import { ThemeProvider, convert, themes } from 'storybook/internal/theming'; -import { A11YPanel } from './A11YPanel'; import { EVENTS } from '../constants'; +import { A11YPanel } from './A11YPanel'; vi.mock('storybook/internal/manager-api'); diff --git a/code/addons/a11y/src/components/A11YPanel.tsx b/code/addons/a11y/src/components/A11YPanel.tsx index 0931bb5cc65..4e259c4c155 100644 --- a/code/addons/a11y/src/components/A11YPanel.tsx +++ b/code/addons/a11y/src/components/A11YPanel.tsx @@ -1,25 +1,23 @@ import React, { useCallback, useMemo, useState } from 'react'; -import { styled } from 'storybook/internal/theming'; - import { ActionBar, ScrollArea } from 'storybook/internal/components'; -import { SyncIcon, CheckIcon } from '@storybook/icons'; - -import type { AxeResults } from 'axe-core'; import { useChannel, useParameter, useStorybookApi, useStorybookState, } from 'storybook/internal/manager-api'; +import { styled } from 'storybook/internal/theming'; -import { Report } from './Report'; +import { CheckIcon, SyncIcon } from '@storybook/icons'; -import { Tabs } from './Tabs'; +import type { AxeResults } from 'axe-core'; -import { useA11yContext } from './A11yContext'; import { EVENTS } from '../constants'; import type { A11yParameters } from '../params'; +import { useA11yContext } from './A11yContext'; +import { Report } from './Report'; +import { Tabs } from './Tabs'; export enum RuleType { VIOLATION, diff --git a/code/addons/a11y/src/components/A11yContext.test.tsx b/code/addons/a11y/src/components/A11yContext.test.tsx index c6514310678..1a1aab3412b 100644 --- a/code/addons/a11y/src/components/A11yContext.test.tsx +++ b/code/addons/a11y/src/components/A11yContext.test.tsx @@ -1,15 +1,18 @@ // @vitest-environment happy-dom +import { act, cleanup, render } from '@testing-library/react'; +import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'; -import { describe, beforeEach, afterEach, it, expect, vi } from 'vitest'; import * as React from 'react'; -import type { AxeResults } from 'axe-core'; -import { render, act, cleanup } from '@testing-library/react'; -import * as api from 'storybook/internal/manager-api'; + import { STORY_CHANGED } from 'storybook/internal/core-events'; +import * as api from 'storybook/internal/manager-api'; + import { HIGHLIGHT } from '@storybook/addon-highlight'; -import { A11yContextProvider, useA11yContext } from './A11yContext'; +import type { AxeResults } from 'axe-core'; + import { EVENTS } from '../constants'; +import { A11yContextProvider, useA11yContext } from './A11yContext'; vi.mock('storybook/internal/manager-api'); const mockedApi = vi.mocked(api); diff --git a/code/addons/a11y/src/components/A11yContext.tsx b/code/addons/a11y/src/components/A11yContext.tsx index 80c74518bc1..35bc476328b 100644 --- a/code/addons/a11y/src/components/A11yContext.tsx +++ b/code/addons/a11y/src/components/A11yContext.tsx @@ -1,9 +1,13 @@ import * as React from 'react'; -import { themes, convert } from 'storybook/internal/theming'; -import type { Result } from 'axe-core'; -import { useChannel, useAddonState, useStorybookApi } from 'storybook/internal/manager-api'; + import { STORY_CHANGED, STORY_RENDERED } from 'storybook/internal/core-events'; +import { useAddonState, useChannel, useStorybookApi } from 'storybook/internal/manager-api'; +import { convert, themes } from 'storybook/internal/theming'; + import { HIGHLIGHT } from '@storybook/addon-highlight'; + +import type { Result } from 'axe-core'; + import { ADDON_ID, EVENTS } from '../constants'; export interface Results { diff --git a/code/addons/a11y/src/components/Report/Elements.tsx b/code/addons/a11y/src/components/Report/Elements.tsx index d17697f66f8..6f1bf8f203b 100644 --- a/code/addons/a11y/src/components/Report/Elements.tsx +++ b/code/addons/a11y/src/components/Report/Elements.tsx @@ -4,10 +4,10 @@ import React from 'react'; import { styled } from 'storybook/internal/theming'; import type { NodeResult } from 'axe-core'; -import { Rules } from './Rules'; import type { RuleType } from '../A11YPanel'; import HighlightToggle from './HighlightToggle'; +import { Rules } from './Rules'; const Item = styled.li({ fontWeight: 600, diff --git a/code/addons/a11y/src/components/Report/HighlightToggle.test.tsx b/code/addons/a11y/src/components/Report/HighlightToggle.test.tsx index b01b1d73120..4bfc197395a 100644 --- a/code/addons/a11y/src/components/Report/HighlightToggle.test.tsx +++ b/code/addons/a11y/src/components/Report/HighlightToggle.test.tsx @@ -1,11 +1,13 @@ // @vitest-environment happy-dom +import { cleanup, fireEvent, render } from '@testing-library/react'; +import { afterEach, describe, expect, it, vi } from 'vitest'; -import { describe, it, expect, afterEach, vi } from 'vitest'; import React from 'react'; -import { render, fireEvent, cleanup } from '@testing-library/react'; + import type { NodeResult } from 'axe-core'; -import HighlightToggle from './HighlightToggle'; + import { A11yContext } from '../A11yContext'; +import HighlightToggle from './HighlightToggle'; const nodeResult = (target: string): NodeResult => ({ html: '', diff --git a/code/addons/a11y/src/components/Report/HighlightToggle.tsx b/code/addons/a11y/src/components/Report/HighlightToggle.tsx index 40f08966add..acbd1159945 100644 --- a/code/addons/a11y/src/components/Report/HighlightToggle.tsx +++ b/code/addons/a11y/src/components/Report/HighlightToggle.tsx @@ -1,7 +1,9 @@ import React from 'react'; + import { styled } from 'storybook/internal/theming'; import type { NodeResult } from 'axe-core'; + import { useA11yContext } from '../A11yContext'; interface ToggleProps { diff --git a/code/addons/a11y/src/components/Report/Info.tsx b/code/addons/a11y/src/components/Report/Info.tsx index 052cfb8de6b..e85bac76ff6 100644 --- a/code/addons/a11y/src/components/Report/Info.tsx +++ b/code/addons/a11y/src/components/Report/Info.tsx @@ -2,6 +2,7 @@ import type { FC } from 'react'; import React from 'react'; import { styled } from 'storybook/internal/theming'; + import type { Result } from 'axe-core'; const Wrapper = styled.div({ diff --git a/code/addons/a11y/src/components/Report/Item.tsx b/code/addons/a11y/src/components/Report/Item.tsx index 2089da0f63a..54f564d1ed3 100644 --- a/code/addons/a11y/src/components/Report/Item.tsx +++ b/code/addons/a11y/src/components/Report/Item.tsx @@ -2,15 +2,15 @@ import React, { Fragment, useState } from 'react'; import { styled } from 'storybook/internal/theming'; -import type { Result } from 'axe-core'; -import { Info } from './Info'; +import { ChevronSmallDownIcon } from '@storybook/icons'; -import { Elements } from './Elements'; -import { Tags } from './Tags'; +import type { Result } from 'axe-core'; import type { RuleType } from '../A11YPanel'; +import { Elements } from './Elements'; import HighlightToggle from './HighlightToggle'; -import { ChevronSmallDownIcon } from '@storybook/icons'; +import { Info } from './Info'; +import { Tags } from './Tags'; const Wrapper = styled.div(({ theme }) => ({ display: 'flex', diff --git a/code/addons/a11y/src/components/Report/Rules.tsx b/code/addons/a11y/src/components/Report/Rules.tsx index a24ded693da..4c4a9ed037c 100644 --- a/code/addons/a11y/src/components/Report/Rules.tsx +++ b/code/addons/a11y/src/components/Report/Rules.tsx @@ -1,7 +1,9 @@ import type { FC } from 'react'; import React from 'react'; -import { styled } from 'storybook/internal/theming'; + import { Badge } from 'storybook/internal/components'; +import { styled } from 'storybook/internal/theming'; + import type { CheckResult } from 'axe-core'; import { useResizeDetector } from 'react-resize-detector'; diff --git a/code/addons/a11y/src/components/Report/Tags.tsx b/code/addons/a11y/src/components/Report/Tags.tsx index 4d8c2e81a38..e16c4d52f51 100644 --- a/code/addons/a11y/src/components/Report/Tags.tsx +++ b/code/addons/a11y/src/components/Report/Tags.tsx @@ -2,6 +2,7 @@ import type { FC } from 'react'; import React from 'react'; import { styled } from 'storybook/internal/theming'; + import type { TagValue } from 'axe-core'; const Wrapper = styled.div({ diff --git a/code/addons/a11y/src/components/Report/index.tsx b/code/addons/a11y/src/components/Report/index.tsx index 0644488614f..0de6a7d8f58 100644 --- a/code/addons/a11y/src/components/Report/index.tsx +++ b/code/addons/a11y/src/components/Report/index.tsx @@ -1,11 +1,12 @@ import type { FC } from 'react'; import React, { Fragment } from 'react'; + import { EmptyTabContent } from 'storybook/internal/components'; -import type { Result } from 'axe-core'; -import { Item } from './Item'; +import type { Result } from 'axe-core'; import type { RuleType } from '../A11YPanel'; +import { Item } from './Item'; export interface ReportProps { items: Result[]; diff --git a/code/addons/a11y/src/components/Tabs.tsx b/code/addons/a11y/src/components/Tabs.tsx index 6a3fbecbd46..08ae46714db 100644 --- a/code/addons/a11y/src/components/Tabs.tsx +++ b/code/addons/a11y/src/components/Tabs.tsx @@ -1,12 +1,13 @@ import * as React from 'react'; import { styled } from 'storybook/internal/theming'; + import type { NodeResult, Result } from 'axe-core'; import { useResizeDetector } from 'react-resize-detector'; -import HighlightToggle from './Report/HighlightToggle'; import type { RuleType } from './A11YPanel'; import { useA11yContext } from './A11yContext'; +import HighlightToggle from './Report/HighlightToggle'; // TODO: reuse the Tabs component from @storybook/theming instead of re-building identical functionality diff --git a/code/addons/a11y/src/components/VisionSimulator.test.tsx b/code/addons/a11y/src/components/VisionSimulator.test.tsx index 4fb2e127e0b..5db1d38e797 100644 --- a/code/addons/a11y/src/components/VisionSimulator.test.tsx +++ b/code/addons/a11y/src/components/VisionSimulator.test.tsx @@ -1,11 +1,13 @@ // @vitest-environment happy-dom - /// ; -import { describe, it, expect } from 'vitest'; -import React from 'react'; -import { render, fireEvent, screen, waitFor } from '@testing-library/react'; +import { fireEvent, render, screen, waitFor } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; -import { ThemeProvider, themes, convert } from 'storybook/internal/theming'; +import { describe, expect, it } from 'vitest'; + +import React from 'react'; + +import { ThemeProvider, convert, themes } from 'storybook/internal/theming'; + import { VisionSimulator, baseList } from './VisionSimulator'; const getOptionByNameAndPercentage = (option: string, percentage?: number) => diff --git a/code/addons/a11y/src/components/VisionSimulator.tsx b/code/addons/a11y/src/components/VisionSimulator.tsx index 419da70240a..2acc66b21c7 100644 --- a/code/addons/a11y/src/components/VisionSimulator.tsx +++ b/code/addons/a11y/src/components/VisionSimulator.tsx @@ -1,9 +1,11 @@ import type { ReactNode } from 'react'; import React, { useState } from 'react'; + +import { IconButton, TooltipLinkList, WithTooltip } from 'storybook/internal/components'; import { Global, styled } from 'storybook/internal/theming'; -import { IconButton, WithTooltip, TooltipLinkList } from 'storybook/internal/components'; import { AccessibilityIcon } from '@storybook/icons'; + import { Filters } from './ColorFilters'; const iframeId = 'storybook-preview-iframe'; diff --git a/code/addons/a11y/src/manager.test.tsx b/code/addons/a11y/src/manager.test.tsx index 546551ff946..c95bdf629d0 100644 --- a/code/addons/a11y/src/manager.test.tsx +++ b/code/addons/a11y/src/manager.test.tsx @@ -1,8 +1,9 @@ // @vitest-environment happy-dom +import { describe, expect, it, vi } from 'vitest'; -import { describe, it, expect, vi } from 'vitest'; import * as api from 'storybook/internal/manager-api'; import type { Addon_BaseType } from 'storybook/internal/types'; + import { PANEL_ID } from './constants'; import './manager'; diff --git a/code/addons/a11y/src/manager.tsx b/code/addons/a11y/src/manager.tsx index b423e029b31..41e79b3061d 100644 --- a/code/addons/a11y/src/manager.tsx +++ b/code/addons/a11y/src/manager.tsx @@ -1,11 +1,13 @@ import React from 'react'; -import { addons, types, useAddonState } from 'storybook/internal/manager-api'; + import { Badge, Spaced } from 'storybook/internal/components'; -import { ADDON_ID, PANEL_ID, PARAM_KEY } from './constants'; -import { VisionSimulator } from './components/VisionSimulator'; +import { addons, types, useAddonState } from 'storybook/internal/manager-api'; + import { A11YPanel } from './components/A11YPanel'; import type { Results } from './components/A11yContext'; import { A11yContextProvider } from './components/A11yContext'; +import { VisionSimulator } from './components/VisionSimulator'; +import { ADDON_ID, PANEL_ID, PARAM_KEY } from './constants'; const Title = () => { const [addonState] = useAddonState(ADDON_ID); diff --git a/code/addons/a11y/src/params.ts b/code/addons/a11y/src/params.ts index 4d529eac850..2428b38add4 100644 --- a/code/addons/a11y/src/params.ts +++ b/code/addons/a11y/src/params.ts @@ -1,4 +1,4 @@ -import type { ElementContext, Spec, RunOptions } from 'axe-core'; +import type { ElementContext, RunOptions, Spec } from 'axe-core'; export interface Setup { element?: ElementContext; diff --git a/code/addons/a11y/vitest.config.ts b/code/addons/a11y/vitest.config.ts index 03172200442..7420176b2e4 100644 --- a/code/addons/a11y/vitest.config.ts +++ b/code/addons/a11y/vitest.config.ts @@ -1,4 +1,5 @@ import { defineConfig, mergeConfig } from 'vitest/config'; + import { vitestCommonConfig } from '../../vitest.workspace'; export default mergeConfig( diff --git a/code/addons/actions/src/addArgs.ts b/code/addons/actions/src/addArgs.ts index 1a114fa2222..f0ee718ed28 100644 --- a/code/addons/actions/src/addArgs.ts +++ b/code/addons/actions/src/addArgs.ts @@ -1,4 +1,5 @@ import type { ArgsEnhancer } from 'storybook/internal/types'; + import { addActionsFromArgTypes, inferActionsFromArgTypesRegex } from './addArgsHelpers'; export const argsEnhancers: ArgsEnhancer[] = [ diff --git a/code/addons/actions/src/addArgsHelpers.test.ts b/code/addons/actions/src/addArgsHelpers.test.ts index 4ad092c93b9..99b8da57908 100644 --- a/code/addons/actions/src/addArgsHelpers.test.ts +++ b/code/addons/actions/src/addArgsHelpers.test.ts @@ -1,6 +1,8 @@ -import { describe, it, expect } from 'vitest'; +import { describe, expect, it } from 'vitest'; + import type { StoryContext } from 'storybook/internal/types'; -import { inferActionsFromArgTypesRegex, addActionsFromArgTypes } from './addArgsHelpers'; + +import { addActionsFromArgTypes, inferActionsFromArgTypesRegex } from './addArgsHelpers'; describe('actions parameter enhancers', () => { describe('actions.argTypesRegex parameter', () => { diff --git a/code/addons/actions/src/addArgsHelpers.ts b/code/addons/actions/src/addArgsHelpers.ts index f86400fdaab..f13b98274df 100644 --- a/code/addons/actions/src/addArgsHelpers.ts +++ b/code/addons/actions/src/addArgsHelpers.ts @@ -1,4 +1,5 @@ -import type { Args, Renderer, ArgsEnhancer } from 'storybook/internal/types'; +import type { Args, ArgsEnhancer, Renderer } from 'storybook/internal/types'; + import { action } from './runtime/action'; // interface ActionsParameter { diff --git a/code/addons/actions/src/components/ActionLogger/index.tsx b/code/addons/actions/src/components/ActionLogger/index.tsx index afff6535f04..25ab0da611a 100644 --- a/code/addons/actions/src/components/ActionLogger/index.tsx +++ b/code/addons/actions/src/components/ActionLogger/index.tsx @@ -1,13 +1,14 @@ import type { ElementRef, ReactNode } from 'react'; -import React, { forwardRef, Fragment, useEffect, useRef } from 'react'; +import React, { Fragment, forwardRef, useEffect, useRef } from 'react'; + +import { ActionBar, ScrollArea } from 'storybook/internal/components'; import type { Theme } from 'storybook/internal/theming'; import { styled, withTheme } from 'storybook/internal/theming'; import { Inspector } from 'react-inspector'; -import { ActionBar, ScrollArea } from 'storybook/internal/components'; -import { Action, Counter, InspectorContainer } from './style'; import type { ActionDisplay } from '../../models'; +import { Action, Counter, InspectorContainer } from './style'; const UnstyledWrapped = forwardRef( ({ children, className }, ref) => ( diff --git a/code/addons/actions/src/components/ActionLogger/style.tsx b/code/addons/actions/src/components/ActionLogger/style.tsx index 351cda9a95a..77e5e30e910 100644 --- a/code/addons/actions/src/components/ActionLogger/style.tsx +++ b/code/addons/actions/src/components/ActionLogger/style.tsx @@ -1,4 +1,5 @@ import { styled } from 'storybook/internal/theming'; + import { opacify } from 'polished'; export const Action = styled.div({ diff --git a/code/addons/actions/src/containers/ActionLogger/index.tsx b/code/addons/actions/src/containers/ActionLogger/index.tsx index ff9e5030263..075ba94af56 100644 --- a/code/addons/actions/src/containers/ActionLogger/index.tsx +++ b/code/addons/actions/src/containers/ActionLogger/index.tsx @@ -1,12 +1,13 @@ import React, { Component } from 'react'; -import { dequal as deepEqual } from 'dequal'; -import type { API } from 'storybook/internal/manager-api'; import { STORY_CHANGED } from 'storybook/internal/core-events'; +import type { API } from 'storybook/internal/manager-api'; + +import { dequal as deepEqual } from 'dequal'; import { ActionLogger as ActionLoggerComponent } from '../../components/ActionLogger'; -import type { ActionDisplay } from '../../models'; import { CLEAR_ID, EVENT_ID } from '../../constants'; +import type { ActionDisplay } from '../../models'; interface ActionLoggerProps { active: boolean; diff --git a/code/addons/actions/src/decorator.ts b/code/addons/actions/src/decorator.ts index 6e8319680cd..e0eb6148f21 100644 --- a/code/addons/actions/src/decorator.ts +++ b/code/addons/actions/src/decorator.ts @@ -1,9 +1,10 @@ -import { global } from '@storybook/global'; -import { useEffect, makeDecorator } from 'storybook/internal/preview-api'; +import { makeDecorator, useEffect } from 'storybook/internal/preview-api'; import type { PartialStoryFn, Renderer } from 'storybook/internal/types'; -import { actions } from './runtime/actions'; + +import { global } from '@storybook/global'; import { PARAM_KEY } from './constants'; +import { actions } from './runtime/actions'; const { document, Element } = global; diff --git a/code/addons/actions/src/loaders.ts b/code/addons/actions/src/loaders.ts index 93bc938cb65..585d8e3815b 100644 --- a/code/addons/actions/src/loaders.ts +++ b/code/addons/actions/src/loaders.ts @@ -1,7 +1,9 @@ /* eslint-disable no-underscore-dangle */ import type { LoaderFunction } from 'storybook/internal/types'; + import { global } from '@storybook/global'; import type { onMockCall as onMockCallType } from '@storybook/test'; + import { action } from './runtime'; let subscribed = false; diff --git a/code/addons/actions/src/manager.tsx b/code/addons/actions/src/manager.tsx index 944f5e4e597..341d9c1f423 100644 --- a/code/addons/actions/src/manager.tsx +++ b/code/addons/actions/src/manager.tsx @@ -1,9 +1,11 @@ import React from 'react'; -import { addons, types, useAddonState, useChannel } from 'storybook/internal/manager-api'; -import { STORY_CHANGED } from 'storybook/internal/core-events'; + import { Badge, Spaced } from 'storybook/internal/components'; -import ActionLogger from './containers/ActionLogger'; +import { STORY_CHANGED } from 'storybook/internal/core-events'; +import { addons, types, useAddonState, useChannel } from 'storybook/internal/manager-api'; + import { ADDON_ID, CLEAR_ID, EVENT_ID, PANEL_ID, PARAM_KEY } from './constants'; +import ActionLogger from './containers/ActionLogger'; function Title() { const [{ count }, setCount] = useAddonState(ADDON_ID, { count: 0 }); diff --git a/code/addons/actions/src/runtime/__tests__/action.test.js b/code/addons/actions/src/runtime/__tests__/action.test.js index 5276d7a75e5..cd6e695304f 100644 --- a/code/addons/actions/src/runtime/__tests__/action.test.js +++ b/code/addons/actions/src/runtime/__tests__/action.test.js @@ -1,5 +1,7 @@ -import { describe, it, expect, vi } from 'vitest'; +import { describe, expect, it, vi } from 'vitest'; + import { addons } from 'storybook/internal/preview-api'; + import { action, configureActions } from '../..'; vi.mock('storybook/internal/preview-api'); diff --git a/code/addons/actions/src/runtime/__tests__/actions.test.js b/code/addons/actions/src/runtime/__tests__/actions.test.js index 04cf68b9e79..3e524d827a0 100644 --- a/code/addons/actions/src/runtime/__tests__/actions.test.js +++ b/code/addons/actions/src/runtime/__tests__/actions.test.js @@ -1,5 +1,7 @@ -import { describe, it, expect, vi } from 'vitest'; +import { describe, expect, it, vi } from 'vitest'; + import { addons } from 'storybook/internal/preview-api'; + import { actions } from '../..'; vi.mock('storybook/internal/preview-api'); diff --git a/code/addons/actions/src/runtime/__tests__/configureActions.test.js b/code/addons/actions/src/runtime/__tests__/configureActions.test.js index 7034904a2a5..acd29ac3316 100644 --- a/code/addons/actions/src/runtime/__tests__/configureActions.test.js +++ b/code/addons/actions/src/runtime/__tests__/configureActions.test.js @@ -1,6 +1,7 @@ -import { describe, it, expect } from 'vitest'; -import { config } from '../configureActions'; +import { describe, expect, it } from 'vitest'; + import { configureActions } from '../..'; +import { config } from '../configureActions'; describe('Configure Actions', () => { it('can configure actions', () => { diff --git a/code/addons/actions/src/runtime/action.ts b/code/addons/actions/src/runtime/action.ts index a5b39c3e340..00295c007e8 100644 --- a/code/addons/actions/src/runtime/action.ts +++ b/code/addons/actions/src/runtime/action.ts @@ -1,9 +1,12 @@ -import { v4 as uuidv4 } from 'uuid'; import type { PreviewWeb } from 'storybook/internal/preview-api'; import { addons } from 'storybook/internal/preview-api'; +import { ImplicitActionsDuringRendering } from 'storybook/internal/preview-errors'; import type { Renderer } from 'storybook/internal/types'; + import { global } from '@storybook/global'; -import { ImplicitActionsDuringRendering } from 'storybook/internal/preview-errors'; + +import { v4 as uuidv4 } from 'uuid'; + import { EVENT_ID } from '../constants'; import type { ActionDisplay, ActionOptions, HandlerFunction } from '../models'; import { config } from './configureActions'; diff --git a/code/addons/actions/src/runtime/actions.ts b/code/addons/actions/src/runtime/actions.ts index 3deeb185e64..9cbb57c4198 100644 --- a/code/addons/actions/src/runtime/actions.ts +++ b/code/addons/actions/src/runtime/actions.ts @@ -1,5 +1,5 @@ +import type { ActionOptions, ActionsFunction, ActionsMap } from '../models'; import { action } from './action'; -import type { ActionsFunction, ActionOptions, ActionsMap } from '../models'; import { config } from './configureActions'; export const actions: ActionsFunction = (...args: any[]) => { diff --git a/code/addons/actions/template/stories/parameters.stories.ts b/code/addons/actions/template/stories/parameters.stories.ts index e4a5bf0ef9d..f184f89a153 100644 --- a/code/addons/actions/template/stories/parameters.stories.ts +++ b/code/addons/actions/template/stories/parameters.stories.ts @@ -1,4 +1,5 @@ import { global as globalThis } from '@storybook/global'; + import { withActions } from '@storybook/addon-actions/decorator'; export default { diff --git a/code/addons/actions/vitest.config.ts b/code/addons/actions/vitest.config.ts index 03172200442..7420176b2e4 100644 --- a/code/addons/actions/vitest.config.ts +++ b/code/addons/actions/vitest.config.ts @@ -1,4 +1,5 @@ import { defineConfig, mergeConfig } from 'vitest/config'; + import { vitestCommonConfig } from '../../vitest.workspace'; export default mergeConfig( diff --git a/code/addons/backgrounds/src/components/Tool.tsx b/code/addons/backgrounds/src/components/Tool.tsx index e214780714e..5f94606d061 100644 --- a/code/addons/backgrounds/src/components/Tool.tsx +++ b/code/addons/backgrounds/src/components/Tool.tsx @@ -1,9 +1,10 @@ -import React, { useState, memo, Fragment, useCallback } from 'react'; +import React, { Fragment, memo, useCallback, useState } from 'react'; +import { IconButton, TooltipLinkList, WithTooltip } from 'storybook/internal/components'; import { useGlobals, useParameter } from 'storybook/internal/manager-api'; -import { IconButton, WithTooltip, TooltipLinkList } from 'storybook/internal/components'; import { CircleIcon, GridIcon, PhotoIcon, RefreshIcon } from '@storybook/icons'; + import { PARAM_KEY as KEY } from '../constants'; import type { Background, BackgroundMap, Config, GlobalStateUpdate } from '../types'; diff --git a/code/addons/backgrounds/src/decorator.ts b/code/addons/backgrounds/src/decorator.ts index bdee2f2ea19..ecaccb44c99 100644 --- a/code/addons/backgrounds/src/decorator.ts +++ b/code/addons/backgrounds/src/decorator.ts @@ -1,13 +1,13 @@ import { useEffect } from 'storybook/internal/preview-api'; import type { Renderer, - PartialStoryFn as StoryFunction, StoryContext, + PartialStoryFn as StoryFunction, } from 'storybook/internal/types'; import { PARAM_KEY as KEY } from './constants'; -import { clearStyles, addBackgroundStyle, isReduceMotionEnabled, addGridStyle } from './utils'; import type { Config, GridConfig } from './types'; +import { addBackgroundStyle, addGridStyle, clearStyles, isReduceMotionEnabled } from './utils'; const defaultGrid: GridConfig = { cellSize: 100, diff --git a/code/addons/backgrounds/src/legacy/BackgroundSelectorLegacy.tsx b/code/addons/backgrounds/src/legacy/BackgroundSelectorLegacy.tsx index dcc8ffb8e65..cc5bc3d00b7 100644 --- a/code/addons/backgrounds/src/legacy/BackgroundSelectorLegacy.tsx +++ b/code/addons/backgrounds/src/legacy/BackgroundSelectorLegacy.tsx @@ -1,15 +1,17 @@ import type { FC, ReactElement } from 'react'; -import React, { useState, useCallback, useMemo, memo } from 'react'; -import memoize from 'memoizerific'; +import React, { memo, useCallback, useMemo, useState } from 'react'; -import { useParameter, useGlobals } from 'storybook/internal/manager-api'; import { logger } from 'storybook/internal/client-logger'; -import { IconButton, WithTooltip, TooltipLinkList } from 'storybook/internal/components'; +import { IconButton, TooltipLinkList, WithTooltip } from 'storybook/internal/components'; +import { useGlobals, useParameter } from 'storybook/internal/manager-api'; import { PhotoIcon } from '@storybook/icons'; + +import memoize from 'memoizerific'; + import { PARAM_KEY as BACKGROUNDS_PARAM_KEY } from '../constants'; -import { ColorIcon } from './ColorIcon'; import type { Background } from '../types'; +import { ColorIcon } from './ColorIcon'; import { getBackgroundColorByName } from './getBackgroundColorByName'; export interface DeprecatedGlobalState { diff --git a/code/addons/backgrounds/src/legacy/GridSelectorLegacy.tsx b/code/addons/backgrounds/src/legacy/GridSelectorLegacy.tsx index e061fd4f231..2cb6e192574 100644 --- a/code/addons/backgrounds/src/legacy/GridSelectorLegacy.tsx +++ b/code/addons/backgrounds/src/legacy/GridSelectorLegacy.tsx @@ -1,10 +1,11 @@ import type { FC } from 'react'; import React, { memo } from 'react'; -import { useGlobals, useParameter } from 'storybook/internal/manager-api'; import { IconButton } from 'storybook/internal/components'; +import { useGlobals, useParameter } from 'storybook/internal/manager-api'; import { GridIcon } from '@storybook/icons'; + import { PARAM_KEY as BACKGROUNDS_PARAM_KEY } from '../constants'; export const GridToolLegacy: FC = memo(function GridSelector() { diff --git a/code/addons/backgrounds/src/legacy/getBackgroundColorByName.ts b/code/addons/backgrounds/src/legacy/getBackgroundColorByName.ts index 95b5296752c..e5fea7ee637 100644 --- a/code/addons/backgrounds/src/legacy/getBackgroundColorByName.ts +++ b/code/addons/backgrounds/src/legacy/getBackgroundColorByName.ts @@ -1,5 +1,7 @@ -import { dedent } from 'ts-dedent'; import { logger } from 'storybook/internal/client-logger'; + +import { dedent } from 'ts-dedent'; + import type { Background } from '../types'; export const getBackgroundColorByName = ( diff --git a/code/addons/backgrounds/src/legacy/withBackgroundLegacy.ts b/code/addons/backgrounds/src/legacy/withBackgroundLegacy.ts index ba649a0a1d3..a7d42e9d46b 100644 --- a/code/addons/backgrounds/src/legacy/withBackgroundLegacy.ts +++ b/code/addons/backgrounds/src/legacy/withBackgroundLegacy.ts @@ -1,12 +1,12 @@ -import { useMemo, useEffect } from 'storybook/internal/preview-api'; +import { useEffect, useMemo } from 'storybook/internal/preview-api'; import type { Renderer, - PartialStoryFn as StoryFunction, StoryContext, + PartialStoryFn as StoryFunction, } from 'storybook/internal/types'; import { PARAM_KEY as BACKGROUNDS_PARAM_KEY } from '../constants'; -import { clearStyles, addBackgroundStyle, isReduceMotionEnabled } from '../utils'; +import { addBackgroundStyle, clearStyles, isReduceMotionEnabled } from '../utils'; import { getBackgroundColorByName } from './getBackgroundColorByName'; export const withBackground = ( diff --git a/code/addons/backgrounds/src/legacy/withGridLegacy.ts b/code/addons/backgrounds/src/legacy/withGridLegacy.ts index 801a1962d92..3fb711c772e 100644 --- a/code/addons/backgrounds/src/legacy/withGridLegacy.ts +++ b/code/addons/backgrounds/src/legacy/withGridLegacy.ts @@ -1,12 +1,12 @@ -import { useMemo, useEffect } from 'storybook/internal/preview-api'; +import { useEffect, useMemo } from 'storybook/internal/preview-api'; import type { Renderer, - PartialStoryFn as StoryFunction, StoryContext, + PartialStoryFn as StoryFunction, } from 'storybook/internal/types'; -import { clearStyles, addGridStyle } from '../utils'; import { PARAM_KEY as BACKGROUNDS_PARAM_KEY } from '../constants'; +import { addGridStyle, clearStyles } from '../utils'; export const withGrid = (StoryFn: StoryFunction, context: StoryContext) => { const { globals, parameters } = context; diff --git a/code/addons/backgrounds/src/manager.tsx b/code/addons/backgrounds/src/manager.tsx index 3f8ab23da58..a1cc71c46ea 100644 --- a/code/addons/backgrounds/src/manager.tsx +++ b/code/addons/backgrounds/src/manager.tsx @@ -1,10 +1,11 @@ import React, { Fragment } from 'react'; + import { addons, types } from 'storybook/internal/manager-api'; +import { BackgroundTool } from './components/Tool'; import { ADDON_ID } from './constants'; import { BackgroundToolLegacy } from './legacy/BackgroundSelectorLegacy'; import { GridToolLegacy } from './legacy/GridSelectorLegacy'; -import { BackgroundTool } from './components/Tool'; addons.register(ADDON_ID, () => { addons.add(ADDON_ID, { diff --git a/code/addons/backgrounds/src/preview.ts b/code/addons/backgrounds/src/preview.ts index dad8dad077b..9d773da2d48 100644 --- a/code/addons/backgrounds/src/preview.ts +++ b/code/addons/backgrounds/src/preview.ts @@ -1,8 +1,9 @@ import type { Addon_DecoratorFunction } from 'storybook/internal/types'; -import { withBackground } from './legacy/withBackgroundLegacy'; -import { withGrid } from './legacy/withGridLegacy'; + import { PARAM_KEY as KEY } from './constants'; import { withBackgroundAndGrid } from './decorator'; +import { withBackground } from './legacy/withBackgroundLegacy'; +import { withGrid } from './legacy/withGridLegacy'; import type { Config, GlobalState } from './types'; export const decorators: Addon_DecoratorFunction[] = FEATURES?.backgroundsStoryGlobals diff --git a/code/addons/backgrounds/vitest.config.ts b/code/addons/backgrounds/vitest.config.ts index 03172200442..7420176b2e4 100644 --- a/code/addons/backgrounds/vitest.config.ts +++ b/code/addons/backgrounds/vitest.config.ts @@ -1,4 +1,5 @@ import { defineConfig, mergeConfig } from 'vitest/config'; + import { vitestCommonConfig } from '../../vitest.workspace'; export default mergeConfig( diff --git a/code/addons/controls/src/ControlsPanel.tsx b/code/addons/controls/src/ControlsPanel.tsx index 20d3e695c2b..a84591aefb4 100644 --- a/code/addons/controls/src/ControlsPanel.tsx +++ b/code/addons/controls/src/ControlsPanel.tsx @@ -1,19 +1,22 @@ -import { dequal as deepEqual } from 'dequal'; import React, { useEffect, useMemo, useState } from 'react'; -import { global } from '@storybook/global'; + import { + useArgTypes, useArgs, useGlobals, - useArgTypes, useParameter, useStorybookState, } from 'storybook/internal/manager-api'; -import { PureArgsTable as ArgsTable, type PresetColor, type SortType } from '@storybook/blocks'; import { styled } from 'storybook/internal/theming'; import type { ArgTypes } from 'storybook/internal/types'; -import { PARAM_KEY } from './constants'; +import { PureArgsTable as ArgsTable, type PresetColor, type SortType } from '@storybook/blocks'; +import { global } from '@storybook/global'; + +import { dequal as deepEqual } from 'dequal'; + import { SaveStory } from './SaveStory'; +import { PARAM_KEY } from './constants'; // Remove undefined values (top-level only) const clean = (obj: { [key: string]: any }) => diff --git a/code/addons/controls/src/SaveStory.stories.tsx b/code/addons/controls/src/SaveStory.stories.tsx index 9dbe620da7f..9c39f6746e0 100644 --- a/code/addons/controls/src/SaveStory.stories.tsx +++ b/code/addons/controls/src/SaveStory.stories.tsx @@ -1,9 +1,11 @@ import React from 'react'; -import { action } from '@storybook/addon-actions'; + import type { Meta, StoryObj } from '@storybook/react'; +import { expect, fireEvent, fn, userEvent, within } from '@storybook/test'; + +import { action } from '@storybook/addon-actions'; import { SaveStory } from './SaveStory'; -import { expect, fireEvent, fn, userEvent, within } from '@storybook/test'; const meta = { component: SaveStory, diff --git a/code/addons/controls/src/SaveStory.tsx b/code/addons/controls/src/SaveStory.tsx index 8cb9bf716a3..56e50a0f032 100644 --- a/code/addons/controls/src/SaveStory.tsx +++ b/code/addons/controls/src/SaveStory.tsx @@ -1,3 +1,5 @@ +import React from 'react'; + import { Bar as BaseBar, Button, @@ -7,9 +9,9 @@ import { TooltipNote, WithTooltip, } from 'storybook/internal/components'; -import { AddIcon, CheckIcon, UndoIcon } from '@storybook/icons'; import { keyframes, styled } from 'storybook/internal/theming'; -import React from 'react'; + +import { AddIcon, CheckIcon, UndoIcon } from '@storybook/icons'; const slideIn = keyframes({ from: { transform: 'translateY(40px)' }, diff --git a/code/addons/controls/src/manager.tsx b/code/addons/controls/src/manager.tsx index 31640963a52..b745bad9eb1 100644 --- a/code/addons/controls/src/manager.tsx +++ b/code/addons/controls/src/manager.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import { dequal as deepEqual } from 'dequal'; + import { AddonPanel, Badge, Spaced } from 'storybook/internal/components'; import type { ResponseData, @@ -14,9 +14,13 @@ import { useArgTypes, } from 'storybook/internal/manager-api'; import { color } from 'storybook/internal/theming'; + +import type { Args } from '@storybook/csf'; + +import { dequal as deepEqual } from 'dequal'; + import { ControlsPanel } from './ControlsPanel'; import { ADDON_ID, PARAM_KEY } from './constants'; -import type { Args } from '@storybook/csf'; function Title() { const rows = useArgTypes(); diff --git a/code/addons/controls/src/preset/checkDocsLoaded.ts b/code/addons/controls/src/preset/checkDocsLoaded.ts index bd801324a1e..ff29457f59f 100644 --- a/code/addons/controls/src/preset/checkDocsLoaded.ts +++ b/code/addons/controls/src/preset/checkDocsLoaded.ts @@ -1,4 +1,5 @@ import { checkAddonOrder, serverRequire } from 'storybook/internal/common'; + import path from 'path'; export const checkDocsLoaded = (configDir: string) => { diff --git a/code/addons/controls/template/stories/basics.stories.ts b/code/addons/controls/template/stories/basics.stories.ts index a75abbf2fb4..bcd5cd147aa 100644 --- a/code/addons/controls/template/stories/basics.stories.ts +++ b/code/addons/controls/template/stories/basics.stories.ts @@ -1,6 +1,7 @@ -import { global as globalThis } from '@storybook/global'; import type { PartialStoryFn, StoryContext } from 'storybook/internal/types'; +import { global as globalThis } from '@storybook/global'; + export default { component: globalThis.Components.Pre, decorators: [ diff --git a/code/addons/controls/template/stories/conditional.stories.ts b/code/addons/controls/template/stories/conditional.stories.ts index ed3c51d8ba8..56d43aa7366 100644 --- a/code/addons/controls/template/stories/conditional.stories.ts +++ b/code/addons/controls/template/stories/conditional.stories.ts @@ -1,6 +1,7 @@ -import { global as globalThis } from '@storybook/global'; import type { PartialStoryFn, StoryContext } from 'storybook/internal/types'; +import { global as globalThis } from '@storybook/global'; + export default { component: globalThis.Components.Pre, decorators: [ diff --git a/code/addons/controls/template/stories/disable.stories.ts b/code/addons/controls/template/stories/disable.stories.ts index 653840df5de..2402d982e45 100644 --- a/code/addons/controls/template/stories/disable.stories.ts +++ b/code/addons/controls/template/stories/disable.stories.ts @@ -1,6 +1,7 @@ -import { global as globalThis } from '@storybook/global'; import type { PartialStoryFn, StoryContext } from 'storybook/internal/types'; +import { global as globalThis } from '@storybook/global'; + export default { component: globalThis.Components.Pre, decorators: [ diff --git a/code/addons/controls/template/stories/filters.stories.ts b/code/addons/controls/template/stories/filters.stories.ts index 983e5890524..e2378d6d0ca 100644 --- a/code/addons/controls/template/stories/filters.stories.ts +++ b/code/addons/controls/template/stories/filters.stories.ts @@ -1,6 +1,7 @@ -import { global as globalThis } from '@storybook/global'; import type { PartialStoryFn, StoryContext } from 'storybook/internal/types'; +import { global as globalThis } from '@storybook/global'; + export default { component: globalThis.Components.Pre, decorators: [ diff --git a/code/addons/controls/template/stories/issues.stories.ts b/code/addons/controls/template/stories/issues.stories.ts index b320f54b1eb..636baf38d53 100644 --- a/code/addons/controls/template/stories/issues.stories.ts +++ b/code/addons/controls/template/stories/issues.stories.ts @@ -1,6 +1,7 @@ -import { global as globalThis } from '@storybook/global'; import type { PartialStoryFn, StoryContext } from 'storybook/internal/types'; +import { global as globalThis } from '@storybook/global'; + export default { component: globalThis.Components.Pre, decorators: [ diff --git a/code/addons/controls/template/stories/matchers.stories.ts b/code/addons/controls/template/stories/matchers.stories.ts index bc5a896d4f6..b54703120f7 100644 --- a/code/addons/controls/template/stories/matchers.stories.ts +++ b/code/addons/controls/template/stories/matchers.stories.ts @@ -1,6 +1,7 @@ -import { global as globalThis } from '@storybook/global'; import type { PartialStoryFn, StoryContext } from 'storybook/internal/types'; +import { global as globalThis } from '@storybook/global'; + export default { component: globalThis.Components.Pre, decorators: [ diff --git a/code/addons/controls/template/stories/sorting.stories.ts b/code/addons/controls/template/stories/sorting.stories.ts index dc6a66acdc3..c3b7b831dec 100644 --- a/code/addons/controls/template/stories/sorting.stories.ts +++ b/code/addons/controls/template/stories/sorting.stories.ts @@ -1,6 +1,7 @@ -import { global as globalThis } from '@storybook/global'; import type { PartialStoryFn, StoryContext } from 'storybook/internal/types'; +import { global as globalThis } from '@storybook/global'; + export default { component: globalThis.Components.Pre, decorators: [ diff --git a/code/addons/controls/vitest.config.ts b/code/addons/controls/vitest.config.ts index 03172200442..7420176b2e4 100644 --- a/code/addons/controls/vitest.config.ts +++ b/code/addons/controls/vitest.config.ts @@ -1,4 +1,5 @@ import { defineConfig, mergeConfig } from 'vitest/config'; + import { vitestCommonConfig } from '../../vitest.workspace'; export default mergeConfig( diff --git a/code/addons/docs/docs/docspage.md b/code/addons/docs/docs/docspage.md index ea50050f6b9..478b674609b 100644 --- a/code/addons/docs/docs/docspage.md +++ b/code/addons/docs/docs/docspage.md @@ -70,6 +70,7 @@ You can replace DocsPage at any level by overriding the `docs.page` parameter: ```js import { addParameters } from '@storybook/react'; + addParameters({ docs: { page: null } }); ``` @@ -77,6 +78,7 @@ addParameters({ docs: { page: null } }); ```js import { Button } from './Button'; + export default { title: 'Demo/Button', component: Button, @@ -101,7 +103,7 @@ Here's an example of rebuilding `DocsPage` out of doc blocks: ```js import React from 'react'; -import { Title, Subtitle, Description, Primary, ArgsTable, Stories } from '@storybook/addon-docs'; +import { ArgsTable, Description, Primary, Stories, Subtitle, Title } from '@storybook/addon-docs'; import { DocgenButton } from '../../components/DocgenButton'; export default { @@ -140,9 +142,9 @@ That being said, there is a system in place to remove the necessity of this trad ```js import React from 'react'; -import { render } from 'react-dom'; -import toReact from '@egoist/vue-to-react'; import { addParameters } from '@storybook/vue'; +import toReact from '@egoist/vue-to-react'; +import { render } from 'react-dom'; addParameters({ docs: { diff --git a/code/addons/docs/docs/multiframework.md b/code/addons/docs/docs/multiframework.md index 070d94089b0..c68201aabdc 100644 --- a/code/addons/docs/docs/multiframework.md +++ b/code/addons/docs/docs/multiframework.md @@ -113,7 +113,7 @@ This dynamic rendering is framework-specific, meaning it needs a custom implemen Let's take a look at the React framework implementation of `dynamic` snippets as a reference for implementing this feature in other frameworks: ```tsx -import { addons, StoryContext } from '@storybook/preview-api'; +import { StoryContext, addons } from '@storybook/preview-api'; import { SNIPPET_RENDERED } from '../../shared'; export const jsxDecorator = (storyFn: any, context: StoryContext) => { @@ -150,6 +150,7 @@ Now we need a way to configure how it's displayed in the UI: ```tsx import { jsxDecorator } from './jsxDecorator'; + export const decorators = [jsxDecorator]; ``` diff --git a/code/addons/docs/docs/props-tables.md b/code/addons/docs/docs/props-tables.md index 8dd5e8f7a28..7a44a6c653a 100644 --- a/code/addons/docs/docs/props-tables.md +++ b/code/addons/docs/docs/props-tables.md @@ -104,6 +104,7 @@ Consider the following input: // Button.js import React from 'react'; import PropTypes from 'prop-types'; + export const Button = ({ label }) => ; Button.propTypes = { /** demo description */ diff --git a/code/addons/docs/docs/recipes.md b/code/addons/docs/docs/recipes.md index 0a982974f39..e760a61e08f 100644 --- a/code/addons/docs/docs/recipes.md +++ b/code/addons/docs/docs/recipes.md @@ -106,6 +106,7 @@ And I can also embed arbitrary markdown & JSX in this file. import React from 'react'; import { Button } from './Button'; import mdx from './Button.mdx'; + export default { title: 'Demo/Button', parameters: { diff --git a/code/addons/docs/docs/theming.md b/code/addons/docs/docs/theming.md index 6f66a2d3726..6c4c8ac1308 100644 --- a/code/addons/docs/docs/theming.md +++ b/code/addons/docs/docs/theming.md @@ -14,9 +14,9 @@ Storybook theming is the **recommended way** to theme your docs. Docs uses the s Supposing you have a Storybook theme defined for the main UI in `.storybook/manager.js`: ```js -import { addons } from '@storybook/manager-api'; // or a custom theme import { themes } from '@storybook/theming'; +import { addons } from '@storybook/manager-api'; addons.setConfig({ theme: themes.dark, diff --git a/code/addons/docs/ember/README.md b/code/addons/docs/ember/README.md index 7491de44284..9418707e31b 100644 --- a/code/addons/docs/ember/README.md +++ b/code/addons/docs/ember/README.md @@ -52,6 +52,7 @@ Next, add the following to your `.storybook/preview.js` to load the generated js ```js import { setJSONDoc } from '@storybook/addon-docs/ember'; import docJson from '../dist/storybook-docgen/index.json'; + setJSONDoc(docJson); ``` diff --git a/code/addons/docs/src/DocsRenderer.tsx b/code/addons/docs/src/DocsRenderer.tsx index 0124bf4dabe..238cfbb27bb 100644 --- a/code/addons/docs/src/DocsRenderer.tsx +++ b/code/addons/docs/src/DocsRenderer.tsx @@ -1,13 +1,13 @@ import type { PropsWithChildren } from 'react'; import React, { Component } from 'react'; -import { renderElement, unmountElement } from '@storybook/react-dom-shim'; import type { - Renderer, - Parameters, DocsContextProps, DocsRenderFunction, + Parameters, + Renderer, } from 'storybook/internal/types'; -import { Docs, CodeOrSourceMdx, AnchorMdx, HeadersMdx } from '@storybook/blocks'; +import { AnchorMdx, CodeOrSourceMdx, Docs, HeadersMdx } from '@storybook/blocks'; +import { renderElement, unmountElement } from '@storybook/react-dom-shim'; // TS doesn't like that we export a component with types that it doesn't know about (TS4203) export const defaultComponents: Record = { diff --git a/code/addons/docs/src/compiler/index.test.ts b/code/addons/docs/src/compiler/index.test.ts index 54ea2c2d291..4bac552fdff 100644 --- a/code/addons/docs/src/compiler/index.test.ts +++ b/code/addons/docs/src/compiler/index.test.ts @@ -1,6 +1,6 @@ -import { expect, describe, it } from 'vitest'; +import { describe, expect, it } from 'vitest'; import { dedent } from 'ts-dedent'; -import { compileSync, compile } from './index'; +import { compile, compileSync } from './index'; expect.addSnapshotSerializer({ serialize: (val: any) => (typeof val === 'string' ? val : val.toString()), diff --git a/code/addons/docs/src/plugins/mdx-plugin.ts b/code/addons/docs/src/plugins/mdx-plugin.ts index 84ce92afeac..1f9aa411689 100644 --- a/code/addons/docs/src/plugins/mdx-plugin.ts +++ b/code/addons/docs/src/plugins/mdx-plugin.ts @@ -1,9 +1,9 @@ import type { Options } from 'storybook/internal/types'; -import type { Plugin } from 'vite'; -import rehypeSlug from 'rehype-slug'; -import rehypeExternalLinks from 'rehype-external-links'; import { createFilter } from '@rollup/pluginutils'; import { dirname, join } from 'path'; +import rehypeExternalLinks from 'rehype-external-links'; +import rehypeSlug from 'rehype-slug'; +import type { Plugin } from 'vite'; import type { CompileOptions } from '../compiler'; import { compile } from '../compiler'; diff --git a/code/addons/docs/src/preset.ts b/code/addons/docs/src/preset.ts index 8d359204c22..3c5d4fe554b 100644 --- a/code/addons/docs/src/preset.ts +++ b/code/addons/docs/src/preset.ts @@ -1,10 +1,9 @@ -import { dirname, join, isAbsolute } from 'path'; -import rehypeSlug from 'rehype-slug'; -import rehypeExternalLinks from 'rehype-external-links'; - +import { logger } from 'storybook/internal/node-logger'; import type { DocsOptions, Options, PresetProperty } from 'storybook/internal/types'; import type { CsfPluginOptions } from '@storybook/csf-plugin'; -import { logger } from 'storybook/internal/node-logger'; +import { dirname, isAbsolute, join } from 'path'; +import rehypeExternalLinks from 'rehype-external-links'; +import rehypeSlug from 'rehype-slug'; import type { CompileOptions } from './compiler'; /** diff --git a/code/addons/docs/template/stories/docs2/resolved-react.stories.ts b/code/addons/docs/template/stories/docs2/resolved-react.stories.ts index 20095ec6164..27b6ba55744 100644 --- a/code/addons/docs/template/stories/docs2/resolved-react.stories.ts +++ b/code/addons/docs/template/stories/docs2/resolved-react.stories.ts @@ -1,5 +1,5 @@ -import { within, expect } from '@storybook/test'; import * as ReactExport from 'react'; +import { expect, within } from '@storybook/test'; import * as ReactDom from 'react-dom'; import * as ReactDomServer from 'react-dom/server'; diff --git a/code/addons/docs/template/stories/docspage/source.stories.ts b/code/addons/docs/template/stories/docspage/source.stories.ts index 2c92512198d..373120eb005 100644 --- a/code/addons/docs/template/stories/docspage/source.stories.ts +++ b/code/addons/docs/template/stories/docspage/source.stories.ts @@ -1,5 +1,5 @@ -import { global as globalThis } from '@storybook/global'; import type { StoryContext } from 'storybook/internal/types'; +import { global as globalThis } from '@storybook/global'; import { dedent } from 'ts-dedent'; export default { diff --git a/code/addons/essentials/src/index.ts b/code/addons/essentials/src/index.ts index d2b1ca20785..fdae10f376b 100644 --- a/code/addons/essentials/src/index.ts +++ b/code/addons/essentials/src/index.ts @@ -1,6 +1,7 @@ -import path from 'path'; -import { logger } from 'storybook/internal/node-logger'; import { serverRequire } from 'storybook/internal/common'; +import { logger } from 'storybook/internal/node-logger'; + +import path from 'path'; interface PresetOptions { /** diff --git a/code/addons/essentials/vitest.config.ts b/code/addons/essentials/vitest.config.ts index 03172200442..7420176b2e4 100644 --- a/code/addons/essentials/vitest.config.ts +++ b/code/addons/essentials/vitest.config.ts @@ -1,4 +1,5 @@ import { defineConfig, mergeConfig } from 'vitest/config'; + import { vitestCommonConfig } from '../../vitest.workspace'; export default mergeConfig( diff --git a/code/addons/gfm/src/index.ts b/code/addons/gfm/src/index.ts index 2ae1e565529..08b13e81842 100644 --- a/code/addons/gfm/src/index.ts +++ b/code/addons/gfm/src/index.ts @@ -1,7 +1,7 @@ -import { dedent } from 'ts-dedent'; import { deprecate } from 'storybook/internal/node-logger'; import remarkGfm from 'remark-gfm'; +import { dedent } from 'ts-dedent'; export const mdxLoaderOptions = async (config: any) => { config.mdxCompileOptions.remarkPlugins = config.mdxCompileOptions.remarkPlugins || []; diff --git a/code/addons/gfm/vitest.config.ts b/code/addons/gfm/vitest.config.ts index 03172200442..7420176b2e4 100644 --- a/code/addons/gfm/vitest.config.ts +++ b/code/addons/gfm/vitest.config.ts @@ -1,4 +1,5 @@ import { defineConfig, mergeConfig } from 'vitest/config'; + import { vitestCommonConfig } from '../../vitest.workspace'; export default mergeConfig( diff --git a/code/addons/highlight/README.md b/code/addons/highlight/README.md index 5f7ffbe0c3a..6f27d1fda60 100644 --- a/code/addons/highlight/README.md +++ b/code/addons/highlight/README.md @@ -32,7 +32,6 @@ Add `"@storybook/addon-highlight"` to the addons array in your `.storybook/main. ```ts // .storybook/main.ts - // Replace your-framework with the framework you are using (e.g., react-webpack5, vue3-vite) import type { StorybookConfig } from '@storybook/your-framework'; @@ -49,11 +48,9 @@ Highlight DOM nodes by emitting the `HIGHLIGHT` event from within a story or an ```ts // MyComponent.stories.ts - import type { Meta, StoryObj } from '@storybook/react'; import { useChannel } from '@storybook/preview-api'; import { HIGHLIGHT } from '@storybook/addon-highlight'; - import { MyComponent } from './MyComponent'; const meta: Meta = { @@ -82,11 +79,9 @@ Highlights are automatically cleared when the story changes. You can also manual ```ts // MyComponent.stories.ts|tsx - import type { Meta, StoryObj } from '@storybook/react'; import { useChannel } from '@storybook/preview-api'; import { HIGHLIGHT, RESET_HIGHLIGHT } from '@storybook/addon-highlight'; - import { MyComponent } from './MyComponent'; const meta: Meta = { @@ -116,11 +111,9 @@ The addon applies a standard style to the highlighted elements you've enabled fo ```ts // MyComponent.stories.ts - import type { Meta, StoryObj } from '@storybook/react'; import { useChannel } from '@storybook/preview-api'; import { HIGHLIGHT } from '@storybook/addon-highlight'; - import { MyComponent } from './MyComponent'; const meta: Meta = { diff --git a/code/addons/highlight/src/preview.ts b/code/addons/highlight/src/preview.ts index 5d38b0aa87b..7d7d43bd14d 100644 --- a/code/addons/highlight/src/preview.ts +++ b/code/addons/highlight/src/preview.ts @@ -1,8 +1,10 @@ /* eslint-env browser */ -import { global } from '@storybook/global'; -import { addons } from 'storybook/internal/preview-api'; import { STORY_CHANGED } from 'storybook/internal/core-events'; -import { HIGHLIGHT, RESET_HIGHLIGHT, HIGHLIGHT_STYLE_ID } from './constants'; +import { addons } from 'storybook/internal/preview-api'; + +import { global } from '@storybook/global'; + +import { HIGHLIGHT, HIGHLIGHT_STYLE_ID, RESET_HIGHLIGHT } from './constants'; const { document } = global; diff --git a/code/addons/highlight/vitest.config.ts b/code/addons/highlight/vitest.config.ts index 03172200442..7420176b2e4 100644 --- a/code/addons/highlight/vitest.config.ts +++ b/code/addons/highlight/vitest.config.ts @@ -1,4 +1,5 @@ import { defineConfig, mergeConfig } from 'vitest/config'; + import { vitestCommonConfig } from '../../vitest.workspace'; export default mergeConfig( diff --git a/code/addons/interactions/README.md b/code/addons/interactions/README.md index 815a83b1804..8e97267a65d 100644 --- a/code/addons/interactions/README.md +++ b/code/addons/interactions/README.md @@ -27,8 +27,8 @@ Note that `@storybook/addon-interactions` must be listed **after** `@storybook/a Interactions relies on "instrumented" versions of Vitest and Testing Library, that you import from `@storybook/test` instead of their original package. You can then use these libraries in your `play` function. ```js +import { expect, fn, userEvent, within } from '@storybook/test'; import { Button } from './Button'; -import { within, userEvent, expect, fn } from '@storybook/test'; export default { title: 'Button', diff --git a/code/addons/interactions/src/Panel.test.ts b/code/addons/interactions/src/Panel.test.ts index bb05a875e29..1d25d154dad 100644 --- a/code/addons/interactions/src/Panel.test.ts +++ b/code/addons/interactions/src/Panel.test.ts @@ -1,7 +1,8 @@ // @vitest-environment happy-dom +import { describe, expect, it } from 'vitest'; -import { describe, it, expect } from 'vitest'; import { type Call, CallStates, type LogItem } from '@storybook/instrumenter'; + import { getInteractions } from './Panel'; describe('Panel', () => { diff --git a/code/addons/interactions/src/Panel.tsx b/code/addons/interactions/src/Panel.tsx index f6e1b06b861..eec7d8a80e9 100644 --- a/code/addons/interactions/src/Panel.tsx +++ b/code/addons/interactions/src/Panel.tsx @@ -1,15 +1,17 @@ -import { global } from '@storybook/global'; import type { Dispatch, SetStateAction } from 'react'; import React, { Fragment, memo, useEffect, useMemo, useRef, useState } from 'react'; -import { useAddonState, useChannel, useParameter } from 'storybook/internal/manager-api'; + import { FORCE_REMOUNT, + PLAY_FUNCTION_THREW_EXCEPTION, STORY_RENDER_PHASE_CHANGED, STORY_THREW_EXCEPTION, - PLAY_FUNCTION_THREW_EXCEPTION, UNHANDLED_ERRORS_WHILE_PLAYING, } from 'storybook/internal/core-events'; -import { EVENTS, type Call, CallStates, type LogItem } from '@storybook/instrumenter'; +import { useAddonState, useChannel, useParameter } from 'storybook/internal/manager-api'; + +import { global } from '@storybook/global'; +import { type Call, CallStates, EVENTS, type LogItem } from '@storybook/instrumenter'; import { InteractionsPanel } from './components/InteractionsPanel'; import { ADDON_ID } from './constants'; diff --git a/code/addons/interactions/src/components/EmptyState.tsx b/code/addons/interactions/src/components/EmptyState.tsx index effaabee839..5c0ee95a1bc 100644 --- a/code/addons/interactions/src/components/EmptyState.tsx +++ b/code/addons/interactions/src/components/EmptyState.tsx @@ -1,9 +1,11 @@ import React, { useEffect, useState } from 'react'; -import { Link, EmptyTabContent } from 'storybook/internal/components'; -import { DocumentIcon, VideoIcon } from '@storybook/icons'; + +import { EmptyTabContent, Link } from 'storybook/internal/components'; import { useStorybookApi } from 'storybook/internal/manager-api'; import { styled } from 'storybook/internal/theming'; +import { DocumentIcon, VideoIcon } from '@storybook/icons'; + import { DOCUMENTATION_LINK, TUTORIAL_VIDEO_LINK } from '../constants'; const Links = styled.div(({ theme }) => ({ diff --git a/code/addons/interactions/src/components/Interaction.stories.tsx b/code/addons/interactions/src/components/Interaction.stories.tsx index 98f57909098..784c5251bf3 100644 --- a/code/addons/interactions/src/components/Interaction.stories.tsx +++ b/code/addons/interactions/src/components/Interaction.stories.tsx @@ -1,8 +1,8 @@ -import type { StoryObj, Meta } from '@storybook/react'; import { CallStates } from '@storybook/instrumenter'; -import { userEvent, within, expect } from '@storybook/test'; -import { getCalls } from '../mocks'; +import type { Meta, StoryObj } from '@storybook/react'; +import { expect, userEvent, within } from '@storybook/test'; +import { getCalls } from '../mocks'; import { Interaction } from './Interaction'; import SubnavStories from './Subnav.stories'; diff --git a/code/addons/interactions/src/components/Interaction.tsx b/code/addons/interactions/src/components/Interaction.tsx index 6b4682f61be..3e613391e85 100644 --- a/code/addons/interactions/src/components/Interaction.tsx +++ b/code/addons/interactions/src/components/Interaction.tsx @@ -1,17 +1,19 @@ import * as React from 'react'; + import { IconButton, TooltipNote, WithTooltip } from 'storybook/internal/components'; -import { type Call, CallStates, type ControlStates } from '@storybook/instrumenter'; import { styled, typography } from 'storybook/internal/theming'; -import { transparentize } from 'polished'; import { ListUnorderedIcon } from '@storybook/icons'; +import { type Call, CallStates, type ControlStates } from '@storybook/instrumenter'; + +import { transparentize } from 'polished'; + +import { isChaiError, isJestError } from '../utils'; +import type { Controls } from './InteractionsPanel'; import { MatcherResult } from './MatcherResult'; import { MethodCall } from './MethodCall'; import { StatusIcon } from './StatusIcon'; -import type { Controls } from './InteractionsPanel'; -import { isChaiError, isJestError } from '../utils'; - const MethodCallWrapper = styled.div(() => ({ fontFamily: typography.fonts.mono, fontSize: typography.size.s1, diff --git a/code/addons/interactions/src/components/InteractionsPanel.stories.tsx b/code/addons/interactions/src/components/InteractionsPanel.stories.tsx index 9105ea7f2a3..c2fb2b9af2a 100644 --- a/code/addons/interactions/src/components/InteractionsPanel.stories.tsx +++ b/code/addons/interactions/src/components/InteractionsPanel.stories.tsx @@ -1,10 +1,12 @@ import React from 'react'; -import type { StoryObj, Meta } from '@storybook/react'; -import { CallStates } from '@storybook/instrumenter'; + import { styled } from 'storybook/internal/theming'; -import { userEvent, within, waitFor, expect } from '@storybook/test'; -import { isChromatic } from '../../../../.storybook/isChromatic'; +import { CallStates } from '@storybook/instrumenter'; +import type { Meta, StoryObj } from '@storybook/react'; +import { expect, userEvent, waitFor, within } from '@storybook/test'; + +import { isChromatic } from '../../../../.storybook/isChromatic'; import { getCalls, getInteractions } from '../mocks'; import { InteractionsPanel } from './InteractionsPanel'; import SubnavStories from './Subnav.stories'; diff --git a/code/addons/interactions/src/components/InteractionsPanel.tsx b/code/addons/interactions/src/components/InteractionsPanel.tsx index 56165d5e376..c86a1df8ffd 100644 --- a/code/addons/interactions/src/components/InteractionsPanel.tsx +++ b/code/addons/interactions/src/components/InteractionsPanel.tsx @@ -1,13 +1,15 @@ import * as React from 'react'; -import { type Call, CallStates, type ControlStates } from '@storybook/instrumenter'; + import { styled } from 'storybook/internal/theming'; -import { transparentize } from 'polished'; -import { Subnav } from './Subnav'; +import { type Call, CallStates, type ControlStates } from '@storybook/instrumenter'; + +import { transparentize } from 'polished'; -import { Interaction } from './Interaction'; import { isTestAssertionError } from '../utils'; import { Empty } from './EmptyState'; +import { Interaction } from './Interaction'; +import { Subnav } from './Subnav'; export interface Controls { start: (args: any) => void; diff --git a/code/addons/interactions/src/components/List.tsx b/code/addons/interactions/src/components/List.tsx index e3a435ffa53..dece58b465e 100644 --- a/code/addons/interactions/src/components/List.tsx +++ b/code/addons/interactions/src/components/List.tsx @@ -1,5 +1,7 @@ import React, { Fragment, useState } from 'react'; -import { styled, themes, convert } from 'storybook/internal/theming'; + +import { convert, styled, themes } from 'storybook/internal/theming'; + import { ChevronSmallDownIcon } from '@storybook/icons'; const ListWrapper = styled.ul({ diff --git a/code/addons/interactions/src/components/MatcherResult.stories.tsx b/code/addons/interactions/src/components/MatcherResult.stories.tsx index 9e812673f6b..516aaed5cd6 100644 --- a/code/addons/interactions/src/components/MatcherResult.stories.tsx +++ b/code/addons/interactions/src/components/MatcherResult.stories.tsx @@ -1,6 +1,9 @@ import React from 'react'; -import { dedent } from 'ts-dedent'; + import { styled } from 'storybook/internal/theming'; + +import { dedent } from 'ts-dedent'; + import { MatcherResult } from './MatcherResult'; const StyledWrapper = styled.div(({ theme }) => ({ diff --git a/code/addons/interactions/src/components/MatcherResult.tsx b/code/addons/interactions/src/components/MatcherResult.tsx index f1bc83d56ec..a56f96abf62 100644 --- a/code/addons/interactions/src/components/MatcherResult.tsx +++ b/code/addons/interactions/src/components/MatcherResult.tsx @@ -1,5 +1,7 @@ import React from 'react'; + import { styled, typography } from 'storybook/internal/theming'; + import { Node } from './MethodCall'; const getParams = (line: string, fromIndex = 0): string => { diff --git a/code/addons/interactions/src/components/MethodCall.stories.tsx b/code/addons/interactions/src/components/MethodCall.stories.tsx index 3c9354d44c8..1ab027dd5de 100644 --- a/code/addons/interactions/src/components/MethodCall.stories.tsx +++ b/code/addons/interactions/src/components/MethodCall.stories.tsx @@ -1,7 +1,10 @@ -import type { Call } from '@storybook/instrumenter'; import React from 'react'; + import { styled, typography } from 'storybook/internal/theming'; -import { Node, MethodCall } from './MethodCall'; + +import type { Call } from '@storybook/instrumenter'; + +import { MethodCall, Node } from './MethodCall'; const StyledWrapper = styled.div(({ theme }) => ({ backgroundColor: theme.background.content, diff --git a/code/addons/interactions/src/components/MethodCall.tsx b/code/addons/interactions/src/components/MethodCall.tsx index 4b6896eb4bf..8e19ea9e654 100644 --- a/code/addons/interactions/src/components/MethodCall.tsx +++ b/code/addons/interactions/src/components/MethodCall.tsx @@ -1,9 +1,12 @@ -import { ObjectInspector } from '@devtools-ds/object-inspector'; -import type { Call, CallRef, ElementRef } from '@storybook/instrumenter'; -import { useTheme } from 'storybook/internal/theming'; import type { ReactElement } from 'react'; import React, { Fragment } from 'react'; +import { useTheme } from 'storybook/internal/theming'; + +import type { Call, CallRef, ElementRef } from '@storybook/instrumenter'; + +import { ObjectInspector } from '@devtools-ds/object-inspector'; + const colorsLight = { base: '#444', nullish: '#7D99AA', diff --git a/code/addons/interactions/src/components/StatusBadge.stories.tsx b/code/addons/interactions/src/components/StatusBadge.stories.tsx index 8fa3f91ae3a..afac03be0a1 100644 --- a/code/addons/interactions/src/components/StatusBadge.stories.tsx +++ b/code/addons/interactions/src/components/StatusBadge.stories.tsx @@ -1,4 +1,5 @@ import { CallStates } from '@storybook/instrumenter'; + import { StatusBadge } from './StatusBadge'; export default { diff --git a/code/addons/interactions/src/components/StatusBadge.tsx b/code/addons/interactions/src/components/StatusBadge.tsx index 3a989492f1b..d730b8ef985 100644 --- a/code/addons/interactions/src/components/StatusBadge.tsx +++ b/code/addons/interactions/src/components/StatusBadge.tsx @@ -1,7 +1,9 @@ import React from 'react'; -import { type Call, CallStates } from '@storybook/instrumenter'; + import { styled, typography } from 'storybook/internal/theming'; +import { type Call, CallStates } from '@storybook/instrumenter'; + export interface StatusBadgeProps { status: Call['status']; } diff --git a/code/addons/interactions/src/components/StatusIcon.stories.tsx b/code/addons/interactions/src/components/StatusIcon.stories.tsx index 4e8ea421748..7d465dc6400 100644 --- a/code/addons/interactions/src/components/StatusIcon.stories.tsx +++ b/code/addons/interactions/src/components/StatusIcon.stories.tsx @@ -1,4 +1,5 @@ import { CallStates } from '@storybook/instrumenter'; + import { StatusIcon } from './StatusIcon'; export default { diff --git a/code/addons/interactions/src/components/StatusIcon.tsx b/code/addons/interactions/src/components/StatusIcon.tsx index c09a9e3c9c8..1e9ec4c9aa9 100644 --- a/code/addons/interactions/src/components/StatusIcon.tsx +++ b/code/addons/interactions/src/components/StatusIcon.tsx @@ -1,9 +1,11 @@ import React from 'react'; -import { type Call, CallStates } from '@storybook/instrumenter'; + import { styled, useTheme } from 'storybook/internal/theming'; -import { transparentize } from 'polished'; import { CheckIcon, CircleIcon, PlayIcon, StopAltIcon } from '@storybook/icons'; +import { type Call, CallStates } from '@storybook/instrumenter'; + +import { transparentize } from 'polished'; export interface StatusIconProps { status: Call['status']; diff --git a/code/addons/interactions/src/components/Subnav.stories.tsx b/code/addons/interactions/src/components/Subnav.stories.tsx index bdaa5fae283..e19f86fc984 100644 --- a/code/addons/interactions/src/components/Subnav.stories.tsx +++ b/code/addons/interactions/src/components/Subnav.stories.tsx @@ -1,7 +1,9 @@ -import { action } from '@storybook/addon-actions'; import { CallStates } from '@storybook/instrumenter'; -import { Subnav } from './Subnav'; + +import { action } from '@storybook/addon-actions'; + import { parameters } from '../preview'; +import { Subnav } from './Subnav'; export default { title: 'Subnav', diff --git a/code/addons/interactions/src/components/Subnav.tsx b/code/addons/interactions/src/components/Subnav.tsx index 8818248e2b5..59564dab2b6 100644 --- a/code/addons/interactions/src/components/Subnav.tsx +++ b/code/addons/interactions/src/components/Subnav.tsx @@ -1,16 +1,15 @@ import type { ComponentProps } from 'react'; import React from 'react'; + import { + Bar, Button, IconButton, - Separator, P, + Separator, TooltipNote, WithTooltip, - Bar, } from 'storybook/internal/components'; -import type { Call, ControlStates } from '@storybook/instrumenter'; -import { CallStates } from '@storybook/instrumenter'; import { styled } from 'storybook/internal/theming'; import { @@ -20,9 +19,11 @@ import { RewindIcon, SyncIcon, } from '@storybook/icons'; -import { StatusBadge } from './StatusBadge'; +import type { Call, ControlStates } from '@storybook/instrumenter'; +import { CallStates } from '@storybook/instrumenter'; import type { Controls } from './InteractionsPanel'; +import { StatusBadge } from './StatusBadge'; const SubnavWrapper = styled.div(({ theme }) => ({ background: theme.background.app, diff --git a/code/addons/interactions/src/manager.tsx b/code/addons/interactions/src/manager.tsx index 2de5d48d8fa..e2d9c50f875 100644 --- a/code/addons/interactions/src/manager.tsx +++ b/code/addons/interactions/src/manager.tsx @@ -1,9 +1,11 @@ import React, { useCallback } from 'react'; -import type { Combo } from 'storybook/internal/manager-api'; -import { addons, Consumer, types, useAddonState } from 'storybook/internal/manager-api'; + import { AddonPanel, Badge, Spaced } from 'storybook/internal/components'; -import { ADDON_ID, PANEL_ID } from './constants'; +import type { Combo } from 'storybook/internal/manager-api'; +import { Consumer, addons, types, useAddonState } from 'storybook/internal/manager-api'; + import { Panel } from './Panel'; +import { ADDON_ID, PANEL_ID } from './constants'; function Title() { const [addonState = {}] = useAddonState(ADDON_ID); diff --git a/code/addons/interactions/src/mocks/index.ts b/code/addons/interactions/src/mocks/index.ts index cffabc3352b..02760bce429 100644 --- a/code/addons/interactions/src/mocks/index.ts +++ b/code/addons/interactions/src/mocks/index.ts @@ -1,4 +1,4 @@ -import { CallStates, type Call } from '@storybook/instrumenter'; +import { type Call, CallStates } from '@storybook/instrumenter'; export const getCalls = (finalStatus: CallStates) => { const calls: Call[] = [ diff --git a/code/addons/interactions/src/preset.ts b/code/addons/interactions/src/preset.ts index fa827d0e86d..2c60d293c66 100644 --- a/code/addons/interactions/src/preset.ts +++ b/code/addons/interactions/src/preset.ts @@ -1,4 +1,5 @@ import { checkAddonOrder, serverRequire } from 'storybook/internal/common'; + import path from 'path'; export const checkActionsLoaded = (configDir: string) => { diff --git a/code/addons/interactions/src/preview.ts b/code/addons/interactions/src/preview.ts index c74a3aa742d..6abc30f63b9 100644 --- a/code/addons/interactions/src/preview.ts +++ b/code/addons/interactions/src/preview.ts @@ -1,4 +1,5 @@ import type { PlayFunction, StepLabel, StoryContext } from 'storybook/internal/types'; + import { instrument } from '@storybook/instrumenter'; export const { step: runStep } = instrument( diff --git a/code/addons/interactions/template/stories/basics.stories.ts b/code/addons/interactions/template/stories/basics.stories.ts index 45947181771..e208654602e 100644 --- a/code/addons/interactions/template/stories/basics.stories.ts +++ b/code/addons/interactions/template/stories/basics.stories.ts @@ -1,8 +1,8 @@ import { global as globalThis } from '@storybook/global'; import { expect, - fn, fireEvent, + fn, userEvent, waitFor, waitForElementToBeRemoved, diff --git a/code/addons/interactions/vitest.config.ts b/code/addons/interactions/vitest.config.ts index 03172200442..7420176b2e4 100644 --- a/code/addons/interactions/vitest.config.ts +++ b/code/addons/interactions/vitest.config.ts @@ -1,4 +1,5 @@ import { defineConfig, mergeConfig } from 'vitest/config'; + import { vitestCommonConfig } from '../../vitest.workspace'; export default mergeConfig( diff --git a/code/addons/jest/README.md b/code/addons/jest/README.md index ec2cc8a34c6..73b37e6dc21 100644 --- a/code/addons/jest/README.md +++ b/code/addons/jest/README.md @@ -88,12 +88,9 @@ In your story file, add a [decorator](https://storybook.js.org/docs/react/writin ```js // MyComponent.stories.js|jsx - -import MyComponent from './MyComponent'; - -import results from '../.jest-test-results.json'; - import { withTests } from '@storybook/addon-jest'; +import results from '../.jest-test-results.json'; +import MyComponent from './MyComponent'; export default { component: MyComponent, @@ -137,9 +134,7 @@ your [`.storybook/preview.js`](https://storybook.js.org/docs/react/configure/#co ```js // .storybook/preview.js - import { withTests } from '@storybook/addon-jest'; - import results from '../.jest-test-results.json'; export const decorators = [ @@ -181,7 +176,6 @@ You can disable the addon for a single story by setting the `jest` parameter to ```js // MyComponent.stories.js|jsx - import MyComponent from './MyComponent'; export default { @@ -209,9 +203,7 @@ Then, in your `.storybook/preview.js`, you'll need to add a decorator with the f ```js // .storybook/preview.js - import { withTests } from '@storybook/addon-jest'; - import results from '../.jest-test-results.json'; export const decorators = [ @@ -226,9 +218,7 @@ Finally, in your story, you'll need to include the following: ```ts // MyComponent.stories.ts - import type { Meta, StoryFn } from '@storybook/angular'; - import MyComponent from './MyComponent.component'; export default { diff --git a/code/addons/jest/src/components/Message.tsx b/code/addons/jest/src/components/Message.tsx index 13c38a1d507..2fdfcd41e46 100644 --- a/code/addons/jest/src/components/Message.tsx +++ b/code/addons/jest/src/components/Message.tsx @@ -1,5 +1,6 @@ import type { FC, ReactElement } from 'react'; import React, { Fragment } from 'react'; + import { styled } from 'storybook/internal/theming'; const positiveConsoleRegex = /\[32m(.*?)\[39m/; diff --git a/code/addons/jest/src/components/Panel.tsx b/code/addons/jest/src/components/Panel.tsx index 5b2024ca425..27be5cbf7a5 100644 --- a/code/addons/jest/src/components/Panel.tsx +++ b/code/addons/jest/src/components/Panel.tsx @@ -1,11 +1,14 @@ import type { FC } from 'react'; import React, { Fragment } from 'react'; -import { styled, themes, convert } from 'storybook/internal/theming'; -import { ScrollArea, TabsState, Link, Placeholder } from 'storybook/internal/components'; + +import { Link, Placeholder, ScrollArea, TabsState } from 'storybook/internal/components'; +import { convert, styled, themes } from 'storybook/internal/theming'; + import { useResizeDetector } from 'react-resize-detector'; -import { Result } from './Result'; + import type { Test } from '../hoc/provideJestResult'; import { provideTests as provideJestResult } from '../hoc/provideJestResult'; +import { Result } from './Result'; const StatusTypes = { PASSED_TYPE: 'passed', diff --git a/code/addons/jest/src/components/Result.tsx b/code/addons/jest/src/components/Result.tsx index 832bc3b988f..332178a32be 100644 --- a/code/addons/jest/src/components/Result.tsx +++ b/code/addons/jest/src/components/Result.tsx @@ -1,8 +1,11 @@ import React, { Fragment, useState } from 'react'; -import { styled, themes, convert } from 'storybook/internal/theming'; + +import { convert, styled, themes } from 'storybook/internal/theming'; + +import { ChevronSmallDownIcon } from '@storybook/icons'; + // eslint-disable-next-line import/no-named-as-default import Message from './Message'; -import { ChevronSmallDownIcon } from '@storybook/icons'; const Wrapper = styled.div<{ status: string }>(({ theme, status }) => ({ display: 'flex', diff --git a/code/addons/jest/src/hoc/provideJestResult.tsx b/code/addons/jest/src/hoc/provideJestResult.tsx index c1af585d270..f2c891c647b 100644 --- a/code/addons/jest/src/hoc/provideJestResult.tsx +++ b/code/addons/jest/src/hoc/provideJestResult.tsx @@ -1,7 +1,9 @@ import type { ComponentType } from 'react'; import React, { Component as ReactComponent } from 'react'; + import { STORY_CHANGED } from 'storybook/internal/core-events'; import type { API } from 'storybook/internal/manager-api'; + import { ADD_TESTS } from '../shared'; // TODO: import type from @types/jest diff --git a/code/addons/jest/src/index.ts b/code/addons/jest/src/index.ts index ca96f5bf914..0ec5000c1b4 100644 --- a/code/addons/jest/src/index.ts +++ b/code/addons/jest/src/index.ts @@ -1,5 +1,7 @@ import { addons } from 'storybook/internal/preview-api'; + import { normalize, sep } from 'upath'; + import { ADD_TESTS, defineJestParameter } from './shared'; const findTestResults = ( diff --git a/code/addons/jest/src/manager.tsx b/code/addons/jest/src/manager.tsx index 60b3c9fb0f0..ca1b84bb60e 100644 --- a/code/addons/jest/src/manager.tsx +++ b/code/addons/jest/src/manager.tsx @@ -1,8 +1,9 @@ import * as React from 'react'; + import { addons, types } from 'storybook/internal/manager-api'; -import { ADDON_ID, PANEL_ID, PARAM_KEY } from './shared'; import Panel from './components/Panel'; +import { ADDON_ID, PANEL_ID, PARAM_KEY } from './shared'; addons.register(ADDON_ID, (api) => { addons.add(PANEL_ID, { diff --git a/code/addons/jest/src/shared.test.ts b/code/addons/jest/src/shared.test.ts index 599276a1235..6ef232fe5a3 100644 --- a/code/addons/jest/src/shared.test.ts +++ b/code/addons/jest/src/shared.test.ts @@ -1,4 +1,5 @@ import { describe, expect, it } from 'vitest'; + import { defineJestParameter } from './shared'; describe('defineJestParameter', () => { diff --git a/code/addons/jest/src/shared.ts b/code/addons/jest/src/shared.ts index 69c7930102b..32107bdf23e 100644 --- a/code/addons/jest/src/shared.ts +++ b/code/addons/jest/src/shared.ts @@ -1,6 +1,7 @@ -import invariant from 'tiny-invariant'; import type { StorybookInternalParameters } from 'storybook/internal/types'; +import invariant from 'tiny-invariant'; + // addons, panels and events get unique names using a prefix export const PARAM_KEY = 'test'; export const ADDON_ID = 'storybookjs/test'; diff --git a/code/addons/jest/vitest.config.ts b/code/addons/jest/vitest.config.ts index 03172200442..7420176b2e4 100644 --- a/code/addons/jest/vitest.config.ts +++ b/code/addons/jest/vitest.config.ts @@ -1,4 +1,5 @@ import { defineConfig, mergeConfig } from 'vitest/config'; + import { vitestCommonConfig } from '../../vitest.workspace'; export default mergeConfig( diff --git a/code/addons/links/README.md b/code/addons/links/README.md index 8b8d94afff2..cc50832328f 100644 --- a/code/addons/links/README.md +++ b/code/addons/links/README.md @@ -80,8 +80,8 @@ export const third = () => Go back; If you want to get an URL for a particular story, you may use `hrefTo` function. It returns a promise, which resolves to string containing a relative URL: ```js -import { hrefTo } from '@storybook/addon-links'; import { action } from '@storybook/addon-actions'; +import { hrefTo } from '@storybook/addon-links'; export default { title: 'Href', diff --git a/code/addons/links/src/preview.ts b/code/addons/links/src/preview.ts index c0da77c598b..6270d133ab7 100644 --- a/code/addons/links/src/preview.ts +++ b/code/addons/links/src/preview.ts @@ -1,4 +1,5 @@ import type { Addon_DecoratorFunction } from 'storybook/internal/types'; + import { withLinks } from './index'; export const decorators: Addon_DecoratorFunction[] = [withLinks]; diff --git a/code/addons/links/src/react/components/link.test.tsx b/code/addons/links/src/react/components/link.test.tsx index 78b8bb3876a..e0b87be09dc 100644 --- a/code/addons/links/src/react/components/link.test.tsx +++ b/code/addons/links/src/react/components/link.test.tsx @@ -1,12 +1,14 @@ // @vitest-environment happy-dom - /// ; -import { describe, it, expect, afterEach, vi } from 'vitest'; -import React from 'react'; -import { addons } from 'storybook/internal/preview-api'; -import { render, screen, waitFor, cleanup, act } from '@testing-library/react'; +import { act, cleanup, render, screen, waitFor } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; +import { afterEach, describe, expect, it, vi } from 'vitest'; + +import React from 'react'; + import { SELECT_STORY } from 'storybook/internal/core-events'; +import { addons } from 'storybook/internal/preview-api'; + import LinkTo from './link'; vi.mock('storybook/internal/preview-api'); diff --git a/code/addons/links/src/react/components/link.tsx b/code/addons/links/src/react/components/link.tsx index 12437029ba6..0f1f5d34718 100644 --- a/code/addons/links/src/react/components/link.tsx +++ b/code/addons/links/src/react/components/link.tsx @@ -1,8 +1,9 @@ -import type { ComponentTitle, StoryKind, StoryName } from 'storybook/internal/types'; import type { MouseEvent, ReactNode } from 'react'; import React, { PureComponent } from 'react'; -import { navigate, hrefTo } from '../../utils'; +import type { ComponentTitle, StoryKind, StoryName } from 'storybook/internal/types'; + +import { hrefTo, navigate } from '../../utils'; // FIXME: copied from Typography.Link. Code is duplicated to // avoid emotion dependency which breaks React 15.x back-compat diff --git a/code/addons/links/src/utils.test.ts b/code/addons/links/src/utils.test.ts index 3ca7c0c4631..44a6601d36e 100644 --- a/code/addons/links/src/utils.test.ts +++ b/code/addons/links/src/utils.test.ts @@ -1,10 +1,10 @@ // @vitest-environment happy-dom +import { beforeAll, beforeEach, describe, expect, it, vi } from 'vitest'; -import { describe, beforeAll, beforeEach, it, expect, vi } from 'vitest'; -import { addons } from 'storybook/internal/preview-api'; import { SELECT_STORY } from 'storybook/internal/core-events'; +import { addons } from 'storybook/internal/preview-api'; -import { linkTo, hrefTo } from './utils'; +import { hrefTo, linkTo } from './utils'; vi.mock('storybook/internal/preview-api'); vi.mock('@storybook/global', () => ({ diff --git a/code/addons/links/src/utils.ts b/code/addons/links/src/utils.ts index 93eb4dc19b9..86aa75c4fc4 100644 --- a/code/addons/links/src/utils.ts +++ b/code/addons/links/src/utils.ts @@ -1,8 +1,10 @@ -import { global } from '@storybook/global'; +import { SELECT_STORY, STORY_CHANGED } from 'storybook/internal/core-events'; import { addons, makeDecorator } from 'storybook/internal/preview-api'; -import { STORY_CHANGED, SELECT_STORY } from 'storybook/internal/core-events'; -import type { StoryId, StoryName, ComponentTitle, StoryKind } from 'storybook/internal/types'; +import type { ComponentTitle, StoryId, StoryKind, StoryName } from 'storybook/internal/types'; + import { toId } from '@storybook/csf'; +import { global } from '@storybook/global'; + import { PARAM_KEY } from './constants'; const { document, HTMLElement } = global; diff --git a/code/addons/links/template/stories/decorator.stories.ts b/code/addons/links/template/stories/decorator.stories.ts index 53a05f380e7..afe2cd34a6a 100644 --- a/code/addons/links/template/stories/decorator.stories.ts +++ b/code/addons/links/template/stories/decorator.stories.ts @@ -1,4 +1,5 @@ import { global as globalThis } from '@storybook/global'; + import { withLinks } from '@storybook/addon-links'; export default { diff --git a/code/addons/links/template/stories/linkto.stories.ts b/code/addons/links/template/stories/linkto.stories.ts index 502509a8d5a..07df223f009 100644 --- a/code/addons/links/template/stories/linkto.stories.ts +++ b/code/addons/links/template/stories/linkto.stories.ts @@ -1,4 +1,5 @@ import { global as globalThis } from '@storybook/global'; + import { linkTo } from '@storybook/addon-links'; export default { diff --git a/code/addons/links/vitest.config.ts b/code/addons/links/vitest.config.ts index 03172200442..7420176b2e4 100644 --- a/code/addons/links/vitest.config.ts +++ b/code/addons/links/vitest.config.ts @@ -1,4 +1,5 @@ import { defineConfig, mergeConfig } from 'vitest/config'; + import { vitestCommonConfig } from '../../vitest.workspace'; export default mergeConfig( diff --git a/code/addons/measure/src/Tool.tsx b/code/addons/measure/src/Tool.tsx index 8662a32beec..b6e9cbf21ca 100644 --- a/code/addons/measure/src/Tool.tsx +++ b/code/addons/measure/src/Tool.tsx @@ -1,8 +1,11 @@ import React, { useCallback, useEffect } from 'react'; -import { useGlobals, useStorybookApi } from 'storybook/internal/manager-api'; + import { IconButton } from 'storybook/internal/components'; +import { useGlobals, useStorybookApi } from 'storybook/internal/manager-api'; + import { RulerIcon } from '@storybook/icons'; -import { TOOL_ID, ADDON_ID } from './constants'; + +import { ADDON_ID, TOOL_ID } from './constants'; export const Tool = () => { const [globals, updateGlobals] = useGlobals(); diff --git a/code/addons/measure/src/box-model/canvas.ts b/code/addons/measure/src/box-model/canvas.ts index 09c769c6d24..80d0f1d3b10 100644 --- a/code/addons/measure/src/box-model/canvas.ts +++ b/code/addons/measure/src/box-model/canvas.ts @@ -1,4 +1,5 @@ import { global } from '@storybook/global'; + import invariant from 'tiny-invariant'; interface Size { diff --git a/code/addons/measure/src/box-model/visualizer.ts b/code/addons/measure/src/box-model/visualizer.ts index 5d07189cedb..00b1425f7f1 100644 --- a/code/addons/measure/src/box-model/visualizer.ts +++ b/code/addons/measure/src/box-model/visualizer.ts @@ -2,6 +2,7 @@ * Based on https://gist.github.com/awestbro/e668c12662ad354f02a413205b65fce7 */ import { global } from '@storybook/global'; + import { draw } from './canvas'; import type { Label, LabelStack } from './labels'; import { labelStacks } from './labels'; diff --git a/code/addons/measure/src/manager.tsx b/code/addons/measure/src/manager.tsx index 0b6aa66a74c..df36d821171 100644 --- a/code/addons/measure/src/manager.tsx +++ b/code/addons/measure/src/manager.tsx @@ -1,8 +1,9 @@ import React from 'react'; + import { addons, types } from 'storybook/internal/manager-api'; -import { ADDON_ID, TOOL_ID } from './constants'; import { Tool } from './Tool'; +import { ADDON_ID, TOOL_ID } from './constants'; addons.register(ADDON_ID, () => { addons.add(TOOL_ID, { diff --git a/code/addons/measure/src/preview.tsx b/code/addons/measure/src/preview.tsx index 596823c3b90..8898eb58dd6 100644 --- a/code/addons/measure/src/preview.tsx +++ b/code/addons/measure/src/preview.tsx @@ -1,6 +1,7 @@ import type { Addon_DecoratorFunction } from 'storybook/internal/types'; -import { withMeasure } from './withMeasure'; + import { PARAM_KEY } from './constants'; +import { withMeasure } from './withMeasure'; export const decorators: Addon_DecoratorFunction[] = [withMeasure]; diff --git a/code/addons/measure/src/withMeasure.ts b/code/addons/measure/src/withMeasure.ts index c9c9a8c57a2..8524a7f71fc 100644 --- a/code/addons/measure/src/withMeasure.ts +++ b/code/addons/measure/src/withMeasure.ts @@ -2,11 +2,12 @@ import { useEffect } from 'storybook/internal/preview-api'; import type { Renderer, - PartialStoryFn as StoryFunction, StoryContext, + PartialStoryFn as StoryFunction, } from 'storybook/internal/types'; + +import { destroy, init, rescale } from './box-model/canvas'; import { drawSelectedElement } from './box-model/visualizer'; -import { init, rescale, destroy } from './box-model/canvas'; import { deepElementFromPoint } from './util'; let nodeAtPointerRef; diff --git a/code/addons/measure/vitest.config.ts b/code/addons/measure/vitest.config.ts index 03172200442..7420176b2e4 100644 --- a/code/addons/measure/vitest.config.ts +++ b/code/addons/measure/vitest.config.ts @@ -1,4 +1,5 @@ import { defineConfig, mergeConfig } from 'vitest/config'; + import { vitestCommonConfig } from '../../vitest.workspace'; export default mergeConfig( diff --git a/code/addons/onboarding/src/Onboarding.tsx b/code/addons/onboarding/src/Onboarding.tsx index fde1526aa48..2fe360db7e9 100644 --- a/code/addons/onboarding/src/Onboarding.tsx +++ b/code/addons/onboarding/src/Onboarding.tsx @@ -1,16 +1,17 @@ +import React, { useCallback, useEffect, useState } from 'react'; + import { SyntaxHighlighter } from 'storybook/internal/components'; import { SAVE_STORY_RESPONSE } from 'storybook/internal/core-events'; import { type API } from 'storybook/internal/manager-api'; import { ThemeProvider, convert, styled, themes } from 'storybook/internal/theming'; -import React, { useCallback, useEffect, useState } from 'react'; + import type { Step } from 'react-joyride'; -import { GuidedTour } from './features/GuidedTour/GuidedTour'; import { Confetti } from './components/Confetti/Confetti'; +import { HighlightElement } from './components/HighlightElement/HighlightElement'; import type { STORYBOOK_ADDON_ONBOARDING_STEPS } from './constants'; import { STORYBOOK_ADDON_ONBOARDING_CHANNEL } from './constants'; - -import { HighlightElement } from './components/HighlightElement/HighlightElement'; +import { GuidedTour } from './features/GuidedTour/GuidedTour'; import { SplashScreen } from './features/SplashScreen/SplashScreen'; const SpanHighlight = styled.span(({ theme }) => ({ diff --git a/code/addons/onboarding/src/components/Button/Button.stories.tsx b/code/addons/onboarding/src/components/Button/Button.stories.tsx index cf8a824713f..1d4396a29c6 100644 --- a/code/addons/onboarding/src/components/Button/Button.stories.tsx +++ b/code/addons/onboarding/src/components/Button/Button.stories.tsx @@ -1,4 +1,5 @@ import type { Meta, StoryObj } from '@storybook/react'; + import { Button } from './Button'; const meta: Meta = { diff --git a/code/addons/onboarding/src/components/Button/Button.tsx b/code/addons/onboarding/src/components/Button/Button.tsx index b4836f8bd93..e8cc30d4cbd 100644 --- a/code/addons/onboarding/src/components/Button/Button.tsx +++ b/code/addons/onboarding/src/components/Button/Button.tsx @@ -1,5 +1,6 @@ import type { ComponentProps } from 'react'; import React, { forwardRef } from 'react'; + import { styled } from 'storybook/internal/theming'; export interface ButtonProps extends ComponentProps<'button'> { diff --git a/code/addons/onboarding/src/components/Confetti/Confetti.stories.tsx b/code/addons/onboarding/src/components/Confetti/Confetti.stories.tsx index 80b01c7e31d..b55fdf783b3 100644 --- a/code/addons/onboarding/src/components/Confetti/Confetti.stories.tsx +++ b/code/addons/onboarding/src/components/Confetti/Confetti.stories.tsx @@ -1,6 +1,8 @@ +import React from 'react'; + import type { Meta, StoryObj } from '@storybook/react'; + import { Confetti } from './Confetti'; -import React from 'react'; const meta: Meta = { component: Confetti, diff --git a/code/addons/onboarding/src/components/Confetti/Confetti.tsx b/code/addons/onboarding/src/components/Confetti/Confetti.tsx index e913712c170..4b48eac08e0 100644 --- a/code/addons/onboarding/src/components/Confetti/Confetti.tsx +++ b/code/addons/onboarding/src/components/Confetti/Confetti.tsx @@ -1,8 +1,10 @@ -import ReactConfetti from 'react-confetti'; import React, { useEffect } from 'react'; +import { useState } from 'react'; + import { styled } from 'storybook/internal/theming'; + +import ReactConfetti from 'react-confetti'; import { createPortal } from 'react-dom'; -import { useState } from 'react'; interface ConfettiProps extends Omit, 'drawShape'> { top?: number; diff --git a/code/addons/onboarding/src/components/HighlightElement/HighlightElement.stories.tsx b/code/addons/onboarding/src/components/HighlightElement/HighlightElement.stories.tsx index 44d894260a2..0a6cb70831b 100644 --- a/code/addons/onboarding/src/components/HighlightElement/HighlightElement.stories.tsx +++ b/code/addons/onboarding/src/components/HighlightElement/HighlightElement.stories.tsx @@ -1,7 +1,9 @@ +import React from 'react'; + import type { Meta, StoryObj } from '@storybook/react'; +import { expect, within } from '@storybook/test'; + import { HighlightElement } from './HighlightElement'; -import React from 'react'; -import { within, expect } from '@storybook/test'; const meta: Meta = { component: HighlightElement, diff --git a/code/addons/onboarding/src/components/List/List.stories.tsx b/code/addons/onboarding/src/components/List/List.stories.tsx index 9ff667586fc..8e7667d8a12 100644 --- a/code/addons/onboarding/src/components/List/List.stories.tsx +++ b/code/addons/onboarding/src/components/List/List.stories.tsx @@ -1,6 +1,7 @@ import React, { useState } from 'react'; + import type { Meta, StoryObj } from '@storybook/react'; -import { userEvent, waitFor, within, expect } from '@storybook/test'; +import { expect, userEvent, waitFor, within } from '@storybook/test'; import { List } from './List'; import { ListItem } from './ListItem/ListItem'; diff --git a/code/addons/onboarding/src/components/List/List.tsx b/code/addons/onboarding/src/components/List/List.tsx index 0b9640f7d90..69467f1101c 100644 --- a/code/addons/onboarding/src/components/List/List.tsx +++ b/code/addons/onboarding/src/components/List/List.tsx @@ -1,4 +1,5 @@ import React from 'react'; + import { ListWrapper } from './List.styled'; interface ListProps { diff --git a/code/addons/onboarding/src/components/List/ListItem/ListItem.tsx b/code/addons/onboarding/src/components/List/ListItem/ListItem.tsx index e8a9945c0bb..2b493b45615 100644 --- a/code/addons/onboarding/src/components/List/ListItem/ListItem.tsx +++ b/code/addons/onboarding/src/components/List/ListItem/ListItem.tsx @@ -1,7 +1,9 @@ import React from 'react'; -import { ListItemContentWrapper, ListItemIndexWrapper, ListItemWrapper } from './ListItem.styled'; + import { CheckIcon } from '@storybook/icons'; +import { ListItemContentWrapper, ListItemIndexWrapper, ListItemWrapper } from './ListItem.styled'; + interface ListItemProps { children: React.ReactNode; index: number; diff --git a/code/addons/onboarding/src/features/GuidedTour/GuidedTour.tsx b/code/addons/onboarding/src/features/GuidedTour/GuidedTour.tsx index 38fd595bdc2..a61e44a420a 100644 --- a/code/addons/onboarding/src/features/GuidedTour/GuidedTour.tsx +++ b/code/addons/onboarding/src/features/GuidedTour/GuidedTour.tsx @@ -1,10 +1,12 @@ import React, { useEffect, useState } from 'react'; + +import { useTheme } from 'storybook/internal/theming'; + import type { CallBackProps } from 'react-joyride'; import Joyride, { ACTIONS } from 'react-joyride'; -import { useTheme } from 'storybook/internal/theming'; -import { Tooltip } from './Tooltip'; import type { StepDefinition, StepKey } from '../../Onboarding'; +import { Tooltip } from './Tooltip'; export function GuidedTour({ step, diff --git a/code/addons/onboarding/src/features/GuidedTour/Tooltip.tsx b/code/addons/onboarding/src/features/GuidedTour/Tooltip.tsx index a2055475765..34ba2593b56 100644 --- a/code/addons/onboarding/src/features/GuidedTour/Tooltip.tsx +++ b/code/addons/onboarding/src/features/GuidedTour/Tooltip.tsx @@ -1,9 +1,12 @@ import type { FC } from 'react'; import React, { useEffect } from 'react'; -import type { Step, TooltipRenderProps } from 'react-joyride'; + import { IconButton } from 'storybook/internal/components'; +import { color, styled } from 'storybook/internal/theming'; + import { CloseAltIcon } from '@storybook/icons'; -import { styled, color } from 'storybook/internal/theming'; + +import type { Step, TooltipRenderProps } from 'react-joyride'; import { Button } from '../../components/Button/Button'; diff --git a/code/addons/onboarding/src/features/SplashScreen/SplashScreen.stories.tsx b/code/addons/onboarding/src/features/SplashScreen/SplashScreen.stories.tsx index fffa7ce4d3a..7e83cd3e655 100644 --- a/code/addons/onboarding/src/features/SplashScreen/SplashScreen.stories.tsx +++ b/code/addons/onboarding/src/features/SplashScreen/SplashScreen.stories.tsx @@ -1,4 +1,5 @@ import type { Meta, StoryObj } from '@storybook/react'; + import { SplashScreen } from './SplashScreen'; const meta = { diff --git a/code/addons/onboarding/src/features/SplashScreen/SplashScreen.tsx b/code/addons/onboarding/src/features/SplashScreen/SplashScreen.tsx index 683bca45528..0e373f63e16 100644 --- a/code/addons/onboarding/src/features/SplashScreen/SplashScreen.tsx +++ b/code/addons/onboarding/src/features/SplashScreen/SplashScreen.tsx @@ -1,7 +1,9 @@ -import { ArrowRightIcon } from '@storybook/icons'; -import { styled, keyframes } from 'storybook/internal/theming'; import React, { useCallback, useEffect, useState } from 'react'; +import { keyframes, styled } from 'storybook/internal/theming'; + +import { ArrowRightIcon } from '@storybook/icons'; + const fadeIn = keyframes({ from: { opacity: 0, diff --git a/code/addons/onboarding/src/manager.tsx b/code/addons/onboarding/src/manager.tsx index 07c543be8bc..40b1436420b 100644 --- a/code/addons/onboarding/src/manager.tsx +++ b/code/addons/onboarding/src/manager.tsx @@ -1,7 +1,9 @@ -import ReactDOM from 'react-dom'; -import React, { lazy, Suspense } from 'react'; -import { addons } from 'storybook/internal/manager-api'; +import React, { Suspense, lazy } from 'react'; + import { STORY_SPECIFIED } from 'storybook/internal/core-events'; +import { addons } from 'storybook/internal/manager-api'; + +import ReactDOM from 'react-dom'; const Onboarding = lazy(() => import('./Onboarding')); diff --git a/code/addons/onboarding/src/preset.ts b/code/addons/onboarding/src/preset.ts index c88501d0a3e..171d26baccb 100644 --- a/code/addons/onboarding/src/preset.ts +++ b/code/addons/onboarding/src/preset.ts @@ -1,9 +1,11 @@ -import type { CoreConfig, Options } from 'storybook/internal/types'; import type { Channel } from 'storybook/internal/channels'; -import { STORYBOOK_ADDON_ONBOARDING_CHANNEL } from './constants'; import { telemetry } from 'storybook/internal/telemetry'; +import type { CoreConfig, Options } from 'storybook/internal/types'; + import fs from 'fs'; +import { STORYBOOK_ADDON_ONBOARDING_CHANNEL } from './constants'; + type Event = { type: 'telemetry'; step: string; diff --git a/code/addons/onboarding/vitest.config.ts b/code/addons/onboarding/vitest.config.ts index 03172200442..7420176b2e4 100644 --- a/code/addons/onboarding/vitest.config.ts +++ b/code/addons/onboarding/vitest.config.ts @@ -1,4 +1,5 @@ import { defineConfig, mergeConfig } from 'vitest/config'; + import { vitestCommonConfig } from '../../vitest.workspace'; export default mergeConfig( diff --git a/code/addons/outline/src/OutlineSelector.tsx b/code/addons/outline/src/OutlineSelector.tsx index 54fb87eda53..a8fb501ca85 100644 --- a/code/addons/outline/src/OutlineSelector.tsx +++ b/code/addons/outline/src/OutlineSelector.tsx @@ -1,7 +1,10 @@ import React, { memo, useCallback, useEffect } from 'react'; -import { useGlobals, useStorybookApi } from 'storybook/internal/manager-api'; + import { IconButton } from 'storybook/internal/components'; +import { useGlobals, useStorybookApi } from 'storybook/internal/manager-api'; + import { OutlineIcon } from '@storybook/icons'; + import { ADDON_ID, PARAM_KEY } from './constants'; export const OutlineSelector = memo(function OutlineSelector() { diff --git a/code/addons/outline/src/manager.tsx b/code/addons/outline/src/manager.tsx index 708ee358a61..61084e2c6ab 100644 --- a/code/addons/outline/src/manager.tsx +++ b/code/addons/outline/src/manager.tsx @@ -1,8 +1,9 @@ import React from 'react'; + import { addons, types } from 'storybook/internal/manager-api'; -import { ADDON_ID } from './constants'; import { OutlineSelector } from './OutlineSelector'; +import { ADDON_ID } from './constants'; addons.register(ADDON_ID, () => { addons.add(ADDON_ID, { diff --git a/code/addons/outline/src/preview.tsx b/code/addons/outline/src/preview.tsx index 394a6fbabe6..19deb3a9afe 100644 --- a/code/addons/outline/src/preview.tsx +++ b/code/addons/outline/src/preview.tsx @@ -1,6 +1,7 @@ import type { Addon_DecoratorFunction } from 'storybook/internal/types'; -import { withOutline } from './withOutline'; + import { PARAM_KEY } from './constants'; +import { withOutline } from './withOutline'; export const decorators: Addon_DecoratorFunction[] = [withOutline]; diff --git a/code/addons/outline/src/withOutline.ts b/code/addons/outline/src/withOutline.ts index 5a9185e7ea0..219b93a3acd 100644 --- a/code/addons/outline/src/withOutline.ts +++ b/code/addons/outline/src/withOutline.ts @@ -1,12 +1,12 @@ -import { useMemo, useEffect } from 'storybook/internal/preview-api'; +import { useEffect, useMemo } from 'storybook/internal/preview-api'; import type { Renderer, - PartialStoryFn as StoryFunction, StoryContext, + PartialStoryFn as StoryFunction, } from 'storybook/internal/types'; -import { clearStyles, addOutlineStyles } from './helpers'; import { PARAM_KEY } from './constants'; +import { addOutlineStyles, clearStyles } from './helpers'; import outlineCSS from './outlineCSS'; export const withOutline = (StoryFn: StoryFunction, context: StoryContext) => { diff --git a/code/addons/outline/vitest.config.ts b/code/addons/outline/vitest.config.ts index 03172200442..7420176b2e4 100644 --- a/code/addons/outline/vitest.config.ts +++ b/code/addons/outline/vitest.config.ts @@ -1,4 +1,5 @@ import { defineConfig, mergeConfig } from 'vitest/config'; + import { vitestCommonConfig } from '../../vitest.workspace'; export default mergeConfig( diff --git a/code/addons/storysource/src/StoryPanel.tsx b/code/addons/storysource/src/StoryPanel.tsx index 3800837778d..aada383782e 100644 --- a/code/addons/storysource/src/StoryPanel.tsx +++ b/code/addons/storysource/src/StoryPanel.tsx @@ -1,18 +1,19 @@ import React from 'react'; -import { type API, useParameter } from 'storybook/internal/manager-api'; -import { styled } from 'storybook/internal/theming'; -import { Link } from 'storybook/internal/router'; + import { SyntaxHighlighter, type SyntaxHighlighterProps, type SyntaxHighlighterRendererProps, } from 'storybook/internal/components'; -import invariant from 'tiny-invariant'; +import { type API, useParameter } from 'storybook/internal/manager-api'; +import { Link } from 'storybook/internal/router'; +import { styled } from 'storybook/internal/theming'; + +import type { LocationsMap, SourceBlock } from '@storybook/source-loader'; // @ts-expect-error Typedefs don't currently expose `createElement` even though it exists import { createElement as createSyntaxHighlighterElement } from 'react-syntax-highlighter'; - -import type { SourceBlock, LocationsMap } from '@storybook/source-loader'; +import invariant from 'tiny-invariant'; const StyledStoryLink = styled(Link)<{ to: string; key: string }>(({ theme }) => ({ display: 'block', diff --git a/code/addons/storysource/src/manager.tsx b/code/addons/storysource/src/manager.tsx index d08e2480fca..7e07f90b595 100644 --- a/code/addons/storysource/src/manager.tsx +++ b/code/addons/storysource/src/manager.tsx @@ -1,4 +1,5 @@ import React from 'react'; + import { addons, types } from 'storybook/internal/manager-api'; import { StoryPanel } from './StoryPanel'; diff --git a/code/addons/storysource/vitest.config.ts b/code/addons/storysource/vitest.config.ts index 03172200442..7420176b2e4 100644 --- a/code/addons/storysource/vitest.config.ts +++ b/code/addons/storysource/vitest.config.ts @@ -1,4 +1,5 @@ import { defineConfig, mergeConfig } from 'vitest/config'; + import { vitestCommonConfig } from '../../vitest.workspace'; export default mergeConfig( diff --git a/code/addons/themes/docs/api.md b/code/addons/themes/docs/api.md index 0c8fc32996d..143178b0004 100644 --- a/code/addons/themes/docs/api.md +++ b/code/addons/themes/docs/api.md @@ -95,6 +95,7 @@ Pulls the selected theme from storybook's global state. ```js import { DecoratorHelpers } from '@storybook/addon-themes'; + const { pluckThemeFromContext } = DecoratorHelpers; export const myCustomDecorator = @@ -112,6 +113,7 @@ Returns the theme parameters for this addon. ```js import { DecoratorHelpers } from '@storybook/addon-themes'; + const { useThemeParameters } = DecoratorHelpers; export const myCustomDecorator = @@ -129,6 +131,7 @@ Used to register the themes and defaultTheme with the addon state. ```js import { DecoratorHelpers } from '@storybook/addon-themes'; + const { initializeThemeState } = DecoratorHelpers; export const myCustomDecorator = ({ themes, defaultState, ...rest }) => { @@ -146,7 +149,6 @@ Let's use Vuetify as an example. Vuetify uses it's own global state to know whic ```js // .storybook/withVeutifyTheme.decorator.js - import { DecoratorHelpers } from '@storybook/addon-themes'; import { useTheme } from 'vuetify'; @@ -182,7 +184,6 @@ This can then be provided to Storybook in `.storybook/preview.js`: ```js // .storybook/preview.js - import { setup } from '@storybook/vue3'; import { registerPlugins } from '../src/plugins'; import { withVuetifyTheme } from './withVuetifyTheme.decorator'; diff --git a/code/addons/themes/src/decorators/data-attribute.decorator.tsx b/code/addons/themes/src/decorators/data-attribute.decorator.tsx index 05ad62792e7..6d4b1cfe26f 100644 --- a/code/addons/themes/src/decorators/data-attribute.decorator.tsx +++ b/code/addons/themes/src/decorators/data-attribute.decorator.tsx @@ -1,5 +1,6 @@ import { useEffect } from 'storybook/internal/preview-api'; import type { DecoratorFunction, Renderer } from 'storybook/internal/types'; + import { initializeThemeState, pluckThemeFromContext, useThemeParameters } from './helpers'; export interface DataAttributeStrategyConfiguration { diff --git a/code/addons/themes/src/decorators/helpers.ts b/code/addons/themes/src/decorators/helpers.ts index d26ce041032..396f0d257f2 100644 --- a/code/addons/themes/src/decorators/helpers.ts +++ b/code/addons/themes/src/decorators/helpers.ts @@ -1,7 +1,8 @@ import { addons, useParameter } from 'storybook/internal/preview-api'; import type { StoryContext } from 'storybook/internal/types'; + import type { ThemeParameters } from '../constants'; -import { GLOBAL_KEY, PARAM_KEY, THEMING_EVENTS, DEFAULT_THEME_PARAMETERS } from '../constants'; +import { DEFAULT_THEME_PARAMETERS, GLOBAL_KEY, PARAM_KEY, THEMING_EVENTS } from '../constants'; /** * diff --git a/code/addons/themes/src/decorators/provider.decorator.tsx b/code/addons/themes/src/decorators/provider.decorator.tsx index f8b47781003..3cc1bce2fdb 100644 --- a/code/addons/themes/src/decorators/provider.decorator.tsx +++ b/code/addons/themes/src/decorators/provider.decorator.tsx @@ -1,4 +1,5 @@ import React from 'react'; + import { useMemo } from 'storybook/internal/preview-api'; import type { DecoratorFunction, Renderer } from 'storybook/internal/types'; diff --git a/code/addons/themes/src/preview.tsx b/code/addons/themes/src/preview.tsx index 6f4a444e7f7..5d33f51b94f 100644 --- a/code/addons/themes/src/preview.tsx +++ b/code/addons/themes/src/preview.tsx @@ -1,4 +1,5 @@ -import type { Renderer, ProjectAnnotations } from 'storybook/internal/types'; +import type { ProjectAnnotations, Renderer } from 'storybook/internal/types'; + import { GLOBAL_KEY as KEY } from './constants'; export const initialGlobals: ProjectAnnotations['initialGlobals'] = { diff --git a/code/addons/themes/src/theme-switcher.tsx b/code/addons/themes/src/theme-switcher.tsx index d57b9ce1e5e..2af5530a0a8 100644 --- a/code/addons/themes/src/theme-switcher.tsx +++ b/code/addons/themes/src/theme-switcher.tsx @@ -1,23 +1,25 @@ import React from 'react'; + +import { IconButton, TooltipLinkList, WithTooltip } from 'storybook/internal/components'; import { + addons, useAddonState, useChannel, useGlobals, useParameter, - addons, } from 'storybook/internal/manager-api'; import { styled } from 'storybook/internal/theming'; -import { IconButton, WithTooltip, TooltipLinkList } from 'storybook/internal/components'; import { PaintBrushIcon } from '@storybook/icons'; + import type { ThemeAddonState, ThemeParameters } from './constants'; import { - PARAM_KEY, - THEME_SWITCHER_ID, - THEMING_EVENTS, DEFAULT_ADDON_STATE, DEFAULT_THEME_PARAMETERS, GLOBAL_KEY as KEY, + PARAM_KEY, + THEME_SWITCHER_ID, + THEMING_EVENTS, } from './constants'; const IconButtonLabel = styled.div(({ theme }) => ({ diff --git a/code/addons/themes/template/stories/decorators.stories.ts b/code/addons/themes/template/stories/decorators.stories.ts index aba8f17d0e7..f4308ba9e02 100644 --- a/code/addons/themes/template/stories/decorators.stories.ts +++ b/code/addons/themes/template/stories/decorators.stories.ts @@ -1,10 +1,12 @@ +import { useEffect } from 'storybook/internal/preview-api'; + import { global as globalThis } from '@storybook/global'; + import { withThemeByClassName, withThemeByDataAttribute, withThemeFromJSXProvider, } from '@storybook/addon-themes'; -import { useEffect } from 'storybook/internal/preview-api'; const cleanup = () => { const existing = globalThis.document.querySelector('style[data-theme-css]'); diff --git a/code/addons/themes/template/stories/globals.stories.ts b/code/addons/themes/template/stories/globals.stories.ts index 3d193d1fa71..e2d5aed08ae 100644 --- a/code/addons/themes/template/stories/globals.stories.ts +++ b/code/addons/themes/template/stories/globals.stories.ts @@ -1,6 +1,8 @@ +import { useEffect } from 'storybook/internal/preview-api'; + import { global as globalThis } from '@storybook/global'; + import { withThemeByClassName } from '@storybook/addon-themes'; -import { useEffect } from 'storybook/internal/preview-api'; const cleanup = () => { const existing = globalThis.document.querySelector('style[data-theme-css]'); diff --git a/code/addons/themes/template/stories/parameters.stories.ts b/code/addons/themes/template/stories/parameters.stories.ts index f2906696859..2c243e085e6 100644 --- a/code/addons/themes/template/stories/parameters.stories.ts +++ b/code/addons/themes/template/stories/parameters.stories.ts @@ -1,6 +1,8 @@ +import { useEffect } from 'storybook/internal/preview-api'; + import { global as globalThis } from '@storybook/global'; + import { withThemeByClassName } from '@storybook/addon-themes'; -import { useEffect } from 'storybook/internal/preview-api'; const cleanup = () => { const existing = globalThis.document.querySelector('style[data-theme-css]'); diff --git a/code/addons/themes/vitest.config.ts b/code/addons/themes/vitest.config.ts index 03172200442..7420176b2e4 100644 --- a/code/addons/themes/vitest.config.ts +++ b/code/addons/themes/vitest.config.ts @@ -1,4 +1,5 @@ import { defineConfig, mergeConfig } from 'vitest/config'; + import { vitestCommonConfig } from '../../vitest.workspace'; export default mergeConfig( diff --git a/code/addons/toolbars/src/components/ToolbarManager.tsx b/code/addons/toolbars/src/components/ToolbarManager.tsx index 1570b72883f..79ce101cb02 100644 --- a/code/addons/toolbars/src/components/ToolbarManager.tsx +++ b/code/addons/toolbars/src/components/ToolbarManager.tsx @@ -1,10 +1,12 @@ import type { FC } from 'react'; import React from 'react'; -import { useGlobalTypes } from 'storybook/internal/manager-api'; + import { Separator } from 'storybook/internal/components'; -import { ToolbarMenuList } from './ToolbarMenuList'; -import { normalizeArgType } from '../utils/normalize-toolbar-arg-type'; +import { useGlobalTypes } from 'storybook/internal/manager-api'; + import type { ToolbarArgType } from '../types'; +import { normalizeArgType } from '../utils/normalize-toolbar-arg-type'; +import { ToolbarMenuList } from './ToolbarMenuList'; /** * A smart component for handling manager-preview interactions. diff --git a/code/addons/toolbars/src/components/ToolbarMenuButton.tsx b/code/addons/toolbars/src/components/ToolbarMenuButton.tsx index bc093fabfad..30e4aa5365a 100644 --- a/code/addons/toolbars/src/components/ToolbarMenuButton.tsx +++ b/code/addons/toolbars/src/components/ToolbarMenuButton.tsx @@ -1,6 +1,7 @@ import type { FC } from 'react'; import React from 'react'; -import { Icons, IconButton, type IconsProps } from 'storybook/internal/components'; + +import { IconButton, Icons, type IconsProps } from 'storybook/internal/components'; interface ToolbarMenuButtonProps { active: boolean; diff --git a/code/addons/toolbars/src/components/ToolbarMenuList.tsx b/code/addons/toolbars/src/components/ToolbarMenuList.tsx index b54f0df44e5..032cccdca4f 100644 --- a/code/addons/toolbars/src/components/ToolbarMenuList.tsx +++ b/code/addons/toolbars/src/components/ToolbarMenuList.tsx @@ -1,12 +1,14 @@ import type { FC } from 'react'; -import React, { useState, useCallback } from 'react'; +import React, { useCallback, useState } from 'react'; + +import { TooltipLinkList, WithTooltip } from 'storybook/internal/components'; import { useGlobals } from 'storybook/internal/manager-api'; -import { WithTooltip, TooltipLinkList } from 'storybook/internal/components'; -import { ToolbarMenuButton } from './ToolbarMenuButton'; + import type { WithKeyboardCycleProps } from '../hoc/withKeyboardCycle'; import { withKeyboardCycle } from '../hoc/withKeyboardCycle'; -import { getSelectedIcon, getSelectedTitle } from '../utils/get-selected'; import type { ToolbarMenuProps } from '../types'; +import { getSelectedIcon, getSelectedTitle } from '../utils/get-selected'; +import { ToolbarMenuButton } from './ToolbarMenuButton'; import { ToolbarMenuListItem } from './ToolbarMenuListItem'; type ToolbarMenuListProps = ToolbarMenuProps & WithKeyboardCycleProps; diff --git a/code/addons/toolbars/src/components/ToolbarMenuListItem.tsx b/code/addons/toolbars/src/components/ToolbarMenuListItem.tsx index 39fa7df5dac..829829de4b2 100644 --- a/code/addons/toolbars/src/components/ToolbarMenuListItem.tsx +++ b/code/addons/toolbars/src/components/ToolbarMenuListItem.tsx @@ -1,6 +1,8 @@ import React from 'react'; + import type { TooltipLinkListLink } from 'storybook/internal/components'; import { Icons } from 'storybook/internal/components'; + import type { ToolbarItem } from '../types'; export type ToolbarMenuListItemProps = { diff --git a/code/addons/toolbars/src/hoc/withKeyboardCycle.tsx b/code/addons/toolbars/src/hoc/withKeyboardCycle.tsx index 9bdcc8e8b6a..15b2e75eb60 100644 --- a/code/addons/toolbars/src/hoc/withKeyboardCycle.tsx +++ b/code/addons/toolbars/src/hoc/withKeyboardCycle.tsx @@ -1,8 +1,10 @@ -import React, { useRef, useEffect, useCallback } from 'react'; +import React, { useCallback, useEffect, useRef } from 'react'; + import { useGlobals, useStorybookApi } from 'storybook/internal/manager-api'; + +import type { ToolbarMenuProps } from '../types'; import { createCycleValueArray } from '../utils/create-cycle-value-array'; import { registerShortcuts } from '../utils/register-shortcuts'; -import type { ToolbarMenuProps } from '../types'; export type WithKeyboardCycleProps = { cycleValues?: string[]; diff --git a/code/addons/toolbars/src/manager.tsx b/code/addons/toolbars/src/manager.tsx index 306e857544b..7b63e9e7b52 100644 --- a/code/addons/toolbars/src/manager.tsx +++ b/code/addons/toolbars/src/manager.tsx @@ -1,5 +1,7 @@ import React from 'react'; + import { addons, types } from 'storybook/internal/manager-api'; + import { ToolbarManager } from './components/ToolbarManager'; import { ADDON_ID } from './constants'; diff --git a/code/addons/toolbars/src/utils/register-shortcuts.ts b/code/addons/toolbars/src/utils/register-shortcuts.ts index 98ef5cc03f5..423543db694 100644 --- a/code/addons/toolbars/src/utils/register-shortcuts.ts +++ b/code/addons/toolbars/src/utils/register-shortcuts.ts @@ -1,4 +1,5 @@ import type { API } from 'storybook/internal/manager-api'; + import { ADDON_ID } from '../constants'; import type { ToolbarShortcutConfig } from '../types'; diff --git a/code/addons/toolbars/template/stories/globals.stories.ts b/code/addons/toolbars/template/stories/globals.stories.ts index dd5b52ddece..8c8ec6a5f0f 100644 --- a/code/addons/toolbars/template/stories/globals.stories.ts +++ b/code/addons/toolbars/template/stories/globals.stories.ts @@ -1,6 +1,7 @@ -import { global as globalThis } from '@storybook/global'; import type { DecoratorFunction } from 'storybook/internal/types'; +import { global as globalThis } from '@storybook/global'; + const greetingForLocale = (locale: string) => { switch (locale) { case 'es': diff --git a/code/addons/toolbars/vitest.config.ts b/code/addons/toolbars/vitest.config.ts index 03172200442..7420176b2e4 100644 --- a/code/addons/toolbars/vitest.config.ts +++ b/code/addons/toolbars/vitest.config.ts @@ -1,4 +1,5 @@ import { defineConfig, mergeConfig } from 'vitest/config'; + import { vitestCommonConfig } from '../../vitest.workspace'; export default mergeConfig( diff --git a/code/addons/viewport/src/components/Tool.tsx b/code/addons/viewport/src/components/Tool.tsx index 8ee3c3bfb96..3564ecad2c0 100644 --- a/code/addons/viewport/src/components/Tool.tsx +++ b/code/addons/viewport/src/components/Tool.tsx @@ -1,22 +1,23 @@ -import React, { useState, Fragment, useEffect, type FC, useCallback } from 'react'; +import React, { type FC, Fragment, useCallback, useEffect, useState } from 'react'; +import { IconButton, TooltipLinkList, WithTooltip } from 'storybook/internal/components'; +import { type API, useGlobals, useParameter } from 'storybook/internal/manager-api'; import { Global } from 'storybook/internal/theming'; -import { IconButton, WithTooltip, TooltipLinkList } from 'storybook/internal/components'; -import { useGlobals, type API, useParameter } from 'storybook/internal/manager-api'; import { GrowIcon, RefreshIcon, TransferIcon } from '@storybook/icons'; + import { PARAM_KEY as KEY } from '../constants'; +import { responsiveViewport } from '../responsiveViewport'; import { registerShortcuts } from '../shortcuts'; +import type { Config, GlobalState, GlobalStateUpdate, Viewport, ViewportMap } from '../types'; import { - IconButtonWithLabel, - IconButtonLabel, - ActiveViewportSize, ActiveViewportLabel, - iconsMap, + ActiveViewportSize, + IconButtonLabel, + IconButtonWithLabel, emptyViewportMap, + iconsMap, } from '../utils'; -import { responsiveViewport } from '../responsiveViewport'; -import type { Config, Viewport, ViewportMap, GlobalState, GlobalStateUpdate } from '../types'; interface PureProps { item: Viewport; diff --git a/code/addons/viewport/src/legacy/ToolLegacy.tsx b/code/addons/viewport/src/legacy/ToolLegacy.tsx index c3eb3f59f7a..7035bd79789 100644 --- a/code/addons/viewport/src/legacy/ToolLegacy.tsx +++ b/code/addons/viewport/src/legacy/ToolLegacy.tsx @@ -1,17 +1,18 @@ -import type { ReactNode, FC } from 'react'; -import React, { useState, Fragment, useEffect, useRef, memo } from 'react'; -import memoize from 'memoizerific'; - -import { styled, Global } from 'storybook/internal/theming'; +import type { FC, ReactNode } from 'react'; +import React, { Fragment, memo, useEffect, useRef, useState } from 'react'; -import { IconButton, WithTooltip, TooltipLinkList } from 'storybook/internal/components'; +import { IconButton, TooltipLinkList, WithTooltip } from 'storybook/internal/components'; +import { useGlobals, useParameter, useStorybookApi } from 'storybook/internal/manager-api'; +import { Global, styled } from 'storybook/internal/theming'; -import { useStorybookApi, useParameter, useGlobals } from 'storybook/internal/manager-api'; import { GrowIcon, TransferIcon } from '@storybook/icons'; -import { registerShortcuts } from '../shortcuts'; + +import memoize from 'memoizerific'; + import { PARAM_KEY } from '../constants'; import { MINIMAL_VIEWPORTS } from '../defaults'; -import type { ViewportMap, ViewportStyles, Styles } from '../types'; +import { registerShortcuts } from '../shortcuts'; +import type { Styles, ViewportMap, ViewportStyles } from '../types'; import type { ViewportAddonParameter } from './ViewportAddonParameter'; interface ViewportItem { diff --git a/code/addons/viewport/src/manager.tsx b/code/addons/viewport/src/manager.tsx index e7425aff76d..df05367498f 100644 --- a/code/addons/viewport/src/manager.tsx +++ b/code/addons/viewport/src/manager.tsx @@ -1,10 +1,10 @@ import * as React from 'react'; + import { addons, types } from 'storybook/internal/manager-api'; +import { ViewportTool } from './components/Tool'; import { ADDON_ID } from './constants'; - import { ViewportToolLegacy } from './legacy/ToolLegacy'; -import { ViewportTool } from './components/Tool'; addons.register(ADDON_ID, (api) => { addons.add(ADDON_ID, { diff --git a/code/addons/viewport/src/shortcuts.ts b/code/addons/viewport/src/shortcuts.ts index f53d460b81b..59ef7787e20 100644 --- a/code/addons/viewport/src/shortcuts.ts +++ b/code/addons/viewport/src/shortcuts.ts @@ -1,4 +1,5 @@ import { type API } from 'storybook/internal/manager-api'; + import { ADDON_ID } from './constants'; import { initialGlobals as defaultGlobals } from './preview'; diff --git a/code/addons/viewport/src/utils.tsx b/code/addons/viewport/src/utils.tsx index be4f3cb1609..e83572e8962 100644 --- a/code/addons/viewport/src/utils.tsx +++ b/code/addons/viewport/src/utils.tsx @@ -1,9 +1,10 @@ import React, { Fragment } from 'react'; -import { styled } from 'storybook/internal/theming'; import { IconButton } from 'storybook/internal/components'; +import { styled } from 'storybook/internal/theming'; import { BrowserIcon, MobileIcon, TabletIcon } from '@storybook/icons'; + import type { Viewport, ViewportMap } from './types'; export const ActiveViewportSize = styled.div(() => ({ diff --git a/code/addons/viewport/template/stories/globals.stories.ts b/code/addons/viewport/template/stories/globals.stories.ts index 621bf0b02c6..ebfcc11f9b6 100644 --- a/code/addons/viewport/template/stories/globals.stories.ts +++ b/code/addons/viewport/template/stories/globals.stories.ts @@ -1,4 +1,5 @@ import { global as globalThis } from '@storybook/global'; + import { MINIMAL_VIEWPORTS } from '@storybook/addon-viewport'; const first = Object.keys(MINIMAL_VIEWPORTS)[0]; diff --git a/code/addons/viewport/template/stories/parameters.stories.ts b/code/addons/viewport/template/stories/parameters.stories.ts index f98de1eda0c..b715564e175 100644 --- a/code/addons/viewport/template/stories/parameters.stories.ts +++ b/code/addons/viewport/template/stories/parameters.stories.ts @@ -1,4 +1,5 @@ import { global as globalThis } from '@storybook/global'; + import { MINIMAL_VIEWPORTS } from '@storybook/addon-viewport'; // these stories only work with `viewportStoryGlobals` set to false diff --git a/code/addons/viewport/vitest.config.ts b/code/addons/viewport/vitest.config.ts index 03172200442..7420176b2e4 100644 --- a/code/addons/viewport/vitest.config.ts +++ b/code/addons/viewport/vitest.config.ts @@ -1,4 +1,5 @@ import { defineConfig, mergeConfig } from 'vitest/config'; + import { vitestCommonConfig } from '../../vitest.workspace'; export default mergeConfig( diff --git a/code/builders/builder-vite/README.md b/code/builders/builder-vite/README.md index 18a2e0ec6df..d6116b3c30f 100644 --- a/code/builders/builder-vite/README.md +++ b/code/builders/builder-vite/README.md @@ -117,7 +117,9 @@ The function should return the updated Vite configuration. Configure your `.storybook/main.ts` to use TypeScript: ```typescript -import type { StorybookConfig } from '@storybook/react-vite'; // (or whatever framework you are using) +import type { StorybookConfig } from '@storybook/react-vite'; + +// (or whatever framework you are using) const config: StorybookConfig = { // other storybook options..., diff --git a/code/builders/builder-vite/src/build.ts b/code/builders/builder-vite/src/build.ts index f55423e0e97..581ce74a756 100644 --- a/code/builders/builder-vite/src/build.ts +++ b/code/builders/builder-vite/src/build.ts @@ -1,13 +1,14 @@ -import type { Options } from 'storybook/internal/types'; import { logger } from 'storybook/internal/node-logger'; +import type { Options } from 'storybook/internal/types'; + import { dedent } from 'ts-dedent'; +import type { InlineConfig } from 'vite'; -import { commonConfig } from './vite-config'; import { sanitizeEnvVars } from './envs'; import type { WebpackStatsPlugin } from './plugins'; -import type { InlineConfig } from 'vite'; import { hasVitePlugins } from './utils/has-vite-plugins'; import { withoutVitePlugins } from './utils/without-vite-plugins'; +import { commonConfig } from './vite-config'; function findPlugin(config: InlineConfig, name: string) { return config.plugins?.find((p) => p && 'name' in p && p.name === name); diff --git a/code/builders/builder-vite/src/codegen-importfn-script.ts b/code/builders/builder-vite/src/codegen-importfn-script.ts index 48ce451b74f..678468b447f 100644 --- a/code/builders/builder-vite/src/codegen-importfn-script.ts +++ b/code/builders/builder-vite/src/codegen-importfn-script.ts @@ -1,7 +1,7 @@ -import * as path from 'path'; - import type { Options } from 'storybook/internal/types'; +import * as path from 'path'; + import { listStories } from './list-stories'; /** diff --git a/code/builders/builder-vite/src/codegen-modern-iframe-script.ts b/code/builders/builder-vite/src/codegen-modern-iframe-script.ts index bcafede0212..86a39776dde 100644 --- a/code/builders/builder-vite/src/codegen-modern-iframe-script.ts +++ b/code/builders/builder-vite/src/codegen-modern-iframe-script.ts @@ -1,7 +1,8 @@ -import { loadPreviewOrConfigFile, getFrameworkName } from 'storybook/internal/common'; +import { getFrameworkName, loadPreviewOrConfigFile } from 'storybook/internal/common'; import type { Options, PreviewAnnotation } from 'storybook/internal/types'; -import { virtualStoriesFile, virtualAddonSetupFile } from './virtual-file-names'; + import { processPreviewAnnotation } from './utils/process-preview-annotation'; +import { virtualAddonSetupFile, virtualStoriesFile } from './virtual-file-names'; export async function generateModernIframeScriptCode(options: Options, projectRoot: string) { const { presets, configDir } = options; diff --git a/code/builders/builder-vite/src/envs.ts b/code/builders/builder-vite/src/envs.ts index 1b9495d7882..422ce3ae28b 100644 --- a/code/builders/builder-vite/src/envs.ts +++ b/code/builders/builder-vite/src/envs.ts @@ -1,7 +1,8 @@ import { stringifyEnvs } from 'storybook/internal/common'; -import type { UserConfig as ViteConfig } from 'vite'; import type { Builder_EnvsRaw, Options } from 'storybook/internal/types'; +import type { UserConfig as ViteConfig } from 'vite'; + // Allowed env variables on the client const allowedEnvVariables = [ 'STORYBOOK', diff --git a/code/builders/builder-vite/src/index.ts b/code/builders/builder-vite/src/index.ts index d62d230b676..edc6a98843d 100644 --- a/code/builders/builder-vite/src/index.ts +++ b/code/builders/builder-vite/src/index.ts @@ -1,17 +1,18 @@ // noinspection JSUnusedGlobalSymbols +import { NoStatsForViteDevError } from 'storybook/internal/server-errors'; +import type { Options } from 'storybook/internal/types'; -import * as fs from 'fs-extra'; import type { RequestHandler } from 'express'; -import type { ViteDevServer } from 'vite'; import express from 'express'; +import * as fs from 'fs-extra'; import { join, parse } from 'path'; -import { NoStatsForViteDevError } from 'storybook/internal/server-errors'; -import type { Options } from 'storybook/internal/types'; import { corePath } from 'storybook/core-path'; -import { transformIframeHtml } from './transform-iframe-html'; -import { createViteServer } from './vite-server'; +import type { ViteDevServer } from 'vite'; + import { build as viteBuild } from './build'; +import { transformIframeHtml } from './transform-iframe-html'; import type { ViteBuilder } from './types'; +import { createViteServer } from './vite-server'; export { withoutVitePlugins } from './utils/without-vite-plugins'; export { hasVitePlugins } from './utils/has-vite-plugins'; diff --git a/code/builders/builder-vite/src/list-stories.ts b/code/builders/builder-vite/src/list-stories.ts index e484ba6cc0c..98916fb994b 100644 --- a/code/builders/builder-vite/src/list-stories.ts +++ b/code/builders/builder-vite/src/list-stories.ts @@ -1,9 +1,9 @@ +import { commonGlobOptions, normalizeStories } from 'storybook/internal/common'; +import type { Options } from 'storybook/internal/types'; + +import { glob } from 'glob'; import * as path from 'path'; import slash from 'slash'; -import { glob } from 'glob'; -import { normalizeStories, commonGlobOptions } from 'storybook/internal/common'; - -import type { Options } from 'storybook/internal/types'; export async function listStories(options: Options) { const { normalizePath } = await import('vite'); diff --git a/code/builders/builder-vite/src/optimizeDeps.ts b/code/builders/builder-vite/src/optimizeDeps.ts index 2b0cb4ad904..c3899075e1e 100644 --- a/code/builders/builder-vite/src/optimizeDeps.ts +++ b/code/builders/builder-vite/src/optimizeDeps.ts @@ -1,6 +1,8 @@ -import * as path from 'path'; -import type { InlineConfig as ViteInlineConfig, UserConfig } from 'vite'; import type { Options } from 'storybook/internal/types'; + +import * as path from 'path'; +import type { UserConfig, InlineConfig as ViteInlineConfig } from 'vite'; + import { listStories } from './list-stories'; // It ensures that vite converts cjs deps into esm without vite having to find them during startup and then having to log a message about them and restart diff --git a/code/builders/builder-vite/src/plugins/code-generator-plugin.ts b/code/builders/builder-vite/src/plugins/code-generator-plugin.ts index 65015129cb3..d4d6bfc1e4f 100644 --- a/code/builders/builder-vite/src/plugins/code-generator-plugin.ts +++ b/code/builders/builder-vite/src/plugins/code-generator-plugin.ts @@ -1,11 +1,12 @@ +import type { Options } from 'storybook/internal/types'; + import * as fs from 'fs'; import type { Plugin } from 'vite'; -import type { Options } from 'storybook/internal/types'; -import { transformIframeHtml } from '../transform-iframe-html'; -import { generateModernIframeScriptCode } from '../codegen-modern-iframe-script'; + import { generateImportFnScriptCode } from '../codegen-importfn-script'; +import { generateModernIframeScriptCode } from '../codegen-modern-iframe-script'; import { generateAddonSetupCode } from '../codegen-set-addon-channel'; - +import { transformIframeHtml } from '../transform-iframe-html'; import { virtualAddonSetupFile, virtualFileId, diff --git a/code/builders/builder-vite/src/plugins/csf-plugin.ts b/code/builders/builder-vite/src/plugins/csf-plugin.ts index cb549f165b8..2541f7b7475 100644 --- a/code/builders/builder-vite/src/plugins/csf-plugin.ts +++ b/code/builders/builder-vite/src/plugins/csf-plugin.ts @@ -1,7 +1,9 @@ -import type { Plugin } from 'vite'; -import { vite } from '@storybook/csf-plugin'; import type { Options } from 'storybook/internal/types'; +import { vite } from '@storybook/csf-plugin'; + +import type { Plugin } from 'vite'; + export async function csfPlugin(config: Options): Promise { const { presets } = config; diff --git a/code/builders/builder-vite/src/plugins/external-globals-plugin.test.ts b/code/builders/builder-vite/src/plugins/external-globals-plugin.test.ts index fc9ec9e47ab..9555a4dd6b8 100644 --- a/code/builders/builder-vite/src/plugins/external-globals-plugin.test.ts +++ b/code/builders/builder-vite/src/plugins/external-globals-plugin.test.ts @@ -1,4 +1,5 @@ -import { it, expect } from 'vitest'; +import { expect, it } from 'vitest'; + import { rewriteImport } from './external-globals-plugin'; const packageName = '@storybook/package'; diff --git a/code/builders/builder-vite/src/plugins/external-globals-plugin.ts b/code/builders/builder-vite/src/plugins/external-globals-plugin.ts index 94af1a74999..8fbe95669f1 100644 --- a/code/builders/builder-vite/src/plugins/external-globals-plugin.ts +++ b/code/builders/builder-vite/src/plugins/external-globals-plugin.ts @@ -1,8 +1,9 @@ import { join } from 'node:path'; -import findCacheDirectory from 'find-cache-dir'; + import { init, parse } from 'es-module-lexer'; -import MagicString from 'magic-string'; +import findCacheDirectory from 'find-cache-dir'; import { ensureFile, writeFile } from 'fs-extra'; +import MagicString from 'magic-string'; import type { Alias, Plugin } from 'vite'; const escapeKeys = (key: string) => key.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&'); diff --git a/code/builders/builder-vite/src/plugins/strip-story-hmr-boundaries.ts b/code/builders/builder-vite/src/plugins/strip-story-hmr-boundaries.ts index c249fc523d1..d393d41476b 100644 --- a/code/builders/builder-vite/src/plugins/strip-story-hmr-boundaries.ts +++ b/code/builders/builder-vite/src/plugins/strip-story-hmr-boundaries.ts @@ -1,5 +1,5 @@ -import type { Plugin } from 'vite'; import MagicString from 'magic-string'; +import type { Plugin } from 'vite'; /** * This plugin removes HMR `accept` calls in story files. Stories should not be treated diff --git a/code/builders/builder-vite/src/plugins/webpack-stats-plugin.ts b/code/builders/builder-vite/src/plugins/webpack-stats-plugin.ts index 672ff4531a6..a318a0d1fbd 100644 --- a/code/builders/builder-vite/src/plugins/webpack-stats-plugin.ts +++ b/code/builders/builder-vite/src/plugins/webpack-stats-plugin.ts @@ -1,6 +1,6 @@ // This plugin is a direct port of https://github.com/IanVS/vite-plugin-turbosnap - import type { BuilderStats } from 'storybook/internal/types'; + import path from 'path'; import slash from 'slash'; import type { Plugin } from 'vite'; diff --git a/code/builders/builder-vite/src/transform-iframe-html.ts b/code/builders/builder-vite/src/transform-iframe-html.ts index 0cf17c2cd8d..6f864b5e418 100644 --- a/code/builders/builder-vite/src/transform-iframe-html.ts +++ b/code/builders/builder-vite/src/transform-iframe-html.ts @@ -1,5 +1,5 @@ import { normalizeStories } from 'storybook/internal/common'; -import type { DocsOptions, TagsOptions, Options } from 'storybook/internal/types'; +import type { DocsOptions, Options, TagsOptions } from 'storybook/internal/types'; export type PreviewHtml = string | undefined; diff --git a/code/builders/builder-vite/src/types.ts b/code/builders/builder-vite/src/types.ts index a6579ed938c..404a259243a 100644 --- a/code/builders/builder-vite/src/types.ts +++ b/code/builders/builder-vite/src/types.ts @@ -1,6 +1,7 @@ -import type { InlineConfig, UserConfig } from 'vite'; import type { Builder, Options } from 'storybook/internal/types'; +import type { InlineConfig, UserConfig } from 'vite'; + // Storybook's Stats are optional Webpack related property type ViteStats = { toJson: () => any; diff --git a/code/builders/builder-vite/src/utils/has-vite-plugins.test.ts b/code/builders/builder-vite/src/utils/has-vite-plugins.test.ts index 8070b69220b..b8d5a3e4461 100644 --- a/code/builders/builder-vite/src/utils/has-vite-plugins.test.ts +++ b/code/builders/builder-vite/src/utils/has-vite-plugins.test.ts @@ -1,4 +1,5 @@ -import { describe, it, expect } from 'vitest'; +import { describe, expect, it } from 'vitest'; + import { hasVitePlugins } from './has-vite-plugins'; describe('hasVitePlugins', () => { diff --git a/code/builders/builder-vite/src/utils/process-preview-annotation.test.ts b/code/builders/builder-vite/src/utils/process-preview-annotation.test.ts index 4d211fd5faf..3a01623919d 100644 --- a/code/builders/builder-vite/src/utils/process-preview-annotation.test.ts +++ b/code/builders/builder-vite/src/utils/process-preview-annotation.test.ts @@ -1,6 +1,7 @@ -import { describe, it, expect } from 'vitest'; -import { processPreviewAnnotation } from './process-preview-annotation'; +import { describe, expect, it } from 'vitest'; + import { onlyWindows, skipWindows } from '../../../../vitest.helpers'; +import { processPreviewAnnotation } from './process-preview-annotation'; describe('processPreviewAnnotation()', () => { it('should pull the `bare` value from an object', () => { diff --git a/code/builders/builder-vite/src/utils/process-preview-annotation.ts b/code/builders/builder-vite/src/utils/process-preview-annotation.ts index e87259d0094..c7e3db8c23a 100644 --- a/code/builders/builder-vite/src/utils/process-preview-annotation.ts +++ b/code/builders/builder-vite/src/utils/process-preview-annotation.ts @@ -1,7 +1,8 @@ +import { stripAbsNodeModulesPath } from 'storybook/internal/common'; import type { PreviewAnnotation } from 'storybook/internal/types'; -import { resolve, isAbsolute, relative } from 'path'; + +import { isAbsolute, relative, resolve } from 'path'; import slash from 'slash'; -import { stripAbsNodeModulesPath } from 'storybook/internal/common'; /** * Preview annotations can take several forms, and vite needs them to be diff --git a/code/builders/builder-vite/src/utils/without-vite-plugins.test.ts b/code/builders/builder-vite/src/utils/without-vite-plugins.test.ts index dea82e6af9c..e0efee13036 100644 --- a/code/builders/builder-vite/src/utils/without-vite-plugins.test.ts +++ b/code/builders/builder-vite/src/utils/without-vite-plugins.test.ts @@ -1,4 +1,5 @@ -import { describe, it, expect } from 'vitest'; +import { describe, expect, it } from 'vitest'; + import { withoutVitePlugins } from './without-vite-plugins'; describe('withoutVitePlugins', () => { diff --git a/code/builders/builder-vite/src/vite-config.test.ts b/code/builders/builder-vite/src/vite-config.test.ts index 6f83d67b547..d88da030539 100644 --- a/code/builders/builder-vite/src/vite-config.test.ts +++ b/code/builders/builder-vite/src/vite-config.test.ts @@ -1,7 +1,10 @@ -import { describe, it, expect, vi } from 'vitest'; +import { describe, expect, it, vi } from 'vitest'; + import type { Options, Presets } from 'storybook/internal/types'; + // eslint-disable-next-line @typescript-eslint/no-restricted-imports import { loadConfigFromFile } from 'vite'; + import { commonConfig } from './vite-config'; vi.mock('vite', async (importOriginal) => ({ diff --git a/code/builders/builder-vite/src/vite-config.ts b/code/builders/builder-vite/src/vite-config.ts index 2a965dbacff..e7c5b874c4f 100644 --- a/code/builders/builder-vite/src/vite-config.ts +++ b/code/builders/builder-vite/src/vite-config.ts @@ -1,28 +1,29 @@ -import * as path from 'path'; -import type { - ConfigEnv, - InlineConfig as ViteInlineConfig, - PluginOption, - UserConfig as ViteConfig, - InlineConfig, -} from 'vite'; import { - isPreservingSymlinks, - getFrameworkName, getBuilderOptions, + getFrameworkName, + isPreservingSymlinks, resolvePathInStorybookCache, } from 'storybook/internal/common'; import { globalsNameReferenceMap } from 'storybook/internal/preview/globals'; import type { Options } from 'storybook/internal/types'; + +import * as path from 'path'; +import type { + ConfigEnv, + InlineConfig, + PluginOption, + UserConfig as ViteConfig, + InlineConfig as ViteInlineConfig, +} from 'vite'; + import { codeGeneratorPlugin, csfPlugin, - injectExportOrderPlugin, - stripStoryHMRBoundary, externalGlobalsPlugin, + injectExportOrderPlugin, pluginWebpackStats, + stripStoryHMRBoundary, } from './plugins'; - import type { BuilderOptions } from './types'; export type PluginConfigType = 'build' | 'development'; diff --git a/code/builders/builder-vite/src/vite-server.ts b/code/builders/builder-vite/src/vite-server.ts index 41cc40ed947..ff235aa9383 100644 --- a/code/builders/builder-vite/src/vite-server.ts +++ b/code/builders/builder-vite/src/vite-server.ts @@ -1,9 +1,11 @@ -import type { Server } from 'http'; import type { Options } from 'storybook/internal/types'; -import { commonConfig } from './vite-config'; -import { getOptimizeDeps } from './optimizeDeps'; -import { sanitizeEnvVars } from './envs'; + +import type { Server } from 'http'; + import { getAssetsInclude } from './assetsInclude'; +import { sanitizeEnvVars } from './envs'; +import { getOptimizeDeps } from './optimizeDeps'; +import { commonConfig } from './vite-config'; export async function createViteServer(options: Options, devServer: Server) { const { presets } = options; diff --git a/code/builders/builder-vite/vitest.config.ts b/code/builders/builder-vite/vitest.config.ts index ea8b4ef1435..edf3cc3ea03 100644 --- a/code/builders/builder-vite/vitest.config.ts +++ b/code/builders/builder-vite/vitest.config.ts @@ -1,5 +1,6 @@ // eslint-disable-next-line import/no-extraneous-dependencies import { defineConfig, mergeConfig } from 'vitest/config'; + import { vitestCommonConfig } from '../../vitest.workspace'; export default mergeConfig( diff --git a/code/builders/builder-webpack5/src/index.ts b/code/builders/builder-webpack5/src/index.ts index 635643626e6..c19779de2f7 100644 --- a/code/builders/builder-webpack5/src/index.ts +++ b/code/builders/builder-webpack5/src/index.ts @@ -1,22 +1,23 @@ -import type { Stats, Configuration, StatsOptions } from 'webpack'; -import webpack, { ProgressPlugin } from 'webpack'; -import webpackDevMiddleware from 'webpack-dev-middleware'; -import webpackHotMiddleware from 'webpack-hot-middleware'; -import { logger } from 'storybook/internal/node-logger'; -import type { Builder, Options } from 'storybook/internal/types'; -import { corePath } from 'storybook/core-path'; -import { checkWebpackVersion } from '@storybook/core-webpack'; -import { join, parse } from 'path'; -import express from 'express'; -import fs from 'fs-extra'; import { PREVIEW_BUILDER_PROGRESS } from 'storybook/internal/core-events'; +import { logger } from 'storybook/internal/node-logger'; import { WebpackCompilationError, WebpackInvocationError, WebpackMissingStatsError, } from 'storybook/internal/server-errors'; +import type { Builder, Options } from 'storybook/internal/types'; + +import { checkWebpackVersion } from '@storybook/core-webpack'; +import express from 'express'; +import fs from 'fs-extra'; +import { join, parse } from 'path'; import prettyTime from 'pretty-hrtime'; +import { corePath } from 'storybook/core-path'; +import type { Configuration, Stats, StatsOptions } from 'webpack'; +import webpack, { ProgressPlugin } from 'webpack'; +import webpackDevMiddleware from 'webpack-dev-middleware'; +import webpackHotMiddleware from 'webpack-hot-middleware'; export * from './types'; export * from './preview/virtual-module-mapping'; diff --git a/code/builders/builder-webpack5/src/loaders/export-order-loader.ts b/code/builders/builder-webpack5/src/loaders/export-order-loader.ts index ef3149a424c..43f5fd00db4 100644 --- a/code/builders/builder-webpack5/src/loaders/export-order-loader.ts +++ b/code/builders/builder-webpack5/src/loaders/export-order-loader.ts @@ -1,5 +1,6 @@ import assert from 'node:assert'; -import { parse as parseCjs, init as initCjsParser } from 'cjs-module-lexer'; + +import { init as initCjsParser, parse as parseCjs } from 'cjs-module-lexer'; import { parse as parseEs } from 'es-module-lexer'; import MagicString from 'magic-string'; import type { LoaderContext } from 'webpack'; diff --git a/code/builders/builder-webpack5/src/presets/custom-webpack-preset.ts b/code/builders/builder-webpack5/src/presets/custom-webpack-preset.ts index f8978d51297..31a90cf794f 100644 --- a/code/builders/builder-webpack5/src/presets/custom-webpack-preset.ts +++ b/code/builders/builder-webpack5/src/presets/custom-webpack-preset.ts @@ -1,8 +1,11 @@ -import * as webpackReal from 'webpack'; import { logger } from 'storybook/internal/node-logger'; import type { Options, PresetProperty } from 'storybook/internal/types'; -import type { Configuration } from 'webpack'; + import { loadCustomWebpackConfig } from '@storybook/core-webpack'; + +import * as webpackReal from 'webpack'; +import type { Configuration } from 'webpack'; + import { createDefaultWebpackConfig } from '../preview/base-webpack.config'; export const swc: PresetProperty<'swc'> = (config: Record): Record => { diff --git a/code/builders/builder-webpack5/src/preview/base-webpack.config.ts b/code/builders/builder-webpack5/src/preview/base-webpack.config.ts index e99fab6b769..d53b437989e 100644 --- a/code/builders/builder-webpack5/src/preview/base-webpack.config.ts +++ b/code/builders/builder-webpack5/src/preview/base-webpack.config.ts @@ -1,5 +1,6 @@ import { logger } from 'storybook/internal/node-logger'; import type { Options } from 'storybook/internal/types'; + import type { Configuration } from 'webpack'; export async function createDefaultWebpackConfig( diff --git a/code/builders/builder-webpack5/src/preview/iframe-webpack.config.ts b/code/builders/builder-webpack5/src/preview/iframe-webpack.config.ts index c594b12978d..0cea3b15737 100644 --- a/code/builders/builder-webpack5/src/preview/iframe-webpack.config.ts +++ b/code/builders/builder-webpack5/src/preview/iframe-webpack.config.ts @@ -1,23 +1,26 @@ -import { dirname, join, resolve } from 'path'; -import { DefinePlugin, HotModuleReplacementPlugin, ProgressPlugin, ProvidePlugin } from 'webpack'; -import type { Configuration } from 'webpack'; -import HtmlWebpackPlugin from 'html-webpack-plugin'; -// @ts-expect-error (I removed this on purpose, because it's incorrect) -import CaseSensitivePathsPlugin from 'case-sensitive-paths-webpack-plugin'; -import TerserWebpackPlugin from 'terser-webpack-plugin'; -import VirtualModulePlugin from 'webpack-virtual-modules'; -import ForkTsCheckerWebpackPlugin from 'fork-ts-checker-webpack-plugin'; -import type { TransformOptions as EsbuildOptions } from 'esbuild'; -import type { Options } from 'storybook/internal/types'; -import { globalsNameReferenceMap } from 'storybook/internal/preview/globals'; import { getBuilderOptions, - stringifyProcessEnvs, - normalizeStories, isPreservingSymlinks, + normalizeStories, + stringifyProcessEnvs, } from 'storybook/internal/common'; +import { globalsNameReferenceMap } from 'storybook/internal/preview/globals'; +import type { Options } from 'storybook/internal/types'; + import { type BuilderOptions } from '@storybook/core-webpack'; + +// @ts-expect-error (I removed this on purpose, because it's incorrect) +import CaseSensitivePathsPlugin from 'case-sensitive-paths-webpack-plugin'; +import type { TransformOptions as EsbuildOptions } from 'esbuild'; +import ForkTsCheckerWebpackPlugin from 'fork-ts-checker-webpack-plugin'; +import HtmlWebpackPlugin from 'html-webpack-plugin'; +import { dirname, join, resolve } from 'path'; +import TerserWebpackPlugin from 'terser-webpack-plugin'; import { dedent } from 'ts-dedent'; +import { DefinePlugin, HotModuleReplacementPlugin, ProgressPlugin, ProvidePlugin } from 'webpack'; +import type { Configuration } from 'webpack'; +import VirtualModulePlugin from 'webpack-virtual-modules'; + import type { TypescriptOptions } from '../types'; import { getVirtualModules } from './virtual-module-mapping'; diff --git a/code/builders/builder-webpack5/src/preview/virtual-module-mapping.ts b/code/builders/builder-webpack5/src/preview/virtual-module-mapping.ts index 69f64ad4192..8c43fff1719 100644 --- a/code/builders/builder-webpack5/src/preview/virtual-module-mapping.ts +++ b/code/builders/builder-webpack5/src/preview/virtual-module-mapping.ts @@ -1,5 +1,3 @@ -import type { Options, PreviewAnnotation } from 'storybook/internal/types'; -import { join, resolve } from 'path'; import { getBuilderOptions, handlebars, @@ -7,8 +5,13 @@ import { normalizeStories, readTemplate, } from 'storybook/internal/common'; -import slash from 'slash'; +import type { Options, PreviewAnnotation } from 'storybook/internal/types'; + import { toImportFn } from '@storybook/core-webpack'; + +import { join, resolve } from 'path'; +import slash from 'slash'; + import type { BuilderOptions } from '../types'; export const getVirtualModules = async (options: Options) => { diff --git a/code/builders/builder-webpack5/src/types.ts b/code/builders/builder-webpack5/src/types.ts index 38621af5627..1064cdb485f 100644 --- a/code/builders/builder-webpack5/src/types.ts +++ b/code/builders/builder-webpack5/src/types.ts @@ -1,12 +1,12 @@ -import type { Configuration, Stats } from 'webpack'; import type { - Options, BuilderResult as BuilderResultBase, + Options, StorybookConfig, TypescriptOptions as WebpackTypescriptOptions, } from '@storybook/core-webpack'; import type ForkTsCheckerWebpackPlugin from 'fork-ts-checker-webpack-plugin'; +import type { Configuration, Stats } from 'webpack'; type TypeScriptOptionsBase = Partial; diff --git a/code/builders/builder-webpack5/vitest.config.ts b/code/builders/builder-webpack5/vitest.config.ts index ea8b4ef1435..edf3cc3ea03 100644 --- a/code/builders/builder-webpack5/vitest.config.ts +++ b/code/builders/builder-webpack5/vitest.config.ts @@ -1,5 +1,6 @@ // eslint-disable-next-line import/no-extraneous-dependencies import { defineConfig, mergeConfig } from 'vitest/config'; + import { vitestCommonConfig } from '../../vitest.workspace'; export default mergeConfig( diff --git a/code/core/scripts/check.ts b/code/core/scripts/check.ts index ca51bcf847f..945fe125c13 100644 --- a/code/core/scripts/check.ts +++ b/code/core/scripts/check.ts @@ -1,4 +1,4 @@ -import { getTSFilesAndConfig, getTSProgramAndHost, getTSDiagnostics } from './helpers/typescript'; +import { getTSDiagnostics, getTSFilesAndConfig, getTSProgramAndHost } from './helpers/typescript'; const tsconfigPath = 'tsconfig.json'; diff --git a/code/core/scripts/dts.ts b/code/core/scripts/dts.ts index fc291e2a234..93458c07dfa 100644 --- a/code/core/scripts/dts.ts +++ b/code/core/scripts/dts.ts @@ -1,7 +1,8 @@ import { join } from 'node:path'; -import { process, dts, nodeInternals } from '../../../scripts/prepare/tools'; -import { getEntries } from './entries'; + +import { dts, nodeInternals, process } from '../../../scripts/prepare/tools'; import pkg from '../package.json'; +import { getEntries } from './entries'; async function run() { const cwd = process.cwd(); diff --git a/code/core/scripts/helpers/dependencies.ts b/code/core/scripts/helpers/dependencies.ts index a02b8ca41d8..82b22a022ad 100644 --- a/code/core/scripts/helpers/dependencies.ts +++ b/code/core/scripts/helpers/dependencies.ts @@ -1,6 +1,7 @@ -import { readJson } from 'fs-extra'; import { join } from 'node:path'; +import { readJson } from 'fs-extra'; + export async function flattenDependencies( list: string[], output: string[] = [], diff --git a/code/core/scripts/helpers/generatePackageJsonFile.ts b/code/core/scripts/helpers/generatePackageJsonFile.ts index 437d34c461a..08a7975e3d9 100644 --- a/code/core/scripts/helpers/generatePackageJsonFile.ts +++ b/code/core/scripts/helpers/generatePackageJsonFile.ts @@ -1,9 +1,11 @@ +import { writeFile } from 'node:fs/promises'; import { join, relative } from 'node:path'; + +import { readJSON } from 'fs-extra'; import slash from 'slash'; + import { sortPackageJson } from '../../../../scripts/prepare/tools'; import type { getEntries } from '../entries'; -import { readJSON } from 'fs-extra'; -import { writeFile } from 'node:fs/promises'; const cwd = process.cwd(); diff --git a/code/core/scripts/helpers/generateTypesFiles.ts b/code/core/scripts/helpers/generateTypesFiles.ts index 8a5e5767b22..a657c6fbd8a 100644 --- a/code/core/scripts/helpers/generateTypesFiles.ts +++ b/code/core/scripts/helpers/generateTypesFiles.ts @@ -1,6 +1,7 @@ import { join, relative } from 'node:path'; + import { spawn } from '../../../../scripts/prepare/tools'; -import { process, chalk, limit } from '../../../../scripts/prepare/tools'; +import { chalk, limit, process } from '../../../../scripts/prepare/tools'; import type { getEntries } from '../entries'; export async function generateTypesFiles( diff --git a/code/core/scripts/helpers/generateTypesMapperFiles.ts b/code/core/scripts/helpers/generateTypesMapperFiles.ts index 82cadc3dc8a..11423eaa0b5 100644 --- a/code/core/scripts/helpers/generateTypesMapperFiles.ts +++ b/code/core/scripts/helpers/generateTypesMapperFiles.ts @@ -1,9 +1,11 @@ -import type { getEntries } from '../entries'; -import { join, relative } from 'node:path'; -import { dedent } from '../../../../scripts/prepare/tools'; import { writeFile } from 'node:fs/promises'; +import { join, relative } from 'node:path'; + import { ensureFile } from 'fs-extra'; +import { dedent } from '../../../../scripts/prepare/tools'; +import type { getEntries } from '../entries'; + const cwd = process.cwd(); async function generateTypesMapperContent(filePath: string) { diff --git a/code/core/scripts/helpers/modifyThemeTypes.ts b/code/core/scripts/helpers/modifyThemeTypes.ts index 14a0b4c0dd8..5e586f4763b 100644 --- a/code/core/scripts/helpers/modifyThemeTypes.ts +++ b/code/core/scripts/helpers/modifyThemeTypes.ts @@ -1,6 +1,7 @@ +import { readFile, writeFile } from 'node:fs/promises'; import { join } from 'node:path'; + import { dedent } from '../../../../scripts/prepare/tools'; -import { readFile, writeFile } from 'node:fs/promises'; export async function modifyThemeTypes() { /** diff --git a/code/core/scripts/helpers/sourcefiles.ts b/code/core/scripts/helpers/sourcefiles.ts index d5a8c0508bf..7b38a00e025 100644 --- a/code/core/scripts/helpers/sourcefiles.ts +++ b/code/core/scripts/helpers/sourcefiles.ts @@ -1,10 +1,11 @@ -import { join } from 'node:path'; import { readdir, writeFile } from 'node:fs/promises'; -import { dedent, prettier, getWorkspace, esbuild } from '../../../../scripts/prepare/tools'; -import { temporaryFile } from '../../src/common/utils/cli'; +import { join } from 'node:path'; import { GlobalRegistrator } from '@happy-dom/global-registrator'; +import { dedent, esbuild, getWorkspace, prettier } from '../../../../scripts/prepare/tools'; +import { temporaryFile } from '../../src/common/utils/cli'; + GlobalRegistrator.register({ url: 'http://localhost:3000', width: 1920, height: 1080 }); // read code/frameworks subfolders and generate a list of available frameworks diff --git a/code/core/scripts/helpers/typescript.ts b/code/core/scripts/helpers/typescript.ts index 474a64e8bc7..13d26b9be64 100644 --- a/code/core/scripts/helpers/typescript.ts +++ b/code/core/scripts/helpers/typescript.ts @@ -1,4 +1,5 @@ import { join } from 'node:path'; + import { typescript } from '../../../../scripts/prepare/tools'; export function getTSDiagnostics( diff --git a/code/core/scripts/prep.ts b/code/core/scripts/prep.ts index 7fb69f15f3c..a24980b296f 100644 --- a/code/core/scripts/prep.ts +++ b/code/core/scripts/prep.ts @@ -1,30 +1,28 @@ /* eslint-disable local-rules/no-uncategorized-errors */ - import { watch } from 'node:fs'; import { mkdir, rm } from 'node:fs/promises'; -import { join, dirname } from 'node:path'; +import { dirname, join } from 'node:path'; + import { - esbuild, - process, - merge, - measure, chalk, - prettyTime, - nodeInternals, dedent, + esbuild, globalExternals, + measure, + merge, + nodeInternals, + prettyTime, + process, } from '../../../scripts/prepare/tools'; -import { getBundles, getEntries, getFinals } from './entries'; - -import { globalsModuleInfoMap } from '../src/manager/globals-module-info'; - import pkg from '../package.json'; -import { generateSourceFiles } from './helpers/sourcefiles'; -import { modifyThemeTypes } from './helpers/modifyThemeTypes'; +import { globalsModuleInfoMap } from '../src/manager/globals-module-info'; +import { getBundles, getEntries, getFinals } from './entries'; import { generatePackageJsonFile } from './helpers/generatePackageJsonFile'; -import { generateTypesMapperFiles } from './helpers/generateTypesMapperFiles'; import { generateTypesFiles } from './helpers/generateTypesFiles'; -import { isNode, noExternals, isBrowser } from './helpers/isEntryType'; +import { generateTypesMapperFiles } from './helpers/generateTypesMapperFiles'; +import { isBrowser, isNode, noExternals } from './helpers/isEntryType'; +import { modifyThemeTypes } from './helpers/modifyThemeTypes'; +import { generateSourceFiles } from './helpers/sourcefiles'; async function run() { const flags = process.argv.slice(2); diff --git a/code/core/src/ERRORS.md b/code/core/src/ERRORS.md index 3638cb7e478..bba4fbbc6a9 100644 --- a/code/core/src/ERRORS.md +++ b/code/core/src/ERRORS.md @@ -26,6 +26,7 @@ Second use the `StorybookError` class to define custom errors with specific code ```typescript import { StorybookError } from './storybook-error'; + export class YourCustomError extends StorybookError { constructor() { super({ diff --git a/code/core/src/__tests/preview-errors.test.ts b/code/core/src/__tests/preview-errors.test.ts index ae573d0f4ea..6c780167947 100644 --- a/code/core/src/__tests/preview-errors.test.ts +++ b/code/core/src/__tests/preview-errors.test.ts @@ -1,4 +1,5 @@ -import { describe, it, expect } from 'vitest'; +import { describe, expect, it } from 'vitest'; + import { UnknownArgTypesError } from '../preview-errors'; describe('UnknownFlowArgTypesError', () => { diff --git a/code/core/src/__tests/server-errors.test.ts b/code/core/src/__tests/server-errors.test.ts index e5a23d7054c..e268a8b43e5 100644 --- a/code/core/src/__tests/server-errors.test.ts +++ b/code/core/src/__tests/server-errors.test.ts @@ -1,4 +1,5 @@ -import { describe, it, expect } from 'vitest'; +import { describe, expect, it } from 'vitest'; + import { WebpackCompilationError } from '../server-errors'; describe('WebpackCompilationError', () => { diff --git a/code/core/src/__tests/storybook-error.test.ts b/code/core/src/__tests/storybook-error.test.ts index dfbec154637..770997b00fe 100644 --- a/code/core/src/__tests/storybook-error.test.ts +++ b/code/core/src/__tests/storybook-error.test.ts @@ -1,4 +1,5 @@ -import { describe, it, expect } from 'vitest'; +import { describe, expect, it } from 'vitest'; + import { StorybookError } from '../storybook-error'; describe('StorybookError', () => { diff --git a/code/core/src/builder-manager/index.ts b/code/core/src/builder-manager/index.ts index 01755fbdef2..e23d3bb89ac 100644 --- a/code/core/src/builder-manager/index.ts +++ b/code/core/src/builder-manager/index.ts @@ -1,17 +1,16 @@ import { dirname, join, parse } from 'node:path'; -import fs from 'fs-extra'; -import express from 'express'; +import { stringifyProcessEnvs } from '@storybook/core/common'; + +import { globalsModuleInfoMap } from '@storybook/core/manager/globals-module-info'; import { logger } from '@storybook/core/node-logger'; import { globalExternals } from '@fal-works/esbuild-plugin-global-externals'; import { pnpPlugin } from '@yarnpkg/esbuild-plugin-pnp'; import aliasPlugin from 'esbuild-plugin-alias'; +import express from 'express'; +import fs from 'fs-extra'; -import { stringifyProcessEnvs } from '@storybook/core/common'; -import { globalsModuleInfoMap } from '@storybook/core/manager/globals-module-info'; -import { getTemplatePath, renderHTML } from './utils/template'; -import { wrapManagerEntries } from './utils/managerEntries'; import type { BuilderBuildResult, BuilderFunction, @@ -20,11 +19,12 @@ import type { ManagerBuilder, StarterFunction, } from './types'; - import { getData } from './utils/data'; -import { safeResolve } from './utils/safeResolve'; import { readOrderedFiles } from './utils/files'; import { buildFrameworkGlobalsFromOptions } from './utils/framework'; +import { wrapManagerEntries } from './utils/managerEntries'; +import { safeResolve } from './utils/safeResolve'; +import { getTemplatePath, renderHTML } from './utils/template'; let compilation: Compilation; let asyncIterator: ReturnType | ReturnType; diff --git a/code/core/src/builder-manager/types.ts b/code/core/src/builder-manager/types.ts index a56481f2c5e..e7541dced4b 100644 --- a/code/core/src/builder-manager/types.ts +++ b/code/core/src/builder-manager/types.ts @@ -1,8 +1,8 @@ import type { Builder, - Builder_WithRequiredProperty, BuilderStats, Builder_Unpromise, + Builder_WithRequiredProperty, } from '@storybook/core/types'; import type { BuildOptions, BuildResult } from 'esbuild'; diff --git a/code/core/src/builder-manager/utils/data.ts b/code/core/src/builder-manager/utils/data.ts index fc21a933c49..233d3186c38 100644 --- a/code/core/src/builder-manager/utils/data.ts +++ b/code/core/src/builder-manager/utils/data.ts @@ -1,10 +1,10 @@ import { basename } from 'node:path'; -import type { Options } from '@storybook/core/types'; -import { getRefs } from '@storybook/core/common'; -import { readTemplate } from './template'; +import { getRefs } from '@storybook/core/common'; +import type { Options } from '@storybook/core/types'; import { executor, getConfig } from '../index'; +import { readTemplate } from './template'; export const getData = async (options: Options) => { const refs = getRefs(options); diff --git a/code/core/src/builder-manager/utils/files.test.ts b/code/core/src/builder-manager/utils/files.test.ts index ed902f1d391..4d37bbd3af6 100644 --- a/code/core/src/builder-manager/utils/files.test.ts +++ b/code/core/src/builder-manager/utils/files.test.ts @@ -1,6 +1,8 @@ -import { it, expect } from 'vitest'; +import { expect, it } from 'vitest'; + import type { OutputFile } from 'esbuild'; import { platform } from 'os'; + import { sanitizePath } from './files'; const os = platform(); diff --git a/code/core/src/builder-manager/utils/files.ts b/code/core/src/builder-manager/utils/files.ts index 15e7d1838e2..94ec31677c4 100644 --- a/code/core/src/builder-manager/utils/files.ts +++ b/code/core/src/builder-manager/utils/files.ts @@ -1,7 +1,9 @@ +import { join, normalize } from 'node:path'; + import type { OutputFile } from 'esbuild'; import fs from 'fs-extra'; -import { join, normalize } from 'node:path'; import slash from 'slash'; + import type { Compilation } from '../types'; export async function readOrderedFiles( diff --git a/code/core/src/builder-manager/utils/framework.test.ts b/code/core/src/builder-manager/utils/framework.test.ts index ecdcb42ead5..8b2af6f9a6c 100644 --- a/code/core/src/builder-manager/utils/framework.test.ts +++ b/code/core/src/builder-manager/utils/framework.test.ts @@ -1,5 +1,6 @@ import path from 'node:path'; -import { describe, it, expect } from 'vitest'; + +import { describe, expect, it } from 'vitest'; import { pluckNameFromConfigProperty, diff --git a/code/core/src/builder-manager/utils/framework.ts b/code/core/src/builder-manager/utils/framework.ts index a40c72ae904..f29d0bd0506 100644 --- a/code/core/src/builder-manager/utils/framework.ts +++ b/code/core/src/builder-manager/utils/framework.ts @@ -1,6 +1,7 @@ import path from 'node:path'; -import type { Options } from '@storybook/core/types'; + import { extractProperRendererNameFromFramework, getFrameworkName } from '@storybook/core/common'; +import type { Options } from '@storybook/core/types'; interface PropertyObject { name: string; diff --git a/code/core/src/builder-manager/utils/managerEntries.ts b/code/core/src/builder-manager/utils/managerEntries.ts index 8d60a077759..a30fbab4a4b 100644 --- a/code/core/src/builder-manager/utils/managerEntries.ts +++ b/code/core/src/builder-manager/utils/managerEntries.ts @@ -1,6 +1,8 @@ -import fs from 'fs-extra'; -import { resolvePathInStorybookCache } from '@storybook/core/common'; import { join, parse, relative, sep } from 'node:path'; + +import { resolvePathInStorybookCache } from '@storybook/core/common'; + +import fs from 'fs-extra'; import slash from 'slash'; const sanitizeBase = (path: string) => { diff --git a/code/core/src/builder-manager/utils/template.ts b/code/core/src/builder-manager/utils/template.ts index 222bb80a0a6..b264a3d5e02 100644 --- a/code/core/src/builder-manager/utils/template.ts +++ b/code/core/src/builder-manager/utils/template.ts @@ -1,9 +1,9 @@ import { dirname, join } from 'node:path'; -import fs from 'fs-extra'; -import { render } from 'ejs'; +import type { DocsOptions, Options, Ref, TagsOptions } from '@storybook/core/types'; -import type { DocsOptions, TagsOptions, Options, Ref } from '@storybook/core/types'; +import { render } from 'ejs'; +import fs from 'fs-extra'; export const getTemplatePath = async (template: string) => { return join(dirname(require.resolve('@storybook/core/package.json')), 'assets/server', template); diff --git a/code/core/src/channels/index.test.ts b/code/core/src/channels/index.test.ts index f99e04f6099..44a9aba6109 100644 --- a/code/core/src/channels/index.test.ts +++ b/code/core/src/channels/index.test.ts @@ -1,4 +1,5 @@ -import { describe, beforeEach, it, expect, vi } from 'vitest'; +import { beforeEach, describe, expect, it, vi } from 'vitest'; + import type { ChannelTransport, Listener } from '.'; import { Channel, WebsocketTransport } from '.'; diff --git a/code/core/src/channels/index.ts b/code/core/src/channels/index.ts index 1823011d8b8..ab2d311b097 100644 --- a/code/core/src/channels/index.ts +++ b/code/core/src/channels/index.ts @@ -1,6 +1,6 @@ /// - import { global } from '@storybook/global'; + import { Channel } from './main'; import { PostMessageTransport } from './postmessage'; import type { ChannelTransport, Config } from './types'; diff --git a/code/core/src/channels/main.ts b/code/core/src/channels/main.ts index 795e9eaa2f6..62bebb4dd54 100644 --- a/code/core/src/channels/main.ts +++ b/code/core/src/channels/main.ts @@ -1,11 +1,11 @@ import type { ChannelArgs, ChannelArgsMulti, - EventsKeyValue, - ChannelTransport, ChannelArgsSingle, - Listener, ChannelEvent, + ChannelTransport, + EventsKeyValue, + Listener, } from './types'; const isMulti = (args: ChannelArgs): args is ChannelArgsMulti => { diff --git a/code/core/src/channels/postmessage/index.ts b/code/core/src/channels/postmessage/index.ts index 7d2bb67baf7..a60ba16a47b 100644 --- a/code/core/src/channels/postmessage/index.ts +++ b/code/core/src/channels/postmessage/index.ts @@ -1,16 +1,18 @@ /// - import { global } from '@storybook/global'; -import * as EVENTS from '@storybook/core/core-events'; + import { logger, pretty } from '@storybook/core/client-logger'; +import * as EVENTS from '@storybook/core/core-events'; + import { isJSON, parse, stringify } from 'telejson'; import invariant from 'tiny-invariant'; + import type { - ChannelTransport, BufferedEvent, + ChannelEvent, ChannelHandler, + ChannelTransport, Config, - ChannelEvent, } from '../types'; import { getEventSourceUrl } from './getEventSourceUrl'; diff --git a/code/core/src/channels/websocket/index.ts b/code/core/src/channels/websocket/index.ts index 989b5386268..15033296512 100644 --- a/code/core/src/channels/websocket/index.ts +++ b/code/core/src/channels/websocket/index.ts @@ -1,11 +1,12 @@ /// - import { global } from '@storybook/global'; + +import * as EVENTS from '@storybook/core/core-events'; + import { isJSON, parse, stringify } from 'telejson'; import invariant from 'tiny-invariant'; -import * as EVENTS from '@storybook/core/core-events'; -import type { ChannelTransport, ChannelHandler, Config } from '../types'; +import type { ChannelHandler, ChannelTransport, Config } from '../types'; const { WebSocket } = global; diff --git a/code/core/src/cli/angular/helpers.ts b/code/core/src/cli/angular/helpers.ts index 9d651fa60ca..ac7f88b713e 100644 --- a/code/core/src/cli/angular/helpers.ts +++ b/code/core/src/cli/angular/helpers.ts @@ -1,10 +1,11 @@ +import { logger } from '@storybook/core/node-logger'; +import { MissingAngularJsonError } from '@storybook/core/server-errors'; + +import boxen from 'boxen'; import fs from 'fs'; import { join } from 'path'; import prompts from 'prompts'; import { dedent } from 'ts-dedent'; -import { MissingAngularJsonError } from '@storybook/core/server-errors'; -import boxen from 'boxen'; -import { logger } from '@storybook/core/node-logger'; export const ANGULAR_JSON_PATH = 'angular.json'; diff --git a/code/core/src/cli/bin/index.ts b/code/core/src/cli/bin/index.ts index 512dc963924..38cbce23efb 100644 --- a/code/core/src/cli/bin/index.ts +++ b/code/core/src/cli/bin/index.ts @@ -1,15 +1,16 @@ -import program from 'commander'; +import { getEnvConfig, parseList, versions } from '@storybook/core/common'; +import { addToGlobalContext } from '@storybook/core/telemetry'; + +import { logger } from '@storybook/core/node-logger'; + import chalk from 'chalk'; -import leven from 'leven'; +import program from 'commander'; import { findPackageSync } from 'fd-package-json'; +import leven from 'leven'; import invariant from 'tiny-invariant'; -import { logger } from '@storybook/core/node-logger'; -import { addToGlobalContext } from '@storybook/core/telemetry'; -import { parseList, getEnvConfig, versions } from '@storybook/core/common'; - -import { dev } from '../dev'; import { build } from '../build'; +import { dev } from '../dev'; addToGlobalContext('cliVersion', versions.storybook); diff --git a/code/core/src/cli/build.ts b/code/core/src/cli/build.ts index a596eb6278d..2a8594cf76e 100644 --- a/code/core/src/cli/build.ts +++ b/code/core/src/cli/build.ts @@ -1,6 +1,8 @@ -import { findPackage } from 'fd-package-json'; -import { buildStaticStandalone, withTelemetry } from '@storybook/core/core-server'; import { cache } from '@storybook/core/common'; + +import { buildStaticStandalone, withTelemetry } from '@storybook/core/core-server'; + +import { findPackage } from 'fd-package-json'; import invariant from 'tiny-invariant'; export const build = async (cliOptions: any) => { diff --git a/code/core/src/cli/detect.test.ts b/code/core/src/cli/detect.test.ts index cf21f8bc423..9a3041cecfa 100644 --- a/code/core/src/cli/detect.test.ts +++ b/code/core/src/cli/detect.test.ts @@ -1,9 +1,13 @@ -import { describe, afterEach, it, expect, vi } from 'vitest'; -import * as fs from 'fs'; +import { afterEach, describe, expect, it, vi } from 'vitest'; + +import type { JsPackageManager, PackageJsonWithMaybeDeps } from '@storybook/core/common'; + import { logger } from '@storybook/core/node-logger'; + +import * as fs from 'fs'; + import { detect, detectFrameworkPreset, detectLanguage } from './detect'; import { ProjectType, SupportedLanguage } from './project_types'; -import type { JsPackageManager, PackageJsonWithMaybeDeps } from '@storybook/core/common'; vi.mock('./helpers', () => ({ isNxProject: vi.fn(), diff --git a/code/core/src/cli/detect.ts b/code/core/src/cli/detect.ts index 83b90237aa9..1aef0ed2062 100644 --- a/code/core/src/cli/detect.ts +++ b/code/core/src/cli/detect.ts @@ -1,21 +1,24 @@ -import * as fs from 'fs'; -import { findUpSync } from 'find-up'; -import semver from 'semver'; +import { resolve } from 'node:path'; + +import type { JsPackageManager, PackageJsonWithMaybeDeps } from '@storybook/core/common'; +import { HandledError, commandLog } from '@storybook/core/common'; + import { logger } from '@storybook/core/node-logger'; -import { resolve } from 'node:path'; +import { findUpSync } from 'find-up'; +import * as fs from 'fs'; import prompts from 'prompts'; +import semver from 'semver'; + +import { isNxProject } from './helpers'; import type { TemplateConfiguration, TemplateMatcher } from './project_types'; import { + CoreBuilder, ProjectType, - supportedTemplates, SupportedLanguage, + supportedTemplates, unsupportedTemplate, - CoreBuilder, } from './project_types'; -import { isNxProject } from './helpers'; -import type { JsPackageManager, PackageJsonWithMaybeDeps } from '@storybook/core/common'; -import { commandLog, HandledError } from '@storybook/core/common'; const viteConfigFiles = ['vite.config.ts', 'vite.config.js', 'vite.config.mjs']; const webpackConfigFiles = ['webpack.config.js']; diff --git a/code/core/src/cli/dev.ts b/code/core/src/cli/dev.ts index f8c7ecbcd11..6d05f140fa3 100644 --- a/code/core/src/cli/dev.ts +++ b/code/core/src/cli/dev.ts @@ -1,10 +1,12 @@ -import { dedent } from 'ts-dedent'; -import { findPackage } from 'fd-package-json'; -import { logger, instance as npmLog } from '@storybook/core/node-logger'; -import { buildDevStandalone, withTelemetry } from '@storybook/core/core-server'; import { cache } from '@storybook/core/common'; import type { CLIOptions } from '@storybook/core/types'; + +import { buildDevStandalone, withTelemetry } from '@storybook/core/core-server'; +import { logger, instance as npmLog } from '@storybook/core/node-logger'; + +import { findPackage } from 'fd-package-json'; import invariant from 'tiny-invariant'; +import { dedent } from 'ts-dedent'; function printError(error: any) { // this is a weird bugfix, somehow 'node-pre-gyp' is polluting the npmLog header diff --git a/code/core/src/cli/dirs.ts b/code/core/src/cli/dirs.ts index 88515e6b668..37fcca50bfc 100644 --- a/code/core/src/cli/dirs.ts +++ b/code/core/src/cli/dirs.ts @@ -1,14 +1,14 @@ -import { dirname, join } from 'path'; +import type { JsPackageManager } from '@storybook/core/common'; +import { temporaryDirectory, versions } from '@storybook/core/common'; +import type { SupportedFrameworks } from '@storybook/core/types'; import downloadTarball from '@ndelangen/get-tarball'; import getNpmTarballUrl from 'get-npm-tarball-url'; - +import { dirname, join } from 'path'; import invariant from 'tiny-invariant'; + import { externalFrameworks } from './project_types'; import type { SupportedRenderers } from './project_types'; -import type { JsPackageManager } from '@storybook/core/common'; -import { temporaryDirectory, versions } from '@storybook/core/common'; -import type { SupportedFrameworks } from '@storybook/core/types'; const resolveUsingBranchInstall = async (packageManager: JsPackageManager, request: string) => { const tempDirectory = await temporaryDirectory(); diff --git a/code/core/src/cli/eslintPlugin.test.ts b/code/core/src/cli/eslintPlugin.test.ts index cb428df7d27..4752f8734eb 100644 --- a/code/core/src/cli/eslintPlugin.test.ts +++ b/code/core/src/cli/eslintPlugin.test.ts @@ -1,4 +1,5 @@ -import { describe, it, expect } from 'vitest'; +import { describe, expect, it } from 'vitest'; + import { normalizeExtends } from './eslintPlugin'; describe('normalizeExtends', () => { diff --git a/code/core/src/cli/eslintPlugin.ts b/code/core/src/cli/eslintPlugin.ts index 75fcaa96bb4..3e37b41b526 100644 --- a/code/core/src/cli/eslintPlugin.ts +++ b/code/core/src/cli/eslintPlugin.ts @@ -1,13 +1,15 @@ -import fse, { readFile, readJson, writeJson } from 'fs-extra'; -import { dedent } from 'ts-dedent'; -import detectIndent from 'detect-indent'; -import prompts from 'prompts'; -import chalk from 'chalk'; +import fs from 'node:fs'; -import { readConfig, writeConfig } from '@storybook/core/csf-tools'; import type { JsPackageManager } from '@storybook/core/common'; import { paddedLog } from '@storybook/core/common'; -import fs from 'node:fs'; + +import { readConfig, writeConfig } from '@storybook/core/csf-tools'; + +import chalk from 'chalk'; +import detectIndent from 'detect-indent'; +import { readFile, readJson, writeJson } from 'fs-extra'; +import prompts from 'prompts'; +import { dedent } from 'ts-dedent'; export const SUPPORTED_ESLINT_EXTENSIONS = ['js', 'cjs', 'json']; const UNSUPPORTED_ESLINT_EXTENSIONS = ['yaml', 'yml']; diff --git a/code/core/src/cli/helpers.test.ts b/code/core/src/cli/helpers.test.ts index 9464c8551a9..71661e5cafa 100644 --- a/code/core/src/cli/helpers.test.ts +++ b/code/core/src/cli/helpers.test.ts @@ -1,10 +1,12 @@ -import { describe, beforeEach, it, expect, vi } from 'vitest'; -import fse from 'fs-extra'; +import { beforeEach, describe, expect, it, vi } from 'vitest'; + +import type { JsPackageManager } from '@storybook/core/common'; +import fse from 'fs-extra'; import { sep } from 'path'; -import * as helpers from './helpers'; + import { IS_WINDOWS } from '../../../vitest.helpers'; -import type { JsPackageManager } from '@storybook/core/common'; +import * as helpers from './helpers'; import type { SupportedRenderers } from './project_types'; import { SupportedLanguage } from './project_types'; diff --git a/code/core/src/cli/helpers.ts b/code/core/src/cli/helpers.ts index e0af5f76af9..c1dfae542c0 100644 --- a/code/core/src/cli/helpers.ts +++ b/code/core/src/cli/helpers.ts @@ -1,22 +1,23 @@ +import { + frameworkToRenderer as CoreFrameworkToRenderer, + type JsPackageManager, + type PackageJson, + type PackageJsonWithDepsAndDevDeps, +} from '@storybook/core/common'; +import { versions as storybookMonorepoPackages } from '@storybook/core/common'; +import type { SupportedFrameworks, SupportedRenderers } from '@storybook/core/types'; + import chalk from 'chalk'; +import { findUpSync } from 'find-up'; import fs from 'fs'; import fse from 'fs-extra'; import path, { join } from 'path'; import { coerce, satisfies } from 'semver'; import stripJsonComments from 'strip-json-comments'; - -import { findUpSync } from 'find-up'; import invariant from 'tiny-invariant'; + import { getRendererDir } from './dirs'; -import { - type JsPackageManager, - type PackageJson, - type PackageJsonWithDepsAndDevDeps, - frameworkToRenderer as CoreFrameworkToRenderer, -} from '@storybook/core/common'; -import type { SupportedFrameworks, SupportedRenderers } from '@storybook/core/types'; import { CoreBuilder, SupportedLanguage } from './project_types'; -import { versions as storybookMonorepoPackages } from '@storybook/core/common'; const logger = console; diff --git a/code/core/src/cli/project_types.test.ts b/code/core/src/cli/project_types.test.ts index 95bca595dfc..c5b6e4adc82 100644 --- a/code/core/src/cli/project_types.test.ts +++ b/code/core/src/cli/project_types.test.ts @@ -1,5 +1,6 @@ -import { describe, it, expect } from 'vitest'; -import { installableProjectTypes, SUPPORTED_RENDERERS } from './project_types'; +import { describe, expect, it } from 'vitest'; + +import { SUPPORTED_RENDERERS, installableProjectTypes } from './project_types'; describe('installableProjectTypes should have an entry for the supported framework', () => { SUPPORTED_RENDERERS.forEach((framework) => { diff --git a/code/core/src/cli/project_types.ts b/code/core/src/cli/project_types.ts index b0f6c889c7c..1efeba6cc52 100644 --- a/code/core/src/cli/project_types.ts +++ b/code/core/src/cli/project_types.ts @@ -1,9 +1,10 @@ -import { minVersion, validRange } from 'semver'; import type { - SupportedFrameworks, SupportedRenderers as CoreSupportedFrameworks, + SupportedFrameworks, } from '@storybook/core/types'; +import { minVersion, validRange } from 'semver'; + function eqMajor(versionRange: string, major: number) { // Uses validRange to avoid a throw from minVersion if an invalid range gets passed if (validRange(versionRange)) { diff --git a/code/core/src/client-logger/index.test.ts b/code/core/src/client-logger/index.test.ts index 8574cef5066..c46f70f2fd0 100644 --- a/code/core/src/client-logger/index.test.ts +++ b/code/core/src/client-logger/index.test.ts @@ -1,4 +1,5 @@ -import { describe, beforeEach, afterAll, it, expect, vi } from 'vitest'; +import { afterAll, beforeEach, describe, expect, it, vi } from 'vitest'; + import { logger } from '.'; vi.mock('@storybook/global', () => ({ global: { ...global, LOGLEVEL: 'debug' } })); diff --git a/code/core/src/common/config.test.ts b/code/core/src/common/config.test.ts index 3e75aeb0396..de70dd7fe9a 100644 --- a/code/core/src/common/config.test.ts +++ b/code/core/src/common/config.test.ts @@ -1,4 +1,5 @@ -import { describe, it, expect } from 'vitest'; +import { describe, expect, it } from 'vitest'; + import { filterPresetsConfig } from './presets'; describe('filterPresetsConfig', () => { diff --git a/code/core/src/common/index.ts b/code/core/src/common/index.ts index d16c9118ae8..107ce9b6d98 100644 --- a/code/core/src/common/index.ts +++ b/code/core/src/common/index.ts @@ -1,3 +1,5 @@ +import versions from './versions'; + /// export * from './presets'; @@ -40,7 +42,6 @@ export * from './utils/strip-abs-node-modules-path'; export * from './utils/formatter'; export * from './js-package-manager'; -import versions from './versions'; export { versions }; export { createFileSystemCache } from './utils/file-cache'; diff --git a/code/core/src/common/js-package-manager/JsPackageManager.ts b/code/core/src/common/js-package-manager/JsPackageManager.ts index 5a18b572f24..6f1b6f6b79d 100644 --- a/code/core/src/common/js-package-manager/JsPackageManager.ts +++ b/code/core/src/common/js-package-manager/JsPackageManager.ts @@ -1,17 +1,18 @@ +import { existsSync, readFileSync } from 'node:fs'; +import { readFile, writeFile } from 'node:fs/promises'; +import path from 'node:path'; + import chalk from 'chalk'; -import { gt, satisfies } from 'semver'; import type { CommonOptions } from 'execa'; import { execaCommand, execaCommandSync } from 'execa'; -import path from 'node:path'; - -import { dedent } from 'ts-dedent'; -import { existsSync, readFileSync } from 'node:fs'; -import { readFile, writeFile } from 'node:fs/promises'; +import { gt, satisfies } from 'semver'; import invariant from 'tiny-invariant'; -import type { PackageJson, PackageJsonWithDepsAndDevDeps } from './PackageJson'; +import { dedent } from 'ts-dedent'; + +import { HandledError } from '../utils/HandledError'; import storybookPackagesVersions from '../versions'; +import type { PackageJson, PackageJsonWithDepsAndDevDeps } from './PackageJson'; import type { InstallationMetadata } from './types'; -import { HandledError } from '../utils/HandledError'; const logger = console; diff --git a/code/core/src/common/js-package-manager/JsPackageManagerFactory.test.ts b/code/core/src/common/js-package-manager/JsPackageManagerFactory.test.ts index 0a5e6e62673..0a3a2a81341 100644 --- a/code/core/src/common/js-package-manager/JsPackageManagerFactory.test.ts +++ b/code/core/src/common/js-package-manager/JsPackageManagerFactory.test.ts @@ -1,7 +1,10 @@ -import { describe, beforeEach, it, expect, vi } from 'vitest'; +import path from 'node:path'; + +import { beforeEach, describe, expect, it, vi } from 'vitest'; + import { sync as spawnSync } from 'cross-spawn'; import { findUpSync } from 'find-up'; -import path from 'node:path'; + import { JsPackageManagerFactory } from './JsPackageManagerFactory'; import { NPMProxy } from './NPMProxy'; import { PNPMProxy } from './PNPMProxy'; diff --git a/code/core/src/common/js-package-manager/JsPackageManagerFactory.ts b/code/core/src/common/js-package-manager/JsPackageManagerFactory.ts index badd60ea6cf..c6ad2162640 100644 --- a/code/core/src/common/js-package-manager/JsPackageManagerFactory.ts +++ b/code/core/src/common/js-package-manager/JsPackageManagerFactory.ts @@ -1,14 +1,13 @@ import path, { parse, relative } from 'node:path'; + import { sync as spawnSync } from 'cross-spawn'; import { findUpSync } from 'find-up'; +import type { JsPackageManager, PackageManagerName } from './JsPackageManager'; import { NPMProxy } from './NPMProxy'; import { PNPMProxy } from './PNPMProxy'; - -import type { JsPackageManager, PackageManagerName } from './JsPackageManager'; - -import { Yarn2Proxy } from './Yarn2Proxy'; import { Yarn1Proxy } from './Yarn1Proxy'; +import { Yarn2Proxy } from './Yarn2Proxy'; const NPM_LOCKFILE = 'package-lock.json'; const PNPM_LOCKFILE = 'pnpm-lock.yaml'; diff --git a/code/core/src/common/js-package-manager/NPMProxy.test.ts b/code/core/src/common/js-package-manager/NPMProxy.test.ts index 9c88ea60af4..4a783017d91 100644 --- a/code/core/src/common/js-package-manager/NPMProxy.test.ts +++ b/code/core/src/common/js-package-manager/NPMProxy.test.ts @@ -1,4 +1,5 @@ -import { describe, beforeEach, it, expect, vi } from 'vitest'; +import { beforeEach, describe, expect, it, vi } from 'vitest'; + import { NPMProxy } from './NPMProxy'; // mock createLogStream diff --git a/code/core/src/common/js-package-manager/NPMProxy.ts b/code/core/src/common/js-package-manager/NPMProxy.ts index 3cdadeb17ff..24ad9cfd794 100644 --- a/code/core/src/common/js-package-manager/NPMProxy.ts +++ b/code/core/src/common/js-package-manager/NPMProxy.ts @@ -1,16 +1,18 @@ -import sort from 'semver/functions/sort.js'; -import { platform } from 'os'; -import dedent from 'ts-dedent'; -import { findUpSync } from 'find-up'; import { existsSync, readFileSync } from 'node:fs'; import path from 'node:path'; + import { logger } from '@storybook/core/node-logger'; import { FindPackageVersionsError } from '@storybook/core/server-errors'; +import { findUpSync } from 'find-up'; +import { platform } from 'os'; +import sort from 'semver/functions/sort.js'; +import dedent from 'ts-dedent'; + +import { createLogStream } from '../utils/cli'; import { JsPackageManager } from './JsPackageManager'; import type { PackageJson } from './PackageJson'; import type { InstallationMetadata, PackageMetadata } from './types'; -import { createLogStream } from '../utils/cli'; type NpmDependency = { version: string; diff --git a/code/core/src/common/js-package-manager/PNPMProxy.test.ts b/code/core/src/common/js-package-manager/PNPMProxy.test.ts index cca2ca4ea36..f869dcb8181 100644 --- a/code/core/src/common/js-package-manager/PNPMProxy.test.ts +++ b/code/core/src/common/js-package-manager/PNPMProxy.test.ts @@ -1,4 +1,5 @@ -import { describe, beforeEach, it, expect, vi } from 'vitest'; +import { beforeEach, describe, expect, it, vi } from 'vitest'; + import { PNPMProxy } from './PNPMProxy'; describe('PNPM Proxy', () => { diff --git a/code/core/src/common/js-package-manager/PNPMProxy.ts b/code/core/src/common/js-package-manager/PNPMProxy.ts index 652310bf87b..d04f78a71b0 100644 --- a/code/core/src/common/js-package-manager/PNPMProxy.ts +++ b/code/core/src/common/js-package-manager/PNPMProxy.ts @@ -1,14 +1,16 @@ -import { pathExistsSync } from 'fs-extra'; -import dedent from 'ts-dedent'; import { existsSync, readFileSync } from 'node:fs'; -import { findUpSync } from 'find-up'; import path from 'node:path'; + import { FindPackageVersionsError } from '@storybook/core/server-errors'; +import { findUpSync } from 'find-up'; +import { pathExistsSync } from 'fs-extra'; +import dedent from 'ts-dedent'; + +import { createLogStream } from '../utils/cli'; import { JsPackageManager } from './JsPackageManager'; import type { PackageJson } from './PackageJson'; import type { InstallationMetadata, PackageMetadata } from './types'; -import { createLogStream } from '../utils/cli'; type PnpmDependency = { from: string; diff --git a/code/core/src/common/js-package-manager/Yarn1Proxy.test.ts b/code/core/src/common/js-package-manager/Yarn1Proxy.test.ts index c20f496fed8..69bbc046aaf 100644 --- a/code/core/src/common/js-package-manager/Yarn1Proxy.test.ts +++ b/code/core/src/common/js-package-manager/Yarn1Proxy.test.ts @@ -1,5 +1,7 @@ -import { describe, beforeEach, it, expect, vi } from 'vitest'; +import { beforeEach, describe, expect, it, vi } from 'vitest'; + import { dedent } from 'ts-dedent'; + import { Yarn1Proxy } from './Yarn1Proxy'; describe('Yarn 1 Proxy', () => { diff --git a/code/core/src/common/js-package-manager/Yarn1Proxy.ts b/code/core/src/common/js-package-manager/Yarn1Proxy.ts index a6387bc3417..97ca04b6364 100644 --- a/code/core/src/common/js-package-manager/Yarn1Proxy.ts +++ b/code/core/src/common/js-package-manager/Yarn1Proxy.ts @@ -1,9 +1,11 @@ import { existsSync, readFileSync } from 'node:fs'; -import dedent from 'ts-dedent'; -import { findUpSync } from 'find-up'; import path from 'node:path'; + import { FindPackageVersionsError } from '@storybook/core/server-errors'; +import { findUpSync } from 'find-up'; +import dedent from 'ts-dedent'; + import { createLogStream } from '../utils/cli'; import { JsPackageManager } from './JsPackageManager'; import type { PackageJson } from './PackageJson'; diff --git a/code/core/src/common/js-package-manager/Yarn2Proxy.test.ts b/code/core/src/common/js-package-manager/Yarn2Proxy.test.ts index c7265e12f18..fad7e829d18 100644 --- a/code/core/src/common/js-package-manager/Yarn2Proxy.test.ts +++ b/code/core/src/common/js-package-manager/Yarn2Proxy.test.ts @@ -1,4 +1,5 @@ -import { describe, beforeEach, it, expect, vi } from 'vitest'; +import { beforeEach, describe, expect, it, vi } from 'vitest'; + import { Yarn2Proxy } from './Yarn2Proxy'; describe('Yarn 2 Proxy', () => { diff --git a/code/core/src/common/js-package-manager/Yarn2Proxy.ts b/code/core/src/common/js-package-manager/Yarn2Proxy.ts index 5036afed434..cf81284b1c2 100644 --- a/code/core/src/common/js-package-manager/Yarn2Proxy.ts +++ b/code/core/src/common/js-package-manager/Yarn2Proxy.ts @@ -1,10 +1,12 @@ -import { dedent } from 'ts-dedent'; -import { findUpSync } from 'find-up'; import { existsSync, readFileSync } from 'node:fs'; import path from 'node:path'; + +import { FindPackageVersionsError } from '@storybook/core/server-errors'; + import { PosixFS, VirtualFS, ZipOpenFS } from '@yarnpkg/fslib'; import { getLibzipSync } from '@yarnpkg/libzip'; -import { FindPackageVersionsError } from '@storybook/core/server-errors'; +import { findUpSync } from 'find-up'; +import { dedent } from 'ts-dedent'; import { createLogStream } from '../utils/cli'; import { JsPackageManager } from './JsPackageManager'; diff --git a/code/core/src/common/presets.test.ts b/code/core/src/common/presets.test.ts index d7a847949f5..7c22e514fc2 100644 --- a/code/core/src/common/presets.test.ts +++ b/code/core/src/common/presets.test.ts @@ -1,8 +1,12 @@ -import mockRequire from 'mock-require'; -import { describe, beforeEach, afterEach, it, expect, vi } from 'vitest'; import path from 'node:path'; + +import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'; + import { logger } from '@storybook/core/node-logger'; -import { getPresets, resolveAddonName, loadPreset } from './presets'; + +import mockRequire from 'mock-require'; + +import { getPresets, loadPreset, resolveAddonName } from './presets'; function wrapPreset(basePresets: any): { babel: Function; webpack: Function } { return { diff --git a/code/core/src/common/presets.ts b/code/core/src/common/presets.ts index 593d6005119..5651aa3e6a1 100644 --- a/code/core/src/common/presets.ts +++ b/code/core/src/common/presets.ts @@ -1,11 +1,5 @@ -import { dedent } from 'ts-dedent'; -import { logger } from '@storybook/core/node-logger'; import { join, parse } from 'node:path'; -import { CriticalPresetLoadError } from '@storybook/core/server-errors'; -import { loadCustomPresets } from './utils/load-custom-presets'; -import { safeResolve, safeResolveFrom } from './utils/safeResolve'; -import { interopRequireDefault } from './utils/interpret-require'; -import { stripAbsNodeModulesPath } from './utils/strip-abs-node-modules-path'; + import type { BuilderOptions, CLIOptions, @@ -18,6 +12,16 @@ import type { StorybookConfigRaw, } from '@storybook/core/types'; +import { logger } from '@storybook/core/node-logger'; +import { CriticalPresetLoadError } from '@storybook/core/server-errors'; + +import { dedent } from 'ts-dedent'; + +import { interopRequireDefault } from './utils/interpret-require'; +import { loadCustomPresets } from './utils/load-custom-presets'; +import { safeResolve, safeResolveFrom } from './utils/safeResolve'; +import { stripAbsNodeModulesPath } from './utils/strip-abs-node-modules-path'; + type InterPresetOptions = Omit< CLIOptions & LoadOptions & diff --git a/code/core/src/common/utils/__tests__/check-addon-order.test.ts b/code/core/src/common/utils/__tests__/check-addon-order.test.ts index 9b22f83b98f..c9f67ffd363 100644 --- a/code/core/src/common/utils/__tests__/check-addon-order.test.ts +++ b/code/core/src/common/utils/__tests__/check-addon-order.test.ts @@ -1,10 +1,13 @@ -import { afterEach, it, expect, vi, describe } from 'vitest'; -import { logger } from '@storybook/core/node-logger'; +import { afterEach, describe, expect, it, vi } from 'vitest'; + import type { CoreCommon_AddonEntry, CoreCommon_AddonInfo, CoreCommon_OptionsEntry, } from '@storybook/core/types'; + +import { logger } from '@storybook/core/node-logger'; + import { checkAddonOrder } from '../check-addon-order'; const configFile = './main.js'; diff --git a/code/core/src/common/utils/__tests__/interpret-files.test.ts b/code/core/src/common/utils/__tests__/interpret-files.test.ts index fff12806dfb..aae6c0bc7c8 100644 --- a/code/core/src/common/utils/__tests__/interpret-files.test.ts +++ b/code/core/src/common/utils/__tests__/interpret-files.test.ts @@ -1,5 +1,7 @@ -import { describe, afterEach, it, expect } from 'vitest'; +import { afterEach, describe, expect, it } from 'vitest'; + import mock from 'mock-fs'; + import { getInterpretedFile } from '../interpret-files'; describe('interpret-files', () => { diff --git a/code/core/src/common/utils/__tests__/normalize-stories.test.ts b/code/core/src/common/utils/__tests__/normalize-stories.test.ts index d16479ee6e7..26e5f1bcc3c 100644 --- a/code/core/src/common/utils/__tests__/normalize-stories.test.ts +++ b/code/core/src/common/utils/__tests__/normalize-stories.test.ts @@ -1,8 +1,10 @@ /// ; -import { describe, it, expect, vi } from 'vitest'; import { sep } from 'node:path'; +import { describe, expect, it, vi } from 'vitest'; + import { InvalidStoriesEntryError } from '@storybook/core/server-errors'; + import { getDirectoryFromWorkingDir, normalizeStories, diff --git a/code/core/src/common/utils/__tests__/paths.test.ts b/code/core/src/common/utils/__tests__/paths.test.ts index 71b6b2a1efa..bef3959dfcb 100644 --- a/code/core/src/common/utils/__tests__/paths.test.ts +++ b/code/core/src/common/utils/__tests__/paths.test.ts @@ -1,8 +1,11 @@ -import { describe, it, expect, vi } from 'vitest'; import path from 'node:path'; + +import { describe, expect, it, vi } from 'vitest'; + import { findUpSync } from 'find-up'; import slash from 'slash'; -import { normalizeStoryPath, getProjectRoot } from '../paths'; + +import { getProjectRoot, normalizeStoryPath } from '../paths'; vi.mock('find-up'); diff --git a/code/core/src/common/utils/__tests__/template.test.ts b/code/core/src/common/utils/__tests__/template.test.ts index 53a43e84909..d3b7567ae65 100644 --- a/code/core/src/common/utils/__tests__/template.test.ts +++ b/code/core/src/common/utils/__tests__/template.test.ts @@ -1,8 +1,11 @@ -import { describe, beforeEach, afterEach, it, expect } from 'vitest'; -import mock from 'mock-fs'; -import { getPreviewHeadTemplate, getPreviewBodyTemplate } from '../template'; import { dirname } from 'node:path'; +import { afterEach, beforeEach, describe, expect, it } from 'vitest'; + +import mock from 'mock-fs'; + +import { getPreviewBodyTemplate, getPreviewHeadTemplate } from '../template'; + const HEAD_HTML_CONTENTS = ''; const BASE_HTML_CONTENTS = ''; diff --git a/code/core/src/common/utils/cli.test.ts b/code/core/src/common/utils/cli.test.ts index 47bcf7d19b3..eecfcc64888 100644 --- a/code/core/src/common/utils/cli.test.ts +++ b/code/core/src/common/utils/cli.test.ts @@ -1,4 +1,5 @@ -import { describe, it, expect } from 'vitest'; +import { describe, expect, it } from 'vitest'; + import { isCorePackage } from './cli'; describe('UTILS', () => { diff --git a/code/core/src/common/utils/cli.ts b/code/core/src/common/utils/cli.ts index 40a686df486..5061d81905c 100644 --- a/code/core/src/common/utils/cli.ts +++ b/code/core/src/common/utils/cli.ts @@ -1,12 +1,15 @@ -import type { WriteStream } from 'fs-extra'; -import { move, remove, writeFile, readFile, createWriteStream, mkdirSync } from 'fs-extra'; +import { realpath } from 'node:fs/promises'; +import os from 'node:os'; import { join } from 'node:path'; -import { rendererPackages } from './get-storybook-info'; + +import type { WriteStream } from 'fs-extra'; +import { createWriteStream, mkdirSync, move, readFile, remove, writeFile } from 'fs-extra'; +import { type MergeExclusive } from 'type-fest'; +import uniqueString from 'unique-string'; + import type { JsPackageManager } from '../js-package-manager'; import versions from '../versions'; -import uniqueString from 'unique-string'; -import os from 'node:os'; -import { realpath } from 'node:fs/promises'; +import { rendererPackages } from './get-storybook-info'; const tempDir = () => realpath(os.tmpdir()); @@ -18,8 +21,6 @@ export async function temporaryDirectory({ prefix = '' } = {}) { return directory; } -import { type MergeExclusive } from 'type-fest'; - export type FileOptions = MergeExclusive< { /** diff --git a/code/core/src/common/utils/envs.ts b/code/core/src/common/utils/envs.ts index 46401309cea..adf1297f686 100644 --- a/code/core/src/common/utils/envs.ts +++ b/code/core/src/common/utils/envs.ts @@ -1,6 +1,7 @@ // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore - Needed for Angular sandbox running without --no-link option. Do NOT convert to @ts-expect-error! import { getEnvironment } from 'lazy-universal-dotenv'; + import { nodePathsToArray } from './paths'; // Load environment variables starts with STORYBOOK_ to the client side. diff --git a/code/core/src/common/utils/formatter.test.ts b/code/core/src/common/utils/formatter.test.ts index 53dfbfb5148..647ada8b404 100644 --- a/code/core/src/common/utils/formatter.test.ts +++ b/code/core/src/common/utils/formatter.test.ts @@ -1,7 +1,9 @@ -import { formatFileContent } from './formatter'; -import { describe, it, expect, vi } from 'vitest'; import path from 'node:path'; +import { describe, expect, it, vi } from 'vitest'; + +import { formatFileContent } from './formatter'; + const mockPrettier = vi.hoisted(() => ({ resolveConfig: vi.fn(), format: vi.fn(), diff --git a/code/core/src/common/utils/get-framework-name.test.ts b/code/core/src/common/utils/get-framework-name.test.ts index 9f6a95ba19e..b0dba5027e0 100644 --- a/code/core/src/common/utils/get-framework-name.test.ts +++ b/code/core/src/common/utils/get-framework-name.test.ts @@ -1,4 +1,5 @@ import { describe, expect, it } from 'vitest'; + import { extractProperFrameworkName } from './get-framework-name'; describe('get-framework-name', () => { diff --git a/code/core/src/common/utils/get-framework-name.ts b/code/core/src/common/utils/get-framework-name.ts index 984de13b7d0..b4fcc57ee34 100644 --- a/code/core/src/common/utils/get-framework-name.ts +++ b/code/core/src/common/utils/get-framework-name.ts @@ -1,7 +1,9 @@ +import type { Options } from '@storybook/core/types'; + import { dedent } from 'ts-dedent'; + import { frameworkPackages } from './get-storybook-info'; import { normalizePath } from './normalize-path'; -import type { Options } from '@storybook/core/types'; /** * Framework can be a string or an object. This utility always returns the string name. diff --git a/code/core/src/common/utils/get-renderer-name.test.ts b/code/core/src/common/utils/get-renderer-name.test.ts index 09c31f36b4f..5ae7fef96f3 100644 --- a/code/core/src/common/utils/get-renderer-name.test.ts +++ b/code/core/src/common/utils/get-renderer-name.test.ts @@ -1,4 +1,5 @@ import { describe, expect, test } from 'vitest'; + import { extractProperRendererNameFromFramework } from './get-renderer-name'; describe('get-renderer-name', () => { diff --git a/code/core/src/common/utils/get-renderer-name.ts b/code/core/src/common/utils/get-renderer-name.ts index df138063236..867fa94f377 100644 --- a/code/core/src/common/utils/get-renderer-name.ts +++ b/code/core/src/common/utils/get-renderer-name.ts @@ -1,7 +1,8 @@ +import type { Options } from '@storybook/core/types'; + +import { frameworkToRenderer } from './framework-to-renderer'; import { extractProperFrameworkName, getFrameworkName } from './get-framework-name'; import { frameworkPackages } from './get-storybook-info'; -import { frameworkToRenderer } from './framework-to-renderer'; -import type { Options } from '@storybook/core/types'; /** * Render is set as a string on core. It must be set by the framework diff --git a/code/core/src/common/utils/get-storybook-configuration.test.ts b/code/core/src/common/utils/get-storybook-configuration.test.ts index aa821e38e59..1bb377f79d9 100644 --- a/code/core/src/common/utils/get-storybook-configuration.test.ts +++ b/code/core/src/common/utils/get-storybook-configuration.test.ts @@ -1,4 +1,5 @@ -import { describe, it, expect } from 'vitest'; +import { describe, expect, it } from 'vitest'; + import { getStorybookConfiguration } from './get-storybook-configuration'; describe('getStorybookConfiguration', () => { diff --git a/code/core/src/common/utils/get-storybook-info.ts b/code/core/src/common/utils/get-storybook-info.ts index b61f1fd4914..669b1b2c1d1 100644 --- a/code/core/src/common/utils/get-storybook-info.ts +++ b/code/core/src/common/utils/get-storybook-info.ts @@ -1,9 +1,12 @@ import path from 'node:path'; -import { pathExistsSync } from 'fs-extra'; -import { getStorybookConfiguration } from './get-storybook-configuration'; + import type { SupportedFrameworks } from '@storybook/core/types'; import type { CoreCommon_StorybookInfo, PackageJson } from '@storybook/core/types'; +import { pathExistsSync } from 'fs-extra'; + +import { getStorybookConfiguration } from './get-storybook-configuration'; + export const rendererPackages: Record = { '@storybook/react': 'react', '@storybook/vue3': 'vue3', diff --git a/code/core/src/common/utils/get-storybook-refs.ts b/code/core/src/common/utils/get-storybook-refs.ts index b24fde29dea..053ae17abc9 100644 --- a/code/core/src/common/utils/get-storybook-refs.ts +++ b/code/core/src/common/utils/get-storybook-refs.ts @@ -1,11 +1,13 @@ -import { readJSON } from 'fs-extra'; import { dirname, join } from 'node:path'; -import { findUp } from 'find-up'; -import resolveFrom from 'resolve-from'; -import { logger } from '@storybook/core/node-logger'; import type { Options, Ref } from '@storybook/core/types'; +import { logger } from '@storybook/core/node-logger'; + +import { findUp } from 'find-up'; +import { readJSON } from 'fs-extra'; +import resolveFrom from 'resolve-from'; + export const getAutoRefs = async (options: Options): Promise> => { const location = await findUp('package.json', { cwd: options.configDir }); if (!location) { diff --git a/code/core/src/common/utils/load-custom-presets.ts b/code/core/src/common/utils/load-custom-presets.ts index 16923ec1a6f..5d8a99ce4c8 100644 --- a/code/core/src/common/utils/load-custom-presets.ts +++ b/code/core/src/common/utils/load-custom-presets.ts @@ -1,7 +1,9 @@ import path from 'node:path'; + +import type { PresetConfig } from '@storybook/core/types'; + import { serverRequire, serverResolve } from './interpret-require'; import { validateConfigurationFiles } from './validate-configuration-files'; -import type { PresetConfig } from '@storybook/core/types'; export function loadCustomPresets({ configDir }: { configDir: string }): PresetConfig[] { validateConfigurationFiles(configDir); diff --git a/code/core/src/common/utils/load-main-config.ts b/code/core/src/common/utils/load-main-config.ts index 37d9789afcf..5a3e0925aed 100644 --- a/code/core/src/common/utils/load-main-config.ts +++ b/code/core/src/common/utils/load-main-config.ts @@ -1,9 +1,13 @@ import path, { relative } from 'node:path'; + +import type { StorybookConfig } from '@storybook/core/types'; + +import { MainFileESMOnlyImportError, MainFileEvaluationError } from '@storybook/core/server-errors'; + +import { readFile } from 'fs/promises'; + import { serverRequire, serverResolve } from './interpret-require'; import { validateConfigurationFiles } from './validate-configuration-files'; -import { readFile } from 'fs/promises'; -import { MainFileESMOnlyImportError, MainFileEvaluationError } from '@storybook/core/server-errors'; -import type { StorybookConfig } from '@storybook/core/types'; export async function loadMainConfig({ configDir = '.storybook', diff --git a/code/core/src/common/utils/load-manager-or-addons-file.ts b/code/core/src/common/utils/load-manager-or-addons-file.ts index 78c10958269..2ffe9e47670 100644 --- a/code/core/src/common/utils/load-manager-or-addons-file.ts +++ b/code/core/src/common/utils/load-manager-or-addons-file.ts @@ -1,5 +1,7 @@ import path from 'node:path'; + import { logger } from '@storybook/core/node-logger'; + import { dedent } from 'ts-dedent'; import { getInterpretedFile } from './interpret-files'; diff --git a/code/core/src/common/utils/load-preview-or-config-file.ts b/code/core/src/common/utils/load-preview-or-config-file.ts index a6af14cfae1..09124397f86 100644 --- a/code/core/src/common/utils/load-preview-or-config-file.ts +++ b/code/core/src/common/utils/load-preview-or-config-file.ts @@ -1,4 +1,5 @@ import path from 'node:path'; + import { dedent } from 'ts-dedent'; import { getInterpretedFile } from './interpret-files'; diff --git a/code/core/src/common/utils/normalize-path.test.ts b/code/core/src/common/utils/normalize-path.test.ts index b2688660b6e..41c5b1dbbf3 100644 --- a/code/core/src/common/utils/normalize-path.test.ts +++ b/code/core/src/common/utils/normalize-path.test.ts @@ -1,6 +1,7 @@ -import { normalizePath } from './normalize-path'; import { describe, expect, it } from 'vitest'; +import { normalizePath } from './normalize-path'; + describe('normalize-path', () => { it('should normalize paths', () => { expect(normalizePath('path/to/../file')).toBe('path/file'); diff --git a/code/core/src/common/utils/normalize-stories.ts b/code/core/src/common/utils/normalize-stories.ts index 44e2bb38f64..35361e17229 100644 --- a/code/core/src/common/utils/normalize-stories.ts +++ b/code/core/src/common/utils/normalize-stories.ts @@ -1,12 +1,15 @@ import { lstatSync } from 'node:fs'; import path from 'node:path'; + +import type { NormalizedStoriesSpecifier, StoriesEntry } from '@storybook/core/types'; + +import { InvalidStoriesEntryError } from '@storybook/core/server-errors'; + import * as pico from 'picomatch'; import slash from 'slash'; -import { InvalidStoriesEntryError } from '@storybook/core/server-errors'; -import { normalizeStoryPath } from './paths'; import { globToRegexp } from './glob-to-regexp'; -import type { NormalizedStoriesSpecifier, StoriesEntry } from '@storybook/core/types'; +import { normalizeStoryPath } from './paths'; const DEFAULT_TITLE_PREFIX = ''; const DEFAULT_FILES_PATTERN = '**/*.@(mdx|stories.@(js|jsx|mjs|ts|tsx))'; diff --git a/code/core/src/common/utils/notify-telemetry.ts b/code/core/src/common/utils/notify-telemetry.ts index 53b291b4b6a..bb39028dede 100644 --- a/code/core/src/common/utils/notify-telemetry.ts +++ b/code/core/src/common/utils/notify-telemetry.ts @@ -1,4 +1,5 @@ import chalk from 'chalk'; + import { cache } from './cache'; const TELEMETRY_KEY_NOTIFY_DATE = 'telemetry-notification-date'; diff --git a/code/core/src/common/utils/paths.ts b/code/core/src/common/utils/paths.ts index b2260be135f..e92d46d7804 100644 --- a/code/core/src/common/utils/paths.ts +++ b/code/core/src/common/utils/paths.ts @@ -1,4 +1,5 @@ import path from 'node:path'; + import { findUpSync } from 'find-up'; export const getProjectRoot = () => { diff --git a/code/core/src/common/utils/remove.ts b/code/core/src/common/utils/remove.ts index f20a9d9f66a..a1be0176cca 100644 --- a/code/core/src/common/utils/remove.ts +++ b/code/core/src/common/utils/remove.ts @@ -1,5 +1,7 @@ -import { dedent } from 'ts-dedent'; import { readConfig, writeConfig } from '@storybook/core/csf-tools'; + +import { dedent } from 'ts-dedent'; + import type { PackageManagerName } from '../js-package-manager'; import { JsPackageManagerFactory } from '../js-package-manager'; import { getStorybookInfo } from './get-storybook-info'; diff --git a/code/core/src/common/utils/resolve-path-in-sb-cache.ts b/code/core/src/common/utils/resolve-path-in-sb-cache.ts index 4ba6e762ba1..a7df27dc41a 100644 --- a/code/core/src/common/utils/resolve-path-in-sb-cache.ts +++ b/code/core/src/common/utils/resolve-path-in-sb-cache.ts @@ -1,4 +1,5 @@ import path from 'node:path'; + import findCacheDirectory from 'find-cache-dir'; /** diff --git a/code/core/src/common/utils/strip-abs-node-modules-path.ts b/code/core/src/common/utils/strip-abs-node-modules-path.ts index b3d83198f1e..cb0950715e4 100644 --- a/code/core/src/common/utils/strip-abs-node-modules-path.ts +++ b/code/core/src/common/utils/strip-abs-node-modules-path.ts @@ -1,4 +1,5 @@ import path from 'node:path'; + import slash from 'slash'; function normalizePath(id: string) { diff --git a/code/core/src/common/utils/template.ts b/code/core/src/common/utils/template.ts index 367ea32afe7..eb32545b7ea 100644 --- a/code/core/src/common/utils/template.ts +++ b/code/core/src/common/utils/template.ts @@ -1,5 +1,5 @@ -import { dirname, resolve } from 'node:path'; import { existsSync, readFileSync } from 'node:fs'; +import { dirname, resolve } from 'node:path'; const interpolate = (string: string, data: Record = {}) => Object.entries(data).reduce((acc, [k, v]) => acc.replace(new RegExp(`%${k}%`, 'g'), v), string); diff --git a/code/core/src/common/utils/validate-config.test.ts b/code/core/src/common/utils/validate-config.test.ts index d945f374002..891b5daa63f 100644 --- a/code/core/src/common/utils/validate-config.test.ts +++ b/code/core/src/common/utils/validate-config.test.ts @@ -1,4 +1,5 @@ -import { describe, afterEach, it, expect, vi } from 'vitest'; +import { afterEach, describe, expect, it, vi } from 'vitest'; + import { validateFrameworkName } from './validate-config'; describe('validateFrameworkName', () => { diff --git a/code/core/src/common/utils/validate-config.ts b/code/core/src/common/utils/validate-config.ts index 4ca2856d02b..221ea923552 100644 --- a/code/core/src/common/utils/validate-config.ts +++ b/code/core/src/common/utils/validate-config.ts @@ -1,9 +1,11 @@ import { join } from 'node:path'; + import { CouldNotEvaluateFrameworkError, - MissingFrameworkFieldError, InvalidFrameworkNameError, + MissingFrameworkFieldError, } from '@storybook/core/server-errors'; + import { frameworkPackages } from './get-storybook-info'; const renderers = ['html', 'preact', 'react', 'server', 'svelte', 'vue', 'vue3', 'web-components']; diff --git a/code/core/src/common/utils/validate-configuration-files.ts b/code/core/src/common/utils/validate-configuration-files.ts index f177bc84901..9bf6a8b68c0 100644 --- a/code/core/src/common/utils/validate-configuration-files.ts +++ b/code/core/src/common/utils/validate-configuration-files.ts @@ -1,11 +1,13 @@ -import { dedent } from 'ts-dedent'; -import { glob } from 'glob'; import path from 'node:path'; -import slash from 'slash'; + import { once } from '@storybook/core/node-logger'; +import { MainFileMissingError } from '@storybook/core/server-errors'; + +import { glob } from 'glob'; +import slash from 'slash'; +import { dedent } from 'ts-dedent'; import { boost } from './interpret-files'; -import { MainFileMissingError } from '@storybook/core/server-errors'; export async function validateConfigurationFiles(configDir: string) { const extensionsPattern = `{${Array.from(boost).join(',')}}`; diff --git a/code/core/src/components/components/ActionBar/ActionBar.stories.tsx b/code/core/src/components/components/ActionBar/ActionBar.stories.tsx index 48fa2d56f47..d5598a36ec1 100644 --- a/code/core/src/components/components/ActionBar/ActionBar.stories.tsx +++ b/code/core/src/components/components/ActionBar/ActionBar.stories.tsx @@ -1,5 +1,6 @@ import type { ReactNode } from 'react'; import React from 'react'; + import { action } from '@storybook/addon-actions'; import { ActionBar } from './ActionBar'; diff --git a/code/core/src/components/components/Badge/Badge.stories.tsx b/code/core/src/components/components/Badge/Badge.stories.tsx index 974dc64f8be..4f51422c0f0 100644 --- a/code/core/src/components/components/Badge/Badge.stories.tsx +++ b/code/core/src/components/components/Badge/Badge.stories.tsx @@ -1,4 +1,5 @@ import type { Meta, StoryObj } from '@storybook/react'; + import { Badge } from './Badge'; const meta = { diff --git a/code/core/src/components/components/Badge/Badge.tsx b/code/core/src/components/components/Badge/Badge.tsx index f5e111cd4c6..a76cbd1121c 100644 --- a/code/core/src/components/components/Badge/Badge.tsx +++ b/code/core/src/components/components/Badge/Badge.tsx @@ -1,5 +1,7 @@ import React from 'react'; + import { styled } from '@storybook/core/theming'; + import { transparentize } from 'polished'; const BadgeWrapper = styled.div( diff --git a/code/core/src/components/components/Button/Button.deprecated.stories.tsx b/code/core/src/components/components/Button/Button.deprecated.stories.tsx index 009ea9627ab..ee10af77e39 100644 --- a/code/core/src/components/components/Button/Button.deprecated.stories.tsx +++ b/code/core/src/components/components/Button/Button.deprecated.stories.tsx @@ -1,8 +1,10 @@ -import type { Meta, StoryObj } from '@storybook/react'; import React from 'react'; + import { LinkIcon } from '@storybook/icons'; -import { Button } from './Button'; +import type { Meta, StoryObj } from '@storybook/react'; + import { Form } from '../form'; +import { Button } from './Button'; const meta: Meta = { title: 'Button (Deprecated)', diff --git a/code/core/src/components/components/Button/Button.stories.tsx b/code/core/src/components/components/Button/Button.stories.tsx index a74ce9e308a..93407ce8cc8 100644 --- a/code/core/src/components/components/Button/Button.stories.tsx +++ b/code/core/src/components/components/Button/Button.stories.tsx @@ -1,7 +1,9 @@ -import type { Meta, StoryObj } from '@storybook/react'; import type { ReactNode } from 'react'; import React from 'react'; + import { FaceHappyIcon } from '@storybook/icons'; +import type { Meta, StoryObj } from '@storybook/react'; + import { Button } from './Button'; const meta = { diff --git a/code/core/src/components/components/Button/Button.tsx b/code/core/src/components/components/Button/Button.tsx index 5c9eb88b693..4e91549a987 100644 --- a/code/core/src/components/components/Button/Button.tsx +++ b/code/core/src/components/components/Button/Button.tsx @@ -1,10 +1,13 @@ import type { ButtonHTMLAttributes, SyntheticEvent } from 'react'; import React, { forwardRef, useEffect, useState } from 'react'; + import { isPropValid, styled } from '@storybook/core/theming'; -import { darken, lighten, rgba, transparentize } from 'polished'; -import { Slot } from '@radix-ui/react-slot'; + import { deprecate } from '@storybook/core/client-logger'; +import { Slot } from '@radix-ui/react-slot'; +import { darken, lighten, rgba, transparentize } from 'polished'; + export interface ButtonProps extends ButtonHTMLAttributes { asChild?: boolean; size?: 'small' | 'medium'; diff --git a/code/core/src/components/components/ErrorFormatter/ErrorFormatter.stories.tsx b/code/core/src/components/components/ErrorFormatter/ErrorFormatter.stories.tsx index 9038928d27a..3ffc4e68381 100644 --- a/code/core/src/components/components/ErrorFormatter/ErrorFormatter.stories.tsx +++ b/code/core/src/components/components/ErrorFormatter/ErrorFormatter.stories.tsx @@ -1,5 +1,7 @@ import React from 'react'; -import type { StoryObj, Meta } from '@storybook/react'; + +import type { Meta, StoryObj } from '@storybook/react'; + import { dedent } from 'ts-dedent'; import { ErrorFormatter } from './ErrorFormatter'; diff --git a/code/core/src/components/components/ErrorFormatter/ErrorFormatter.tsx b/code/core/src/components/components/ErrorFormatter/ErrorFormatter.tsx index 422d0a0ff5a..b33a4c2f404 100644 --- a/code/core/src/components/components/ErrorFormatter/ErrorFormatter.tsx +++ b/code/core/src/components/components/ErrorFormatter/ErrorFormatter.tsx @@ -1,7 +1,7 @@ -import { global } from '@storybook/global'; - import React, { Fragment } from 'react'; + import { styled } from '@storybook/core/theming'; +import { global } from '@storybook/global'; const { document } = global; diff --git a/code/core/src/components/components/IconButton/IconButton.stories.tsx b/code/core/src/components/components/IconButton/IconButton.stories.tsx index c3341ac44c9..b7c8584cc15 100644 --- a/code/core/src/components/components/IconButton/IconButton.stories.tsx +++ b/code/core/src/components/components/IconButton/IconButton.stories.tsx @@ -1,6 +1,8 @@ -import type { Meta, StoryObj } from '@storybook/react'; import React from 'react'; + import { FaceHappyIcon } from '@storybook/icons'; +import type { Meta, StoryObj } from '@storybook/react'; + import { IconButton } from './IconButton'; const meta = { diff --git a/code/core/src/components/components/IconButton/IconButton.tsx b/code/core/src/components/components/IconButton/IconButton.tsx index 87088d342b5..31bf06902b3 100644 --- a/code/core/src/components/components/IconButton/IconButton.tsx +++ b/code/core/src/components/components/IconButton/IconButton.tsx @@ -1,4 +1,5 @@ import React, { forwardRef } from 'react'; + import type { ButtonProps } from '../Button/Button'; import { Button } from '../Button/Button'; diff --git a/code/core/src/components/components/Loader/Loader.stories.tsx b/code/core/src/components/components/Loader/Loader.stories.tsx index c4d7b5eb001..35b3f4cc14a 100644 --- a/code/core/src/components/components/Loader/Loader.stories.tsx +++ b/code/core/src/components/components/Loader/Loader.stories.tsx @@ -1,4 +1,5 @@ import React from 'react'; + import { Loader } from './Loader'; const withBackground = (storyFn: any) => ( diff --git a/code/core/src/components/components/Loader/Loader.tsx b/code/core/src/components/components/Loader/Loader.tsx index c29130e86b5..e30812e2728 100644 --- a/code/core/src/components/components/Loader/Loader.tsx +++ b/code/core/src/components/components/Loader/Loader.tsx @@ -1,9 +1,12 @@ -import { transparentize } from 'polished'; import React from 'react'; -import { styled, keyframes } from '@storybook/core/theming'; -import { rotate360 } from '../shared/animation'; + +import { keyframes, styled } from '@storybook/core/theming'; import { LightningOffIcon } from '@storybook/icons'; +import { transparentize } from 'polished'; + +import { rotate360 } from '../shared/animation'; + const LoaderWrapper = styled.div<{ size?: number }>(({ size = 32 }) => ({ borderRadius: '50%', cursor: 'progress', diff --git a/code/core/src/components/components/Modal/Modal.stories.tsx b/code/core/src/components/components/Modal/Modal.stories.tsx index 658683e6368..0793d24c8db 100644 --- a/code/core/src/components/components/Modal/Modal.stories.tsx +++ b/code/core/src/components/components/Modal/Modal.stories.tsx @@ -1,9 +1,10 @@ import React, { useState } from 'react'; + import type { Meta, StoryObj } from '@storybook/react'; -import { userEvent, within, expect } from '@storybook/test'; +import { expect, userEvent, within } from '@storybook/test'; -import { Modal } from './Modal'; import { Button } from '../Button/Button'; +import { Modal } from './Modal'; type Story = StoryObj; diff --git a/code/core/src/components/components/Modal/Modal.styled.tsx b/code/core/src/components/components/Modal/Modal.styled.tsx index 4636eea89d8..ca56fb05627 100644 --- a/code/core/src/components/components/Modal/Modal.styled.tsx +++ b/code/core/src/components/components/Modal/Modal.styled.tsx @@ -1,11 +1,13 @@ -import { keyframes, styled } from '@storybook/core/theming'; -import * as Dialog from '@radix-ui/react-dialog'; import type { ComponentProps } from 'react'; import React from 'react'; -import { IconButton } from '../IconButton/IconButton'; +import { keyframes, styled } from '@storybook/core/theming'; import { CrossIcon } from '@storybook/icons'; +import * as Dialog from '@radix-ui/react-dialog'; + +import { IconButton } from '../IconButton/IconButton'; + const fadeIn = keyframes({ from: { opacity: 0 }, to: { opacity: 1 }, diff --git a/code/core/src/components/components/Modal/Modal.tsx b/code/core/src/components/components/Modal/Modal.tsx index ad5ddaa85b4..a31f5aa838b 100644 --- a/code/core/src/components/components/Modal/Modal.tsx +++ b/code/core/src/components/components/Modal/Modal.tsx @@ -1,5 +1,7 @@ import React from 'react'; + import * as Dialog from '@radix-ui/react-dialog'; + import * as Components from './Modal.styled'; type ContentProps = React.ComponentProps; diff --git a/code/core/src/components/components/ScrollArea/ScrollArea.stories.tsx b/code/core/src/components/components/ScrollArea/ScrollArea.stories.tsx index b353f644cec..134088a66ed 100644 --- a/code/core/src/components/components/ScrollArea/ScrollArea.stories.tsx +++ b/code/core/src/components/components/ScrollArea/ScrollArea.stories.tsx @@ -1,6 +1,8 @@ import type { ReactElement } from 'react'; import React, { Fragment } from 'react'; + import { styled } from '@storybook/core/theming'; + import { ScrollArea } from './ScrollArea'; const Block = styled.span({ diff --git a/code/core/src/components/components/ScrollArea/ScrollArea.tsx b/code/core/src/components/components/ScrollArea/ScrollArea.tsx index 836294b51f3..aa1dff7b5c2 100644 --- a/code/core/src/components/components/ScrollArea/ScrollArea.tsx +++ b/code/core/src/components/components/ScrollArea/ScrollArea.tsx @@ -1,5 +1,7 @@ import React, { forwardRef } from 'react'; + import { styled } from '@storybook/core/theming'; + import * as ScrollAreaPrimitive from '@radix-ui/react-scroll-area'; export interface ScrollAreaProps { diff --git a/code/core/src/components/components/Zoom/Zoom.stories.tsx b/code/core/src/components/components/Zoom/Zoom.stories.tsx index f4632ece0e4..b480b78b192 100644 --- a/code/core/src/components/components/Zoom/Zoom.stories.tsx +++ b/code/core/src/components/components/Zoom/Zoom.stories.tsx @@ -1,5 +1,6 @@ import type { CSSProperties } from 'react'; import React, { useEffect, useState } from 'react'; + import { Zoom } from './Zoom'; export default { diff --git a/code/core/src/components/components/Zoom/ZoomElement.tsx b/code/core/src/components/components/Zoom/ZoomElement.tsx index e67a5f82181..7fb8068a3d6 100644 --- a/code/core/src/components/components/Zoom/ZoomElement.tsx +++ b/code/core/src/components/components/Zoom/ZoomElement.tsx @@ -1,8 +1,10 @@ import type { ReactElement } from 'react'; -import React, { useEffect, useRef, useState, useCallback } from 'react'; +import React, { useCallback, useEffect, useRef, useState } from 'react'; + +import { styled } from '@storybook/core/theming'; + import type { ResizeHandler } from 'use-resize-observer'; import useResizeObserver from 'use-resize-observer'; -import { styled } from '@storybook/core/theming'; const ZoomElementWrapper = styled.div<{ scale: number; elementHeight: number }>( ({ scale = 1, elementHeight }) => ({ diff --git a/code/core/src/components/components/Zoom/ZoomIFrame.tsx b/code/core/src/components/components/Zoom/ZoomIFrame.tsx index 370b2c4e22d..d166d3b96c2 100644 --- a/code/core/src/components/components/Zoom/ZoomIFrame.tsx +++ b/code/core/src/components/components/Zoom/ZoomIFrame.tsx @@ -1,4 +1,4 @@ -import type { RefObject, ReactElement } from 'react'; +import type { ReactElement, RefObject } from 'react'; import React, { Component } from 'react'; export type IZoomIFrameProps = { diff --git a/code/core/src/components/components/addon-panel/addon-panel.tsx b/code/core/src/components/components/addon-panel/addon-panel.tsx index 89e32c0b859..a34ac48e9ef 100644 --- a/code/core/src/components/components/addon-panel/addon-panel.tsx +++ b/code/core/src/components/components/addon-panel/addon-panel.tsx @@ -1,5 +1,5 @@ import type { ReactNode } from 'react'; -import React, { useRef, useEffect } from 'react'; +import React, { useEffect, useRef } from 'react'; const usePrevious = (value: any) => { const ref = useRef(); diff --git a/code/core/src/components/components/bar/bar.tsx b/code/core/src/components/components/bar/bar.tsx index 933cd65cb52..571d8401662 100644 --- a/code/core/src/components/components/bar/bar.tsx +++ b/code/core/src/components/components/bar/bar.tsx @@ -1,5 +1,6 @@ import type { ComponentProps } from 'react'; import React, { Children } from 'react'; + import { styled } from '@storybook/core/theming'; import type { ScrollAreaProps } from '../ScrollArea/ScrollArea'; diff --git a/code/core/src/components/components/bar/button.tsx b/code/core/src/components/components/bar/button.tsx index 2561f19fa2a..ef64b7e6064 100644 --- a/code/core/src/components/components/bar/button.tsx +++ b/code/core/src/components/components/bar/button.tsx @@ -2,13 +2,14 @@ import type { AnchorHTMLAttributes, ButtonHTMLAttributes, DetailedHTMLProps, - ForwardedRef, ForwardRefExoticComponent, + ForwardedRef, ReactElement, RefAttributes, } from 'react'; import React, { forwardRef } from 'react'; -import { styled, isPropValid } from '@storybook/core/theming'; + +import { isPropValid, styled } from '@storybook/core/theming'; interface ButtonProps extends DetailedHTMLProps, HTMLButtonElement> { diff --git a/code/core/src/components/components/bar/separator.tsx b/code/core/src/components/components/bar/separator.tsx index 039c4257ad6..dd06697e9af 100644 --- a/code/core/src/components/components/bar/separator.tsx +++ b/code/core/src/components/components/bar/separator.tsx @@ -1,4 +1,5 @@ import React, { Fragment } from 'react'; + import { styled } from '@storybook/core/theming'; export interface SeparatorProps { diff --git a/code/core/src/components/components/clipboard/ClipboardCode.tsx b/code/core/src/components/components/clipboard/ClipboardCode.tsx index 5954e466f62..bb9ffd1bf73 100644 --- a/code/core/src/components/components/clipboard/ClipboardCode.tsx +++ b/code/core/src/components/components/clipboard/ClipboardCode.tsx @@ -1,4 +1,5 @@ import React from 'react'; + import { color, styled, typography } from '@storybook/core/theming'; const Code = styled.pre` diff --git a/code/core/src/components/components/form/field/field.tsx b/code/core/src/components/components/form/field/field.tsx index 6ff17740691..ad43a138878 100644 --- a/code/core/src/components/components/form/field/field.tsx +++ b/code/core/src/components/components/form/field/field.tsx @@ -1,5 +1,6 @@ import type { ReactNode } from 'react'; import React from 'react'; + import { styled } from '@storybook/core/theming'; const Wrapper = styled.label(({ theme }) => ({ diff --git a/code/core/src/components/components/form/form.stories.tsx b/code/core/src/components/components/form/form.stories.tsx index 45470d60c84..a081368f6db 100644 --- a/code/core/src/components/components/form/form.stories.tsx +++ b/code/core/src/components/components/form/form.stories.tsx @@ -1,9 +1,11 @@ import React from 'react'; + import { styled } from '@storybook/core/theming'; + import { action } from '@storybook/addon-actions'; -import * as InputComponents from './input/input'; import { Field as FieldComponent } from './field/field'; +import * as InputComponents from './input/input'; const Flexed = styled(FieldComponent)({ display: 'flex' }); diff --git a/code/core/src/components/components/form/index.tsx b/code/core/src/components/components/form/index.tsx index 3407f342a86..4eba4e779f1 100644 --- a/code/core/src/components/components/form/index.tsx +++ b/code/core/src/components/components/form/index.tsx @@ -1,7 +1,8 @@ import { styled } from '@storybook/core/theming'; + +import { Button } from '../Button/Button'; import { Field } from './field/field'; import { Input, Select, Textarea } from './input/input'; -import { Button } from '../Button/Button'; export const Form = Object.assign( styled.form({ diff --git a/code/core/src/components/components/form/input/input.tsx b/code/core/src/components/components/form/input/input.tsx index 423da39326a..5e037b38fb4 100644 --- a/code/core/src/components/components/form/input/input.tsx +++ b/code/core/src/components/components/form/input/input.tsx @@ -1,5 +1,6 @@ import type { HTMLProps, SelectHTMLAttributes } from 'react'; import React, { forwardRef } from 'react'; + import type { CSSObject, StorybookTheme } from '@storybook/core/theming'; import { styled } from '@storybook/core/theming'; diff --git a/code/core/src/components/components/icon/icon.stories.tsx b/code/core/src/components/components/icon/icon.stories.tsx index 929319b346a..acafe6af442 100644 --- a/code/core/src/components/components/icon/icon.stories.tsx +++ b/code/core/src/components/components/icon/icon.stories.tsx @@ -1,6 +1,7 @@ import type { ComponentProps } from 'react'; import React from 'react'; -import { styled, css } from '@storybook/core/theming'; + +import { css, styled } from '@storybook/core/theming'; import type { IconType } from './icon'; import { Icons, icons } from './icon'; diff --git a/code/core/src/components/components/icon/icon.tsx b/code/core/src/components/components/icon/icon.tsx index ca80a070095..9e2a52405cd 100644 --- a/code/core/src/components/components/icon/icon.tsx +++ b/code/core/src/components/components/icon/icon.tsx @@ -1,8 +1,9 @@ import type { ComponentProps } from 'react'; import React, { memo } from 'react'; -import * as StorybookIcons from '@storybook/icons'; import { styled } from '@storybook/core/theming'; +import * as StorybookIcons from '@storybook/icons'; + import { deprecate, logger } from '@storybook/core/client-logger'; export type IconType = keyof typeof icons; diff --git a/code/core/src/components/components/placeholder/placeholder.stories.tsx b/code/core/src/components/components/placeholder/placeholder.stories.tsx index 4e7c5317244..071610125b7 100644 --- a/code/core/src/components/components/placeholder/placeholder.stories.tsx +++ b/code/core/src/components/components/placeholder/placeholder.stories.tsx @@ -1,7 +1,7 @@ import React, { Fragment } from 'react'; -import { Placeholder } from './placeholder'; import { Link } from '../typography/link/link'; +import { Placeholder } from './placeholder'; export default { component: Placeholder, diff --git a/code/core/src/components/components/placeholder/placeholder.tsx b/code/core/src/components/components/placeholder/placeholder.tsx index 68f1c026d4d..faa7d1df78b 100644 --- a/code/core/src/components/components/placeholder/placeholder.tsx +++ b/code/core/src/components/components/placeholder/placeholder.tsx @@ -1,4 +1,5 @@ import React, { Children } from 'react'; + import { styled } from '@storybook/core/theming'; const Title = styled.div(({ theme }) => ({ diff --git a/code/core/src/components/components/spaced/Spaced.stories.tsx b/code/core/src/components/components/spaced/Spaced.stories.tsx index 4c84f681166..3f342022e3b 100644 --- a/code/core/src/components/components/spaced/Spaced.stories.tsx +++ b/code/core/src/components/components/spaced/Spaced.stories.tsx @@ -1,5 +1,6 @@ import type { ComponentProps } from 'react'; import React from 'react'; + import { styled } from '@storybook/core/theming'; import { Spaced } from './Spaced'; diff --git a/code/core/src/components/components/spaced/Spaced.tsx b/code/core/src/components/components/spaced/Spaced.tsx index b4a79a91920..4c0afcfb9bf 100644 --- a/code/core/src/components/components/spaced/Spaced.tsx +++ b/code/core/src/components/components/spaced/Spaced.tsx @@ -1,5 +1,6 @@ import React from 'react'; -import { styled, ignoreSsrWarning } from '@storybook/core/theming'; + +import { ignoreSsrWarning, styled } from '@storybook/core/theming'; const toNumber = (input: any) => (typeof input === 'number' ? input : Number(input)); diff --git a/code/core/src/components/components/syntaxhighlighter/formatter.test.ts b/code/core/src/components/components/syntaxhighlighter/formatter.test.ts index 041cf2148ee..4c215c97715 100644 --- a/code/core/src/components/components/syntaxhighlighter/formatter.test.ts +++ b/code/core/src/components/components/syntaxhighlighter/formatter.test.ts @@ -1,4 +1,5 @@ -import { describe, it, expect } from 'vitest'; +import { describe, expect, it } from 'vitest'; + import { dedent } from 'ts-dedent'; import { formatter } from './formatter'; diff --git a/code/core/src/components/components/syntaxhighlighter/formatter.ts b/code/core/src/components/components/syntaxhighlighter/formatter.ts index c0ec2d7ad18..7ff96626bc0 100644 --- a/code/core/src/components/components/syntaxhighlighter/formatter.ts +++ b/code/core/src/components/components/syntaxhighlighter/formatter.ts @@ -1,8 +1,8 @@ import memoize from 'memoizerific'; - import prettierHtml from 'prettier/plugins/html'; import prettier from 'prettier/standalone'; import { dedent } from 'ts-dedent'; + import type { SyntaxHighlighterFormatTypes } from './syntaxhighlighter-types'; export const formatter = memoize(2)(async (type: SyntaxHighlighterFormatTypes, source: string) => { diff --git a/code/core/src/components/components/syntaxhighlighter/lazy-syntaxhighlighter.tsx b/code/core/src/components/components/syntaxhighlighter/lazy-syntaxhighlighter.tsx index 822034aca21..25aacedaafb 100644 --- a/code/core/src/components/components/syntaxhighlighter/lazy-syntaxhighlighter.tsx +++ b/code/core/src/components/components/syntaxhighlighter/lazy-syntaxhighlighter.tsx @@ -1,6 +1,6 @@ import React, { Suspense, lazy } from 'react'; - import type { ComponentProps } from 'react'; + import type ReactSyntaxHighlighter from './syntaxhighlighter'; let languages: Parameters[] = []; diff --git a/code/core/src/components/components/syntaxhighlighter/syntaxhighlighter-types.ts b/code/core/src/components/components/syntaxhighlighter/syntaxhighlighter-types.ts index d7ec7832df8..389f966e496 100644 --- a/code/core/src/components/components/syntaxhighlighter/syntaxhighlighter-types.ts +++ b/code/core/src/components/components/syntaxhighlighter/syntaxhighlighter-types.ts @@ -1,5 +1,7 @@ -import type { BuiltInParserName } from 'prettier'; import type { ReactNode } from 'react'; + +import type { BuiltInParserName } from 'prettier'; + import type { supportedLanguages } from './syntaxhighlighter'; export interface SyntaxHighlighterRendererProps { diff --git a/code/core/src/components/components/syntaxhighlighter/syntaxhighlighter.stories.tsx b/code/core/src/components/components/syntaxhighlighter/syntaxhighlighter.stories.tsx index 4b817b756c7..cd1fbe7af16 100644 --- a/code/core/src/components/components/syntaxhighlighter/syntaxhighlighter.stories.tsx +++ b/code/core/src/components/components/syntaxhighlighter/syntaxhighlighter.stories.tsx @@ -1,7 +1,8 @@ -import { ThemeProvider, ensure, themes } from '@storybook/core/theming'; - import type { ComponentProps } from 'react'; import React from 'react'; + +import { ThemeProvider, ensure, themes } from '@storybook/core/theming'; + import { SyntaxHighlighter } from './lazy-syntaxhighlighter'; export default { diff --git a/code/core/src/components/components/syntaxhighlighter/syntaxhighlighter.tsx b/code/core/src/components/components/syntaxhighlighter/syntaxhighlighter.tsx index 08a424fe31a..1c6db28aca2 100644 --- a/code/core/src/components/components/syntaxhighlighter/syntaxhighlighter.tsx +++ b/code/core/src/components/components/syntaxhighlighter/syntaxhighlighter.tsx @@ -1,31 +1,31 @@ import type { MouseEvent } from 'react'; import React, { useCallback, useEffect, useState } from 'react'; -import { logger } from '@storybook/core/client-logger'; + import { styled } from '@storybook/core/theming'; import { global } from '@storybook/global'; -import memoize from 'memoizerific'; -import jsx from 'react-syntax-highlighter/dist/esm/languages/prism/jsx'; +import { logger } from '@storybook/core/client-logger'; + +import memoize from 'memoizerific'; +// @ts-expect-error (Converted from ts-ignore) +import { createElement } from 'react-syntax-highlighter/dist/esm/index'; import bash from 'react-syntax-highlighter/dist/esm/languages/prism/bash'; import css from 'react-syntax-highlighter/dist/esm/languages/prism/css'; +import graphql from 'react-syntax-highlighter/dist/esm/languages/prism/graphql'; // @ts-expect-error (Converted from ts-ignore) import jsExtras from 'react-syntax-highlighter/dist/esm/languages/prism/js-extras'; import json from 'react-syntax-highlighter/dist/esm/languages/prism/json'; -import graphql from 'react-syntax-highlighter/dist/esm/languages/prism/graphql'; -import html from 'react-syntax-highlighter/dist/esm/languages/prism/markup'; +import jsx from 'react-syntax-highlighter/dist/esm/languages/prism/jsx'; import md from 'react-syntax-highlighter/dist/esm/languages/prism/markdown'; -import yml from 'react-syntax-highlighter/dist/esm/languages/prism/yaml'; +import html from 'react-syntax-highlighter/dist/esm/languages/prism/markup'; import tsx from 'react-syntax-highlighter/dist/esm/languages/prism/tsx'; import typescript from 'react-syntax-highlighter/dist/esm/languages/prism/typescript'; - +import yml from 'react-syntax-highlighter/dist/esm/languages/prism/yaml'; import ReactSyntaxHighlighter from 'react-syntax-highlighter/dist/esm/prism-light'; -// @ts-expect-error (Converted from ts-ignore) -import { createElement } from 'react-syntax-highlighter/dist/esm/index'; import { ActionBar } from '../ActionBar/ActionBar'; import type { ScrollAreaProps } from '../ScrollArea/ScrollArea'; import { ScrollArea } from '../ScrollArea/ScrollArea'; - import type { SyntaxHighlighterProps, SyntaxHighlighterRenderer, diff --git a/code/core/src/components/components/tabs/EmptyTabContent.stories.tsx b/code/core/src/components/components/tabs/EmptyTabContent.stories.tsx index e03fa329532..9c291b9e629 100644 --- a/code/core/src/components/components/tabs/EmptyTabContent.stories.tsx +++ b/code/core/src/components/components/tabs/EmptyTabContent.stories.tsx @@ -1,9 +1,11 @@ import React from 'react'; -import { EmptyTabContent } from './EmptyTabContent'; -import { DocumentIcon } from '@storybook/icons'; + import { Link } from '@storybook/core/components'; +import { DocumentIcon } from '@storybook/icons'; import type { Meta, StoryObj } from '@storybook/react'; +import { EmptyTabContent } from './EmptyTabContent'; + export default { title: 'TabContentEmpty', component: EmptyTabContent, diff --git a/code/core/src/components/components/tabs/EmptyTabContent.tsx b/code/core/src/components/components/tabs/EmptyTabContent.tsx index 1ce8d5e5a9f..cdb191e5971 100644 --- a/code/core/src/components/components/tabs/EmptyTabContent.tsx +++ b/code/core/src/components/components/tabs/EmptyTabContent.tsx @@ -1,4 +1,5 @@ import React from 'react'; + import { styled } from '@storybook/core/theming'; const Wrapper = styled.div(({ theme }) => ({ diff --git a/code/core/src/components/components/tabs/tabs.helpers.tsx b/code/core/src/components/components/tabs/tabs.helpers.tsx index 2a26b665113..90ae4c2c10a 100644 --- a/code/core/src/components/components/tabs/tabs.helpers.tsx +++ b/code/core/src/components/components/tabs/tabs.helpers.tsx @@ -1,7 +1,9 @@ -import { styled } from '@storybook/core/theming'; import type { FC, PropsWithChildren, ReactChild, ReactElement, ReactNode } from 'react'; import React, { Children } from 'react'; + +import { styled } from '@storybook/core/theming'; import type { Addon_RenderOptions } from '@storybook/core/types'; + import type { TabsProps } from './tabs'; export interface VisuallyHiddenProps { diff --git a/code/core/src/components/components/tabs/tabs.hooks.tsx b/code/core/src/components/components/tabs/tabs.hooks.tsx index d2606644d5a..be3a8f2060a 100644 --- a/code/core/src/components/components/tabs/tabs.hooks.tsx +++ b/code/core/src/components/components/tabs/tabs.hooks.tsx @@ -1,12 +1,15 @@ import React, { useCallback, useLayoutEffect, useRef, useState } from 'react'; -import { sanitize } from '@storybook/csf'; + import { styled } from '@storybook/core/theming'; +import { sanitize } from '@storybook/csf'; + import useResizeObserver from 'use-resize-observer'; + import { TabButton } from '../bar/button'; import { TooltipLinkList } from '../tooltip/TooltipLinkList'; +import type { Link } from '../tooltip/TooltipLinkList'; import { WithTooltip } from '../tooltip/WithTooltip'; import type { ChildrenListComplete } from './tabs.helpers'; -import type { Link } from '../tooltip/TooltipLinkList'; const CollapseIcon = styled.span<{ isActive: boolean }>(({ theme, isActive }) => ({ display: 'inline-block', diff --git a/code/core/src/components/components/tabs/tabs.stories.tsx b/code/core/src/components/components/tabs/tabs.stories.tsx index 1958c3e1855..5e23fd7ecb7 100644 --- a/code/core/src/components/components/tabs/tabs.stories.tsx +++ b/code/core/src/components/components/tabs/tabs.stories.tsx @@ -1,12 +1,15 @@ -import { expect } from '@storybook/test'; import React from 'react'; -import { action } from '@storybook/addon-actions'; -import type { Meta, StoryObj } from '@storybook/react'; -import { within, fireEvent, waitFor, screen, userEvent, findByText } from '@storybook/test'; + import { BottomBarIcon, CloseIcon } from '@storybook/icons'; -import { Tabs, TabsState, TabWrapper } from './tabs'; -import type { ChildrenList } from './tabs.helpers'; +import type { Meta, StoryObj } from '@storybook/react'; +import { expect } from '@storybook/test'; +import { findByText, fireEvent, screen, userEvent, waitFor, within } from '@storybook/test'; + +import { action } from '@storybook/addon-actions'; + import { IconButton } from '../IconButton/IconButton'; +import { TabWrapper, Tabs, TabsState } from './tabs'; +import type { ChildrenList } from './tabs.helpers'; const colours = Array.from(new Array(15), (val, index) => index).map((i) => Math.floor((1 / 15) * i * 16777215) diff --git a/code/core/src/components/components/tabs/tabs.tsx b/code/core/src/components/components/tabs/tabs.tsx index 318fc31c033..3c8c46c45c1 100644 --- a/code/core/src/components/components/tabs/tabs.tsx +++ b/code/core/src/components/components/tabs/tabs.tsx @@ -1,14 +1,15 @@ import type { FC, PropsWithChildren, ReactElement, ReactNode, SyntheticEvent } from 'react'; -import React, { useMemo, Component, memo } from 'react'; +import React, { Component, memo, useMemo } from 'react'; + import { styled } from '@storybook/core/theming'; +import type { Addon_RenderOptions } from '@storybook/core/types'; import { sanitize } from '@storybook/csf'; -import type { Addon_RenderOptions } from '@storybook/core/types'; -import { TabButton } from '../bar/button'; import { FlexBar } from '../bar/bar'; -import { childrenToList, VisuallyHidden } from './tabs.helpers'; -import { useList } from './tabs.hooks'; +import { TabButton } from '../bar/button'; import { EmptyTabContent } from './EmptyTabContent'; +import { VisuallyHidden, childrenToList } from './tabs.helpers'; +import { useList } from './tabs.hooks'; const ignoreSsrWarning = '/* emotion-disable-server-rendering-unsafe-selector-warning-please-do-not-use-this-the-warning-exists-for-a-reason */'; diff --git a/code/core/src/components/components/tooltip/ListItem.stories.tsx b/code/core/src/components/components/tooltip/ListItem.stories.tsx index ab68b8444ba..b85d3ba4c1a 100644 --- a/code/core/src/components/components/tooltip/ListItem.stories.tsx +++ b/code/core/src/components/components/tooltip/ListItem.stories.tsx @@ -1,5 +1,7 @@ import React, { Fragment } from 'react'; + import { EyeIcon } from '@storybook/icons'; + import ListItem from './ListItem'; export default { diff --git a/code/core/src/components/components/tooltip/ListItem.tsx b/code/core/src/components/components/tooltip/ListItem.tsx index 58528169f16..9e4dc9d75f9 100644 --- a/code/core/src/components/components/tooltip/ListItem.tsx +++ b/code/core/src/components/components/tooltip/ListItem.tsx @@ -1,6 +1,8 @@ -import type { ReactNode, ComponentProps } from 'react'; +import type { ComponentProps, ReactNode } from 'react'; import React from 'react'; + import { styled } from '@storybook/core/theming'; + import memoize from 'memoizerific'; import { transparentize } from 'polished'; diff --git a/code/core/src/components/components/tooltip/Tooltip.stories.tsx b/code/core/src/components/components/tooltip/Tooltip.stories.tsx index 3ca9e21cfc1..35385c1b447 100644 --- a/code/core/src/components/components/tooltip/Tooltip.stories.tsx +++ b/code/core/src/components/components/tooltip/Tooltip.stories.tsx @@ -1,6 +1,8 @@ import type { ComponentProps } from 'react'; import React from 'react'; + import { styled } from '@storybook/core/theming'; + import { Tooltip } from './Tooltip'; // Popper would position the tooltip absolutely. We just need to make sure we are pos:rel diff --git a/code/core/src/components/components/tooltip/Tooltip.tsx b/code/core/src/components/components/tooltip/Tooltip.tsx index 83fbebfd1c9..77a6d4fc9c2 100644 --- a/code/core/src/components/components/tooltip/Tooltip.tsx +++ b/code/core/src/components/components/tooltip/Tooltip.tsx @@ -1,7 +1,8 @@ import React from 'react'; -import memoize from 'memoizerific'; -import { styled, type Color, lighten } from '@storybook/core/theming'; +import { type Color, lighten, styled } from '@storybook/core/theming'; + +import memoize from 'memoizerific'; const match = memoize(1000)((requests, actual, value, fallback = 0) => actual.split('-')[0] === requests ? value : fallback diff --git a/code/core/src/components/components/tooltip/TooltipLinkList.stories.tsx b/code/core/src/components/components/tooltip/TooltipLinkList.stories.tsx index 84186de3544..07f870cc1f2 100644 --- a/code/core/src/components/components/tooltip/TooltipLinkList.stories.tsx +++ b/code/core/src/components/components/tooltip/TooltipLinkList.stories.tsx @@ -1,10 +1,13 @@ import type { FunctionComponent, MouseEvent, PropsWithChildren, ReactElement } from 'react'; import React, { Children, cloneElement } from 'react'; -import { action } from '@storybook/addon-actions'; -import type { Meta, StoryObj } from '@storybook/react'; + import { LinkIcon, LinuxIcon } from '@storybook/icons'; -import { WithTooltip } from './WithTooltip'; +import type { Meta, StoryObj } from '@storybook/react'; + +import { action } from '@storybook/addon-actions'; + import { TooltipLinkList } from './TooltipLinkList'; +import { WithTooltip } from './WithTooltip'; import ellipseUrl from './assets/ellipse.png'; const onLinkClick = action('onLinkClick'); diff --git a/code/core/src/components/components/tooltip/TooltipLinkList.tsx b/code/core/src/components/components/tooltip/TooltipLinkList.tsx index 6f05bf2ec90..7ab5fabf196 100644 --- a/code/core/src/components/components/tooltip/TooltipLinkList.tsx +++ b/code/core/src/components/components/tooltip/TooltipLinkList.tsx @@ -1,5 +1,6 @@ import type { SyntheticEvent } from 'react'; import React, { useCallback } from 'react'; + import { styled } from '@storybook/core/theming'; import type { LinkWrapperType, ListItemProps } from './ListItem'; diff --git a/code/core/src/components/components/tooltip/TooltipMessage.stories.tsx b/code/core/src/components/components/tooltip/TooltipMessage.stories.tsx index 9c210eb90ba..c84eb4dcc40 100644 --- a/code/core/src/components/components/tooltip/TooltipMessage.stories.tsx +++ b/code/core/src/components/components/tooltip/TooltipMessage.stories.tsx @@ -1,7 +1,9 @@ import React from 'react'; + import type { Meta } from '@storybook/react'; -import { WithTooltip } from './WithTooltip'; + import { TooltipMessage } from './TooltipMessage'; +import { WithTooltip } from './WithTooltip'; export default { component: TooltipMessage, diff --git a/code/core/src/components/components/tooltip/TooltipMessage.tsx b/code/core/src/components/components/tooltip/TooltipMessage.tsx index 8af15a91501..3882e428fab 100644 --- a/code/core/src/components/components/tooltip/TooltipMessage.tsx +++ b/code/core/src/components/components/tooltip/TooltipMessage.tsx @@ -1,5 +1,6 @@ import type { ReactNode } from 'react'; import React from 'react'; + import { styled } from '@storybook/core/theming'; import { Link } from '../typography/link/link'; diff --git a/code/core/src/components/components/tooltip/TooltipNote.stories.tsx b/code/core/src/components/components/tooltip/TooltipNote.stories.tsx index 6c1e533edc7..fac7e72347e 100644 --- a/code/core/src/components/components/tooltip/TooltipNote.stories.tsx +++ b/code/core/src/components/components/tooltip/TooltipNote.stories.tsx @@ -1,6 +1,7 @@ import React from 'react'; -import { WithTooltip } from './WithTooltip'; + import { TooltipNote } from './TooltipNote'; +import { WithTooltip } from './WithTooltip'; export default { component: TooltipNote, diff --git a/code/core/src/components/components/tooltip/TooltipNote.tsx b/code/core/src/components/components/tooltip/TooltipNote.tsx index 2366525b0a5..6bfde56693d 100644 --- a/code/core/src/components/components/tooltip/TooltipNote.tsx +++ b/code/core/src/components/components/tooltip/TooltipNote.tsx @@ -1,4 +1,5 @@ import React from 'react'; + import { styled } from '@storybook/core/theming'; const Note = styled.div(({ theme }) => ({ diff --git a/code/core/src/components/components/tooltip/WithTooltip.stories.tsx b/code/core/src/components/components/tooltip/WithTooltip.stories.tsx index 4bfae3be6aa..e5651c50bf7 100644 --- a/code/core/src/components/components/tooltip/WithTooltip.stories.tsx +++ b/code/core/src/components/components/tooltip/WithTooltip.stories.tsx @@ -1,8 +1,10 @@ -import type { FunctionComponent, ComponentProps } from 'react'; +import type { ComponentProps, FunctionComponent } from 'react'; import React from 'react'; + +import { styled } from '@storybook/core/theming'; import type { StoryObj } from '@storybook/react'; import { expect, screen } from '@storybook/test'; -import { styled } from '@storybook/core/theming'; + import { TooltipMessage } from './TooltipMessage'; import { WithToolTipState as WithTooltip } from './WithTooltip'; diff --git a/code/core/src/components/components/tooltip/WithTooltip.tsx b/code/core/src/components/components/tooltip/WithTooltip.tsx index 63cb4e5d5d7..28576bf6c20 100644 --- a/code/core/src/components/components/tooltip/WithTooltip.tsx +++ b/code/core/src/components/components/tooltip/WithTooltip.tsx @@ -1,11 +1,13 @@ import type { ComponentProps, ReactNode } from 'react'; -import React, { useCallback, useState, useEffect } from 'react'; -import ReactDOM from 'react-dom'; +import React, { useCallback, useEffect, useState } from 'react'; + import { styled } from '@storybook/core/theming'; import { global } from '@storybook/global'; -import type { Config as ReactPopperTooltipConfig, PopperOptions } from 'react-popper-tooltip'; +import ReactDOM from 'react-dom'; +import type { PopperOptions, Config as ReactPopperTooltipConfig } from 'react-popper-tooltip'; import { usePopperTooltip } from 'react-popper-tooltip'; + import { Tooltip } from './Tooltip'; const { document } = global; diff --git a/code/core/src/components/components/tooltip/lazy-WithTooltip.tsx b/code/core/src/components/components/tooltip/lazy-WithTooltip.tsx index 4bf90edb5f1..336ffdfacf4 100644 --- a/code/core/src/components/components/tooltip/lazy-WithTooltip.tsx +++ b/code/core/src/components/components/tooltip/lazy-WithTooltip.tsx @@ -1,5 +1,5 @@ import type { ComponentProps } from 'react'; -import React, { lazy, Suspense } from 'react'; +import React, { Suspense, lazy } from 'react'; const LazyWithTooltip = lazy(() => import('./WithTooltip').then((mod) => ({ default: mod.WithTooltip })) diff --git a/code/core/src/components/components/typography/ResetWrapper.tsx b/code/core/src/components/components/typography/ResetWrapper.tsx index 5f639a3fa09..09791ce4c32 100644 --- a/code/core/src/components/components/typography/ResetWrapper.tsx +++ b/code/core/src/components/components/typography/ResetWrapper.tsx @@ -1,4 +1,5 @@ import { styled } from '@storybook/core/theming'; + import { withReset } from './lib/common'; /** diff --git a/code/core/src/components/components/typography/components.tsx b/code/core/src/components/components/typography/components.tsx index 4f324b3f7a5..790a8c02501 100644 --- a/code/core/src/components/components/typography/components.tsx +++ b/code/core/src/components/components/typography/components.tsx @@ -1,20 +1,22 @@ import type { - HTMLAttributes, - DetailedHTMLProps, AnchorHTMLAttributes, BlockquoteHTMLAttributes, + DetailedHTMLProps, + HTMLAttributes, ImgHTMLAttributes, - TableHTMLAttributes, LiHTMLAttributes, OlHTMLAttributes, + TableHTMLAttributes, } from 'react'; import React from 'react'; + import { nameSpaceClassNames } from './DocumentFormatting'; +import { ResetWrapper } from './ResetWrapper'; import { A } from './elements/A'; import { Blockquote } from './elements/Blockquote'; import { Code } from './elements/Code'; -import { Div } from './elements/Div'; import { DL } from './elements/DL'; +import { Div } from './elements/Div'; import { H1 } from './elements/H1'; import { H2 } from './elements/H2'; import { H3 } from './elements/H3'; @@ -28,10 +30,9 @@ import { OL } from './elements/OL'; import { P } from './elements/P'; import { Pre } from './elements/Pre'; import { Span } from './elements/Span'; -import { Table } from './elements/Table'; import { TT } from './elements/TT'; +import { Table } from './elements/Table'; import { UL } from './elements/UL'; -import { ResetWrapper } from './ResetWrapper'; export const components = { h1: (props: DetailedHTMLProps, HTMLHeadingElement>) => ( diff --git a/code/core/src/components/components/typography/elements/A.tsx b/code/core/src/components/components/typography/elements/A.tsx index 28e8ccc082d..2eb9cdb4d87 100644 --- a/code/core/src/components/components/typography/elements/A.tsx +++ b/code/core/src/components/components/typography/elements/A.tsx @@ -1,4 +1,5 @@ import { styled } from '@storybook/core/theming'; + import { withReset } from '../lib/common'; import { Link } from './Link'; diff --git a/code/core/src/components/components/typography/elements/Blockquote.tsx b/code/core/src/components/components/typography/elements/Blockquote.tsx index 5692a72aa9f..b4e06b210ed 100644 --- a/code/core/src/components/components/typography/elements/Blockquote.tsx +++ b/code/core/src/components/components/typography/elements/Blockquote.tsx @@ -1,5 +1,6 @@ import { styled } from '@storybook/core/theming'; -import { withReset, withMargin } from '../lib/common'; + +import { withMargin, withReset } from '../lib/common'; export const Blockquote = styled.blockquote(withReset, withMargin, ({ theme }) => ({ borderLeft: `4px solid ${theme.color.medium}`, diff --git a/code/core/src/components/components/typography/elements/Code.tsx b/code/core/src/components/components/typography/elements/Code.tsx index 7f67c12e645..e22b3cca913 100644 --- a/code/core/src/components/components/typography/elements/Code.tsx +++ b/code/core/src/components/components/typography/elements/Code.tsx @@ -1,10 +1,12 @@ -import { styled } from '@storybook/core/theming'; import type { ComponentProps } from 'react'; import React, { Children } from 'react'; + +import { styled } from '@storybook/core/theming'; + import { SyntaxHighlighter } from '../../syntaxhighlighter/syntaxhighlighter'; -import { isReactChildString } from '../lib/isReactChildString'; -import { codeCommon } from '../lib/common'; import type { SupportedLanguage } from '../../syntaxhighlighter/syntaxhighlighter-types'; +import { codeCommon } from '../lib/common'; +import { isReactChildString } from '../lib/isReactChildString'; const isInlineCodeRegex = /[\n\r]/g; diff --git a/code/core/src/components/components/typography/elements/DL.tsx b/code/core/src/components/components/typography/elements/DL.tsx index 792df46878c..840dbc0bbed 100644 --- a/code/core/src/components/components/typography/elements/DL.tsx +++ b/code/core/src/components/components/typography/elements/DL.tsx @@ -1,5 +1,6 @@ import { styled } from '@storybook/core/theming'; -import { withReset, withMargin } from '../lib/common'; + +import { withMargin, withReset } from '../lib/common'; export const DL = styled.dl(withReset, withMargin, { padding: 0, diff --git a/code/core/src/components/components/typography/elements/Div.tsx b/code/core/src/components/components/typography/elements/Div.tsx index bf70948dfa1..7e8b9b6765d 100644 --- a/code/core/src/components/components/typography/elements/Div.tsx +++ b/code/core/src/components/components/typography/elements/Div.tsx @@ -1,4 +1,5 @@ import { styled } from '@storybook/core/theming'; + import { withReset } from '../lib/common'; export const Div = styled.div(withReset); diff --git a/code/core/src/components/components/typography/elements/H1.tsx b/code/core/src/components/components/typography/elements/H1.tsx index 9b306ab1343..6ede5882351 100644 --- a/code/core/src/components/components/typography/elements/H1.tsx +++ b/code/core/src/components/components/typography/elements/H1.tsx @@ -1,5 +1,6 @@ import { styled } from '@storybook/core/theming'; -import { withReset, headerCommon } from '../lib/common'; + +import { headerCommon, withReset } from '../lib/common'; export const H1 = styled.h1(withReset, headerCommon, ({ theme }) => ({ fontSize: `${theme.typography.size.l1}px`, diff --git a/code/core/src/components/components/typography/elements/H2.tsx b/code/core/src/components/components/typography/elements/H2.tsx index 9d17758aefb..f2c070827ed 100644 --- a/code/core/src/components/components/typography/elements/H2.tsx +++ b/code/core/src/components/components/typography/elements/H2.tsx @@ -1,5 +1,6 @@ import { styled } from '@storybook/core/theming'; -import { withReset, headerCommon } from '../lib/common'; + +import { headerCommon, withReset } from '../lib/common'; export const H2 = styled.h2(withReset, headerCommon, ({ theme }) => ({ fontSize: `${theme.typography.size.m2}px`, diff --git a/code/core/src/components/components/typography/elements/H3.tsx b/code/core/src/components/components/typography/elements/H3.tsx index 6eea8bd27af..150474aa427 100644 --- a/code/core/src/components/components/typography/elements/H3.tsx +++ b/code/core/src/components/components/typography/elements/H3.tsx @@ -1,5 +1,6 @@ import { styled } from '@storybook/core/theming'; -import { withReset, headerCommon } from '../lib/common'; + +import { headerCommon, withReset } from '../lib/common'; export const H3 = styled.h3(withReset, headerCommon, ({ theme }) => ({ fontSize: `${theme.typography.size.m1}px`, diff --git a/code/core/src/components/components/typography/elements/H4.tsx b/code/core/src/components/components/typography/elements/H4.tsx index edd0b263922..f0933727d8c 100644 --- a/code/core/src/components/components/typography/elements/H4.tsx +++ b/code/core/src/components/components/typography/elements/H4.tsx @@ -1,5 +1,6 @@ import { styled } from '@storybook/core/theming'; -import { withReset, headerCommon } from '../lib/common'; + +import { headerCommon, withReset } from '../lib/common'; export const H4 = styled.h4(withReset, headerCommon, ({ theme }) => ({ fontSize: `${theme.typography.size.s3}px`, diff --git a/code/core/src/components/components/typography/elements/H5.tsx b/code/core/src/components/components/typography/elements/H5.tsx index e06405f1909..637b64cad8f 100644 --- a/code/core/src/components/components/typography/elements/H5.tsx +++ b/code/core/src/components/components/typography/elements/H5.tsx @@ -1,5 +1,6 @@ import { styled } from '@storybook/core/theming'; -import { withReset, headerCommon } from '../lib/common'; + +import { headerCommon, withReset } from '../lib/common'; export const H5 = styled.h5(withReset, headerCommon, ({ theme }) => ({ fontSize: `${theme.typography.size.s2}px`, diff --git a/code/core/src/components/components/typography/elements/H6.tsx b/code/core/src/components/components/typography/elements/H6.tsx index bbf7b7cbb43..b862026ede7 100644 --- a/code/core/src/components/components/typography/elements/H6.tsx +++ b/code/core/src/components/components/typography/elements/H6.tsx @@ -1,5 +1,6 @@ import { styled } from '@storybook/core/theming'; -import { withReset, headerCommon } from '../lib/common'; + +import { headerCommon, withReset } from '../lib/common'; export const H6 = styled.h6(withReset, headerCommon, ({ theme }) => ({ fontSize: `${theme.typography.size.s2}px`, diff --git a/code/core/src/components/components/typography/elements/LI.tsx b/code/core/src/components/components/typography/elements/LI.tsx index 4b18e602272..9361defda4e 100644 --- a/code/core/src/components/components/typography/elements/LI.tsx +++ b/code/core/src/components/components/typography/elements/LI.tsx @@ -1,6 +1,7 @@ import type { CSSObject } from '@storybook/core/theming'; import { styled } from '@storybook/core/theming'; -import { withReset, codeCommon } from '../lib/common'; + +import { codeCommon, withReset } from '../lib/common'; export const LI = styled.li(withReset, ({ theme }) => ({ fontSize: theme.typography.size.s2, diff --git a/code/core/src/components/components/typography/elements/OL.tsx b/code/core/src/components/components/typography/elements/OL.tsx index 50d17100358..dd6c328c72b 100644 --- a/code/core/src/components/components/typography/elements/OL.tsx +++ b/code/core/src/components/components/typography/elements/OL.tsx @@ -1,6 +1,7 @@ import { styled } from '@storybook/core/theming'; import type { Interpolation } from '@storybook/core/theming'; -import { withReset, withMargin } from '../lib/common'; + +import { withMargin, withReset } from '../lib/common'; const listCommon: Interpolation = { paddingLeft: 30, diff --git a/code/core/src/components/components/typography/elements/P.tsx b/code/core/src/components/components/typography/elements/P.tsx index c24405d69a5..3039d859227 100644 --- a/code/core/src/components/components/typography/elements/P.tsx +++ b/code/core/src/components/components/typography/elements/P.tsx @@ -1,6 +1,7 @@ import type { CSSObject } from '@storybook/core/theming'; import { styled } from '@storybook/core/theming'; -import { withReset, withMargin, codeCommon } from '../lib/common'; + +import { codeCommon, withMargin, withReset } from '../lib/common'; export const P = styled.p(withReset, withMargin, ({ theme }) => ({ fontSize: theme.typography.size.s2, diff --git a/code/core/src/components/components/typography/elements/Pre.tsx b/code/core/src/components/components/typography/elements/Pre.tsx index 4792fe8b387..d2c3a1258cc 100644 --- a/code/core/src/components/components/typography/elements/Pre.tsx +++ b/code/core/src/components/components/typography/elements/Pre.tsx @@ -1,5 +1,6 @@ import { styled } from '@storybook/core/theming'; -import { withReset, withMargin } from '../lib/common'; + +import { withMargin, withReset } from '../lib/common'; export const Pre = styled.pre(withReset, withMargin, ({ theme }) => ({ // reset diff --git a/code/core/src/components/components/typography/elements/Span.tsx b/code/core/src/components/components/typography/elements/Span.tsx index 3c3a8a11957..35d9e45bd60 100644 --- a/code/core/src/components/components/typography/elements/Span.tsx +++ b/code/core/src/components/components/typography/elements/Span.tsx @@ -1,4 +1,5 @@ import { styled } from '@storybook/core/theming'; + import { withReset } from '../lib/common'; export const Span = styled.span(withReset, ({ theme }) => ({ diff --git a/code/core/src/components/components/typography/elements/TT.tsx b/code/core/src/components/components/typography/elements/TT.tsx index af32c595442..4544a0b6ded 100644 --- a/code/core/src/components/components/typography/elements/TT.tsx +++ b/code/core/src/components/components/typography/elements/TT.tsx @@ -1,4 +1,5 @@ import { styled } from '@storybook/core/theming'; + import { codeCommon } from '../lib/common'; export const TT = styled.title(codeCommon); diff --git a/code/core/src/components/components/typography/elements/Table.tsx b/code/core/src/components/components/typography/elements/Table.tsx index d09639884f6..262adddd3f3 100644 --- a/code/core/src/components/components/typography/elements/Table.tsx +++ b/code/core/src/components/components/typography/elements/Table.tsx @@ -1,5 +1,6 @@ import { styled } from '@storybook/core/theming'; -import { withReset, withMargin } from '../lib/common'; + +import { withMargin, withReset } from '../lib/common'; export const Table = styled.table(withReset, withMargin, ({ theme }) => ({ fontSize: theme.typography.size.s2, diff --git a/code/core/src/components/components/typography/elements/UL.tsx b/code/core/src/components/components/typography/elements/UL.tsx index 75bb7d5c9da..1aeb5b10bb6 100644 --- a/code/core/src/components/components/typography/elements/UL.tsx +++ b/code/core/src/components/components/typography/elements/UL.tsx @@ -1,6 +1,7 @@ import { styled } from '@storybook/core/theming'; import type { Interpolation } from '@storybook/core/theming'; -import { withReset, withMargin } from '../lib/common'; + +import { withMargin, withReset } from '../lib/common'; const listCommon: Interpolation = { paddingLeft: 30, diff --git a/code/core/src/components/components/typography/lib/common.tsx b/code/core/src/components/components/typography/lib/common.tsx index 1cf1ccd9e93..fc0d32f128b 100644 --- a/code/core/src/components/components/typography/lib/common.tsx +++ b/code/core/src/components/components/typography/lib/common.tsx @@ -1,6 +1,7 @@ -import { transparentize } from 'polished'; import type { CSSObject, FunctionInterpolation } from '@storybook/core/theming'; +import { transparentize } from 'polished'; + export const headerCommon: FunctionInterpolation = ({ theme }) => ({ margin: '20px 0 8px', padding: 0, diff --git a/code/core/src/components/components/typography/link/link.stories.tsx b/code/core/src/components/components/typography/link/link.stories.tsx index 0ee21b79314..9ac42ec3581 100644 --- a/code/core/src/components/components/typography/link/link.stories.tsx +++ b/code/core/src/components/components/typography/link/link.stories.tsx @@ -1,7 +1,10 @@ import type { ComponentProps } from 'react'; import React from 'react'; -import { action } from '@storybook/addon-actions'; + import { DiscordIcon, SidebarIcon } from '@storybook/icons'; + +import { action } from '@storybook/addon-actions'; + import { Link } from './link'; const onClick = action('onClick'); diff --git a/code/core/src/components/components/typography/link/link.test.tsx b/code/core/src/components/components/typography/link/link.test.tsx index ccf004e8765..5e0af1da209 100644 --- a/code/core/src/components/components/typography/link/link.test.tsx +++ b/code/core/src/components/components/typography/link/link.test.tsx @@ -1,11 +1,13 @@ // @vitest-environment happy-dom +import { cleanup, render, screen } from '@testing-library/react'; +import userEvent from '@testing-library/user-event'; +import { afterEach, describe, expect, it, vi } from 'vitest'; -import { vi, describe, afterEach, it, expect } from 'vitest'; import type { AnchorHTMLAttributes } from 'react'; import React from 'react'; -import { cleanup, render, screen } from '@testing-library/react'; -import userEvent from '@testing-library/user-event'; -import { ThemeProvider, themes, convert } from '@storybook/core/theming'; + +import { ThemeProvider, convert, themes } from '@storybook/core/theming'; + import type { LinkProps } from './link'; import { Link } from './link'; diff --git a/code/core/src/components/components/typography/link/link.tsx b/code/core/src/components/components/typography/link/link.tsx index adb92701af2..2ce80ec9612 100644 --- a/code/core/src/components/components/typography/link/link.tsx +++ b/code/core/src/components/components/typography/link/link.tsx @@ -1,9 +1,11 @@ import type { AnchorHTMLAttributes, MouseEvent } from 'react'; import React from 'react'; + import { styled } from '@storybook/core/theming'; -import { darken } from 'polished'; import { ChevronRightIcon } from '@storybook/icons'; +import { darken } from 'polished'; + // Cmd/Ctrl/Shift/Alt + Click should trigger default browser behavior. Same applies to non-left clicks const LEFT_BUTTON = 0; diff --git a/code/core/src/components/index.ts b/code/core/src/components/index.ts index ad14eb46e72..eaf6fef4f60 100644 --- a/code/core/src/components/index.ts +++ b/code/core/src/components/index.ts @@ -1,7 +1,7 @@ /// - import type { ElementType } from 'react'; import { createElement, forwardRef } from 'react'; + import * as typography from './components/typography/components'; export { A } from './components/typography/elements/A'; diff --git a/code/core/src/core-events/index.test.ts b/code/core/src/core-events/index.test.ts index 9ee5d1b0669..bc3401a7186 100644 --- a/code/core/src/core-events/index.test.ts +++ b/code/core/src/core-events/index.test.ts @@ -1,4 +1,5 @@ -import { describe, it, expect } from 'vitest'; +import { describe, expect, it } from 'vitest'; + import * as EventsPackageExport from './index'; import EventsDefaultExport, { CHANNEL_CREATED } from './index'; diff --git a/code/core/src/core-server/build-dev.ts b/code/core/src/core-server/build-dev.ts index f1c8cd8468c..fc07aa11ab9 100644 --- a/code/core/src/core-server/build-dev.ts +++ b/code/core/src/core-server/build-dev.ts @@ -1,4 +1,5 @@ -import type { BuilderOptions, CLIOptions, LoadOptions, Options } from '@storybook/core/types'; +import { join, relative, resolve } from 'node:path'; + import { getProjectRoot, loadAllPresets, @@ -8,25 +9,27 @@ import { serverResolve, validateFrameworkName, } from '@storybook/core/common'; -import prompts from 'prompts'; -import invariant from 'tiny-invariant'; -import { global } from '@storybook/global'; import { oneWayHash, telemetry } from '@storybook/core/telemetry'; +import type { BuilderOptions, CLIOptions, LoadOptions, Options } from '@storybook/core/types'; +import { global } from '@storybook/global'; -import { join, relative, resolve } from 'node:path'; import { deprecate } from '@storybook/core/node-logger'; -import { dedent } from 'ts-dedent'; -import { readFile } from 'fs-extra'; import { MissingBuilderError, NoStatsForViteDevError } from '@storybook/core/server-errors'; + +import { readFile } from 'fs-extra'; +import prompts from 'prompts'; +import invariant from 'tiny-invariant'; +import { dedent } from 'ts-dedent'; + import { storybookDevServer } from './dev-server'; -import { outputStats } from './utils/output-stats'; +import { buildOrThrow } from './utils/build-or-throw'; +import { getManagerBuilder, getPreviewBuilder } from './utils/get-builders'; import { outputStartupInformation } from './utils/output-startup-information'; -import { updateCheck } from './utils/update-check'; +import { outputStats } from './utils/output-stats'; import { getServerChannelUrl, getServerPort } from './utils/server-address'; -import { getManagerBuilder, getPreviewBuilder } from './utils/get-builders'; +import { updateCheck } from './utils/update-check'; import { warnOnIncompatibleAddons } from './utils/warnOnIncompatibleAddons'; import { warnWhenUsingArgTypesRegex } from './utils/warnWhenUsingArgTypesRegex'; -import { buildOrThrow } from './utils/build-or-throw'; export async function buildDevStandalone( options: CLIOptions & LoadOptions & BuilderOptions diff --git a/code/core/src/core-server/build-static.ts b/code/core/src/core-server/build-static.ts index 16d7de1036b..248b2746ea8 100644 --- a/code/core/src/core-server/build-static.ts +++ b/code/core/src/core-server/build-static.ts @@ -1,10 +1,5 @@ -import chalk from 'chalk'; -import { copy, emptyDir, ensureDir } from 'fs-extra'; import { dirname, join, relative, resolve } from 'node:path'; -import { global } from '@storybook/global'; -import { logger } from '@storybook/core/node-logger'; -import { getPrecedingUpgrade, telemetry } from '@storybook/core/telemetry'; -import type { BuilderOptions, CLIOptions, LoadOptions, Options } from '@storybook/core/types'; + import { loadAllPresets, loadMainConfig, @@ -12,15 +7,23 @@ import { normalizeStories, resolveAddonName, } from '@storybook/core/common'; +import { getPrecedingUpgrade, telemetry } from '@storybook/core/telemetry'; +import type { BuilderOptions, CLIOptions, LoadOptions, Options } from '@storybook/core/types'; +import { global } from '@storybook/global'; -import { outputStats } from './utils/output-stats'; +import { logger } from '@storybook/core/node-logger'; + +import chalk from 'chalk'; +import { copy, emptyDir, ensureDir } from 'fs-extra'; + +import { StoryIndexGenerator } from './utils/StoryIndexGenerator'; +import { buildOrThrow } from './utils/build-or-throw'; import { copyAllStaticFilesRelativeToMain } from './utils/copy-all-static-files'; import { getBuilders } from './utils/get-builders'; -import { extractStoriesJson } from './utils/stories-json'; import { extractStorybookMetadata } from './utils/metadata'; -import { StoryIndexGenerator } from './utils/StoryIndexGenerator'; +import { outputStats } from './utils/output-stats'; +import { extractStoriesJson } from './utils/stories-json'; import { summarizeIndex } from './utils/summarizeIndex'; -import { buildOrThrow } from './utils/build-or-throw'; export type BuildStaticStandaloneOptions = CLIOptions & LoadOptions & diff --git a/code/core/src/core-server/dev-server.ts b/code/core/src/core-server/dev-server.ts index 1639e754fe0..cdf1027d187 100644 --- a/code/core/src/core-server/dev-server.ts +++ b/code/core/src/core-server/dev-server.ts @@ -1,27 +1,26 @@ -import express from 'express'; -import compression from 'compression'; -import invariant from 'tiny-invariant'; - +import { logConfig } from '@storybook/core/common'; import type { Options } from '@storybook/core/types'; -import { logConfig } from '@storybook/core/common'; import { logger } from '@storybook/core/node-logger'; - import { MissingBuilderError } from '@storybook/core/server-errors'; -import { getMiddleware } from './utils/middleware'; -import { getServerAddresses } from './utils/server-address'; -import { getServer } from './utils/server-init'; -import { useStatics } from './utils/server-statics'; -import { getServerChannel } from './utils/get-server-channel'; -import { openInBrowser } from './utils/open-in-browser'; -import { getManagerBuilder, getPreviewBuilder } from './utils/get-builders'; +import compression from 'compression'; +import express from 'express'; +import invariant from 'tiny-invariant'; + import type { StoryIndexGenerator } from './utils/StoryIndexGenerator'; -import { getStoryIndexGenerator } from './utils/getStoryIndexGenerator'; import { doTelemetry } from './utils/doTelemetry'; -import { router } from './utils/router'; -import { getAccessControlMiddleware } from './utils/getAccessControlMiddleware'; +import { getManagerBuilder, getPreviewBuilder } from './utils/get-builders'; import { getCachingMiddleware } from './utils/get-caching-middleware'; +import { getServerChannel } from './utils/get-server-channel'; +import { getAccessControlMiddleware } from './utils/getAccessControlMiddleware'; +import { getStoryIndexGenerator } from './utils/getStoryIndexGenerator'; +import { getMiddleware } from './utils/middleware'; +import { openInBrowser } from './utils/open-in-browser'; +import { router } from './utils/router'; +import { getServerAddresses } from './utils/server-address'; +import { getServer } from './utils/server-init'; +import { useStatics } from './utils/server-statics'; export async function storybookDevServer(options: Options) { const app = express(); diff --git a/code/core/src/core-server/presets/common-override-preset.ts b/code/core/src/core-server/presets/common-override-preset.ts index 83e6ed022ce..2566bee5359 100644 --- a/code/core/src/core-server/presets/common-override-preset.ts +++ b/code/core/src/core-server/presets/common-override-preset.ts @@ -1,4 +1,5 @@ import type { PresetProperty, TestBuildFlags } from '@storybook/core/types'; + import { removeMDXEntries } from '../utils/remove-mdx-entries'; export const framework: PresetProperty<'framework'> = async (config) => { diff --git a/code/core/src/core-server/presets/common-preset.ts b/code/core/src/core-server/presets/common-preset.ts index 177944e3453..c1b8ca68f88 100644 --- a/code/core/src/core-server/presets/common-preset.ts +++ b/code/core/src/core-server/presets/common-preset.ts @@ -1,6 +1,6 @@ -import { pathExists, readFile } from 'fs-extra'; -import { logger } from '@storybook/core/node-logger'; -import { telemetry } from '@storybook/core/telemetry'; +import { dirname, isAbsolute, join } from 'node:path'; + +import type { Channel } from '@storybook/core/channels'; import { getDirectoryFromWorkingDir, getPreviewBodyTemplate, @@ -8,24 +8,28 @@ import { loadEnvs, removeAddon as removeAddonBase, } from '@storybook/core/common'; +import { telemetry } from '@storybook/core/telemetry'; import type { CLIOptions, CoreConfig, Indexer, Options, - PresetPropertyFn, PresetProperty, + PresetPropertyFn, } from '@storybook/core/types'; + import { readCsf } from '@storybook/core/csf-tools'; -import { join, dirname, isAbsolute } from 'node:path'; +import { logger } from '@storybook/core/node-logger'; + +import { pathExists, readFile } from 'fs-extra'; import { dedent } from 'ts-dedent'; -import type { Channel } from '@storybook/core/channels'; -import { parseStaticDir } from '../utils/server-statics'; + +import { initCreateNewStoryChannel } from '../server-channel/create-new-story-channel'; +import { initFileSearchChannel } from '../server-channel/file-search-channel'; import { defaultStaticDirs } from '../utils/constants'; -import { initializeWhatsNew, type OptionsWithRequiredCache } from '../utils/whats-new'; import { initializeSaveStory } from '../utils/save-story/save-story'; -import { initFileSearchChannel } from '../server-channel/file-search-channel'; -import { initCreateNewStoryChannel } from '../server-channel/create-new-story-channel'; +import { parseStaticDir } from '../utils/server-statics'; +import { type OptionsWithRequiredCache, initializeWhatsNew } from '../utils/whats-new'; const interpolate = (string: string, data: Record = {}) => Object.entries(data).reduce((acc, [k, v]) => acc.replace(new RegExp(`%${k}%`, 'g'), v), string); diff --git a/code/core/src/core-server/presets/favicon.test.ts b/code/core/src/core-server/presets/favicon.test.ts index 2ba8666cc6a..7af2bfbfb34 100644 --- a/code/core/src/core-server/presets/favicon.test.ts +++ b/code/core/src/core-server/presets/favicon.test.ts @@ -1,8 +1,11 @@ -import { expect, vi, it } from 'vitest'; - import { dirname, join } from 'node:path'; -import * as fs from 'fs-extra'; + +import { expect, it, vi } from 'vitest'; + import { logger } from '@storybook/core/node-logger'; + +import * as fs from 'fs-extra'; + import * as m from './common-preset'; const defaultFavicon = join( diff --git a/code/core/src/core-server/server-channel/create-new-story-channel.test.ts b/code/core/src/core-server/server-channel/create-new-story-channel.test.ts index 81b9d74fce9..a8cecafca56 100644 --- a/code/core/src/core-server/server-channel/create-new-story-channel.test.ts +++ b/code/core/src/core-server/server-channel/create-new-story-channel.test.ts @@ -1,14 +1,18 @@ -import { describe, it, expect, vi, beforeEach } from 'vitest'; -import { initCreateNewStoryChannel } from './create-new-story-channel'; import path from 'node:path'; + +import { beforeEach, describe, expect, it, vi } from 'vitest'; + import type { ChannelTransport } from '@storybook/core/channels'; import { Channel } from '@storybook/core/channels'; + import type { CreateNewStoryRequestPayload, RequestData } from '@storybook/core/core-events'; import { CREATE_NEW_STORYFILE_REQUEST, CREATE_NEW_STORYFILE_RESPONSE, } from '@storybook/core/core-events'; +import { initCreateNewStoryChannel } from './create-new-story-channel'; + vi.mock('@storybook/core/common', async (importOriginal) => { const actual = await importOriginal(); return { diff --git a/code/core/src/core-server/server-channel/create-new-story-channel.ts b/code/core/src/core-server/server-channel/create-new-story-channel.ts index f30fdf2d57a..8362b8ff161 100644 --- a/code/core/src/core-server/server-channel/create-new-story-channel.ts +++ b/code/core/src/core-server/server-channel/create-new-story-channel.ts @@ -1,6 +1,11 @@ -import type { CoreConfig, Options } from '@storybook/core/types'; +import { existsSync } from 'node:fs'; +import { writeFile } from 'node:fs/promises'; +import path from 'node:path'; + import type { Channel } from '@storybook/core/channels'; import { telemetry } from '@storybook/core/telemetry'; +import type { CoreConfig, Options } from '@storybook/core/types'; + import type { CreateNewStoryErrorPayload, CreateNewStoryRequestPayload, @@ -12,11 +17,9 @@ import { CREATE_NEW_STORYFILE_REQUEST, CREATE_NEW_STORYFILE_RESPONSE, } from '@storybook/core/core-events'; -import { writeFile } from 'node:fs/promises'; -import { existsSync } from 'node:fs'; + import { getNewStoryFile } from '../utils/get-new-story-file'; import { getStoryId } from '../utils/get-story-id'; -import path from 'node:path'; export function initCreateNewStoryChannel( channel: Channel, diff --git a/code/core/src/core-server/server-channel/file-search-channel.test.ts b/code/core/src/core-server/server-channel/file-search-channel.test.ts index bb27cfcb1e0..5594b8a844b 100644 --- a/code/core/src/core-server/server-channel/file-search-channel.test.ts +++ b/code/core/src/core-server/server-channel/file-search-channel.test.ts @@ -1,13 +1,14 @@ // @vitest-environment happy-dom +import { beforeEach, describe, expect, it, vi } from 'vitest'; import type { ChannelTransport } from '@storybook/core/channels'; import { Channel } from '@storybook/core/channels'; -import type { RequestData, FileComponentSearchRequestPayload } from '@storybook/core/core-events'; + +import type { FileComponentSearchRequestPayload, RequestData } from '@storybook/core/core-events'; import { - FILE_COMPONENT_SEARCH_RESPONSE, FILE_COMPONENT_SEARCH_REQUEST, + FILE_COMPONENT_SEARCH_RESPONSE, } from '@storybook/core/core-events'; -import { beforeEach, describe, expect, vi, it } from 'vitest'; import { initFileSearchChannel } from './file-search-channel'; diff --git a/code/core/src/core-server/server-channel/file-search-channel.ts b/code/core/src/core-server/server-channel/file-search-channel.ts index aaf6af62af3..f3d0655d8ca 100644 --- a/code/core/src/core-server/server-channel/file-search-channel.ts +++ b/code/core/src/core-server/server-channel/file-search-channel.ts @@ -1,15 +1,14 @@ -import type { CoreConfig, Options, SupportedRenderers } from '@storybook/core/types'; +import path from 'node:path'; + import type { Channel } from '@storybook/core/channels'; import { extractProperRendererNameFromFramework, getFrameworkName, getProjectRoot, } from '@storybook/core/common'; -import path from 'node:path'; -import fs from 'fs/promises'; +import { telemetry } from '@storybook/core/telemetry'; +import type { CoreConfig, Options, SupportedRenderers } from '@storybook/core/types'; -import { getParser } from '../utils/parser'; -import { searchFiles } from '../utils/search-files'; import type { FileComponentSearchRequestPayload, FileComponentSearchResponsePayload, @@ -20,8 +19,12 @@ import { FILE_COMPONENT_SEARCH_REQUEST, FILE_COMPONENT_SEARCH_RESPONSE, } from '@storybook/core/core-events'; + +import fs from 'fs/promises'; + import { doesStoryFileExist, getStoryMetadata } from '../utils/get-new-story-file'; -import { telemetry } from '@storybook/core/telemetry'; +import { getParser } from '../utils/parser'; +import { searchFiles } from '../utils/search-files'; export async function initFileSearchChannel( channel: Channel, diff --git a/code/core/src/core-server/standalone.ts b/code/core/src/core-server/standalone.ts index 72a98d61711..d7946357814 100644 --- a/code/core/src/core-server/standalone.ts +++ b/code/core/src/core-server/standalone.ts @@ -1,7 +1,8 @@ -import { buildStaticStandalone } from './build-static'; -import { buildDevStandalone } from './build-dev'; import { dirname } from 'node:path'; +import { buildDevStandalone } from './build-dev'; +import { buildStaticStandalone } from './build-static'; + async function build(options: any = {}, frameworkOptions: any = {}) { const { mode = 'dev' } = options; const packageJsonDir = dirname(require.resolve('@storybook/core/package.json')); diff --git a/code/core/src/core-server/utils/StoryIndexGenerator.test.ts b/code/core/src/core-server/utils/StoryIndexGenerator.test.ts index 1d0b479f459..94a169c2a9f 100644 --- a/code/core/src/core-server/utils/StoryIndexGenerator.test.ts +++ b/code/core/src/core-server/utils/StoryIndexGenerator.test.ts @@ -1,17 +1,18 @@ /* eslint-disable @typescript-eslint/no-shadow */ +import path from 'node:path'; -import { describe, beforeEach, it, expect, vi } from 'vitest'; +import { beforeEach, describe, expect, it, vi } from 'vitest'; -import path from 'node:path'; import { normalizeStoriesEntry } from '@storybook/core/common'; import type { NormalizedStoriesSpecifier, StoryIndexEntry } from '@storybook/core/types'; -import { readCsf, getStorySortParameter } from '@storybook/core/csf-tools'; import { toId } from '@storybook/csf'; + +import { getStorySortParameter, readCsf } from '@storybook/core/csf-tools'; import { logger, once } from '@storybook/core/node-logger'; +import { csfIndexer } from '../presets/common-preset'; import type { StoryIndexGeneratorOptions } from './StoryIndexGenerator'; import { StoryIndexGenerator } from './StoryIndexGenerator'; -import { csfIndexer } from '../presets/common-preset'; vi.mock('@storybook/csf', async (importOriginal) => { const csf = await importOriginal(); diff --git a/code/core/src/core-server/utils/StoryIndexGenerator.ts b/code/core/src/core-server/utils/StoryIndexGenerator.ts index 64aa9744e00..cb880449ab5 100644 --- a/code/core/src/core-server/utils/StoryIndexGenerator.ts +++ b/code/core/src/core-server/utils/StoryIndexGenerator.ts @@ -1,34 +1,37 @@ /* eslint-disable no-underscore-dangle */ import path from 'node:path'; -import chalk from 'chalk'; -import fs from 'fs-extra'; -import slash from 'slash'; -import invariant from 'tiny-invariant'; -import * as TsconfigPaths from 'tsconfig-paths'; -import { findUp } from 'find-up'; +import { commonGlobOptions, normalizeStoryPath } from '@storybook/core/common'; import type { - IndexEntry, - StoryIndexEntry, DocsIndexEntry, - NormalizedStoriesSpecifier, DocsOptions, + IndexEntry, + IndexInputStats, + Indexer, + NormalizedStoriesSpecifier, Path, - Tag, StoryIndex, - Indexer, + StoryIndexEntry, StorybookConfigRaw, - IndexInputStats, + Tag, } from '@storybook/core/types'; -import { userOrAutoTitleFromSpecifier, sortStoriesV7 } from '@storybook/core/preview-api'; -import { commonGlobOptions, normalizeStoryPath } from '@storybook/core/common'; -import { logger, once } from '@storybook/core/node-logger'; +import { combineTags, storyNameFromExport, toId } from '@storybook/csf'; + import { getStorySortParameter, loadConfig } from '@storybook/core/csf-tools'; -import { storyNameFromExport, toId, combineTags } from '@storybook/csf'; +import { logger, once } from '@storybook/core/node-logger'; +import { sortStoriesV7, userOrAutoTitleFromSpecifier } from '@storybook/core/preview-api'; + +import chalk from 'chalk'; +import { findUp } from 'find-up'; +import fs from 'fs-extra'; +import slash from 'slash'; +import invariant from 'tiny-invariant'; import { dedent } from 'ts-dedent'; -import { autoName } from './autoName'; +import * as TsconfigPaths from 'tsconfig-paths'; + import { IndexingError, MultipleIndexingError } from './IndexingError'; -import { addStats, type IndexStatsSummary } from './summarizeStats'; +import { autoName } from './autoName'; +import { type IndexStatsSummary, addStats } from './summarizeStats'; // Extended type to keep track of the csf meta id so we know the component id when referencing docs in `extractDocs` type StoryIndexEntryWithExtra = StoryIndexEntry & { diff --git a/code/core/src/core-server/utils/__tests__/IndexingError.test.ts b/code/core/src/core-server/utils/__tests__/IndexingError.test.ts index 20154aa4250..ad228d2dbb2 100644 --- a/code/core/src/core-server/utils/__tests__/IndexingError.test.ts +++ b/code/core/src/core-server/utils/__tests__/IndexingError.test.ts @@ -1,4 +1,5 @@ -import { describe, it, expect } from 'vitest'; +import { describe, expect, it } from 'vitest'; + import { IndexingError, MultipleIndexingError } from '../IndexingError'; it('formats single file errors', () => { diff --git a/code/core/src/core-server/utils/__tests__/autoName.test.ts b/code/core/src/core-server/utils/__tests__/autoName.test.ts index 64954fc55d1..273178340f2 100644 --- a/code/core/src/core-server/utils/__tests__/autoName.test.ts +++ b/code/core/src/core-server/utils/__tests__/autoName.test.ts @@ -1,4 +1,5 @@ -import { it, expect } from 'vitest'; +import { expect, it } from 'vitest'; + import { autoName } from '../autoName'; it('pulls name from named MDX files', () => { diff --git a/code/core/src/core-server/utils/__tests__/index-extraction.test.ts b/code/core/src/core-server/utils/__tests__/index-extraction.test.ts index 6fbbdeb41c6..beb16cc73a2 100644 --- a/code/core/src/core-server/utils/__tests__/index-extraction.test.ts +++ b/code/core/src/core-server/utils/__tests__/index-extraction.test.ts @@ -1,6 +1,7 @@ -import { describe, it, expect, vi } from 'vitest'; - import path from 'node:path'; + +import { describe, expect, it, vi } from 'vitest'; + import { normalizeStoriesEntry } from '@storybook/core/common'; import type { NormalizedStoriesSpecifier } from '@storybook/core/types'; diff --git a/code/core/src/core-server/utils/__tests__/remove-mdx-stories.test.ts b/code/core/src/core-server/utils/__tests__/remove-mdx-stories.test.ts index 2dff9f7810e..f1342ad48a9 100644 --- a/code/core/src/core-server/utils/__tests__/remove-mdx-stories.test.ts +++ b/code/core/src/core-server/utils/__tests__/remove-mdx-stories.test.ts @@ -1,9 +1,13 @@ -import { glob as globOriginal } from 'glob'; -import { type StoriesEntry } from '@storybook/core/types'; -import { normalizeStoriesEntry } from '@storybook/core/common'; import { join } from 'node:path'; + +import { describe, expect, it, vi } from 'vitest'; + +import { normalizeStoriesEntry } from '@storybook/core/common'; +import { type StoriesEntry } from '@storybook/core/types'; + +import { glob as globOriginal } from 'glob'; import slash from 'slash'; -import { vi, it, describe, expect } from 'vitest'; + import { removeMDXEntries } from '../remove-mdx-entries'; const configDir = '/configDir/'; diff --git a/code/core/src/core-server/utils/__tests__/server-address.test.ts b/code/core/src/core-server/utils/__tests__/server-address.test.ts index 4b3636ee9e8..cc9b3dfa6f5 100644 --- a/code/core/src/core-server/utils/__tests__/server-address.test.ts +++ b/code/core/src/core-server/utils/__tests__/server-address.test.ts @@ -1,5 +1,7 @@ -import { describe, beforeEach, it, expect, vi } from 'vitest'; +import { beforeEach, describe, expect, it, vi } from 'vitest'; + import os, { type NetworkInterfaceInfoIPv4 } from 'os'; + import { getServerAddresses } from '../server-address'; vi.mock('os'); diff --git a/code/core/src/core-server/utils/__tests__/server-channel.test.ts b/code/core/src/core-server/utils/__tests__/server-channel.test.ts index 0078b6d78cf..c43955bd588 100644 --- a/code/core/src/core-server/utils/__tests__/server-channel.test.ts +++ b/code/core/src/core-server/utils/__tests__/server-channel.test.ts @@ -1,10 +1,12 @@ -import { describe, expect, vi, it } from 'vitest'; -import type { Server } from 'http'; +import { describe, expect, it, vi } from 'vitest'; + import { Channel } from '@storybook/core/channels'; import { EventEmitter } from 'events'; +import type { Server } from 'http'; import { stringify } from 'telejson'; -import { getServerChannel, ServerChannelTransport } from '../get-server-channel'; + +import { ServerChannelTransport, getServerChannel } from '../get-server-channel'; describe('getServerChannel', () => { it('should return a channel', () => { diff --git a/code/core/src/core-server/utils/__tests__/server-statics.test.ts b/code/core/src/core-server/utils/__tests__/server-statics.test.ts index 7033bec5770..c739e4ac5fe 100644 --- a/code/core/src/core-server/utils/__tests__/server-statics.test.ts +++ b/code/core/src/core-server/utils/__tests__/server-statics.test.ts @@ -1,6 +1,9 @@ -import { describe, it, expect, vi, beforeEach } from 'vitest'; -import fs from 'fs-extra'; import path from 'node:path'; + +import { beforeEach, describe, expect, it, vi } from 'vitest'; + +import fs from 'fs-extra'; + import { onlyWindows, skipWindows } from '../../../../../vitest.helpers'; import { parseStaticDir } from '../server-statics'; diff --git a/code/core/src/core-server/utils/autoName.ts b/code/core/src/core-server/utils/autoName.ts index aa916c86566..953124f7db0 100644 --- a/code/core/src/core-server/utils/autoName.ts +++ b/code/core/src/core-server/utils/autoName.ts @@ -1,6 +1,7 @@ -import type { Path } from '@storybook/core/types'; import { basename } from 'node:path'; +import type { Path } from '@storybook/core/types'; + /** * Calculate a name to use for a docs entry if not specified. The rule is: * diff --git a/code/core/src/core-server/utils/copy-all-static-files.ts b/code/core/src/core-server/utils/copy-all-static-files.ts index 344bc12eeb7..b17ceaa1f8d 100644 --- a/code/core/src/core-server/utils/copy-all-static-files.ts +++ b/code/core/src/core-server/utils/copy-all-static-files.ts @@ -1,8 +1,12 @@ -import chalk from 'chalk'; -import fs from 'fs-extra'; import { join, relative } from 'node:path'; -import { logger } from '@storybook/core/node-logger'; + import { getDirectoryFromWorkingDir } from '@storybook/core/common'; + +import { logger } from '@storybook/core/node-logger'; + +import chalk from 'chalk'; +import fs from 'fs-extra'; + import { parseStaticDir } from './server-statics'; export async function copyAllStaticFiles(staticDirs: any[] | undefined, outputDir: string) { diff --git a/code/core/src/core-server/utils/doTelemetry.ts b/code/core/src/core-server/utils/doTelemetry.ts index be9479cf334..c7d92c324d8 100644 --- a/code/core/src/core-server/utils/doTelemetry.ts +++ b/code/core/src/core-server/utils/doTelemetry.ts @@ -1,12 +1,14 @@ -import invariant from 'tiny-invariant'; +import { getPrecedingUpgrade, telemetry } from '@storybook/core/telemetry'; import type { CoreConfig, Options, StoryIndex } from '@storybook/core/types'; -import { telemetry, getPrecedingUpgrade } from '@storybook/core/telemetry'; -import { useStorybookMetadata } from './metadata'; + +import invariant from 'tiny-invariant'; + +import { sendTelemetryError } from '../withTelemetry'; import type { StoryIndexGenerator } from './StoryIndexGenerator'; -import { summarizeIndex } from './summarizeIndex'; +import { useStorybookMetadata } from './metadata'; import { router } from './router'; +import { summarizeIndex } from './summarizeIndex'; import { versionStatus } from './versionStatus'; -import { sendTelemetryError } from '../withTelemetry'; export async function doTelemetry( core: CoreConfig, diff --git a/code/core/src/core-server/utils/get-builders.ts b/code/core/src/core-server/utils/get-builders.ts index 13a5365c91e..5b654a14c95 100644 --- a/code/core/src/core-server/utils/get-builders.ts +++ b/code/core/src/core-server/utils/get-builders.ts @@ -1,6 +1,8 @@ +import { pathToFileURL } from 'node:url'; + import type { Builder, Options } from '@storybook/core/types'; + import { MissingBuilderError } from '@storybook/core/server-errors'; -import { pathToFileURL } from 'node:url'; export async function getManagerBuilder(): Promise> { return import('@storybook/core/builder-manager'); diff --git a/code/core/src/core-server/utils/get-component-variable-name.test.ts b/code/core/src/core-server/utils/get-component-variable-name.test.ts index 07b2fb5599a..222f97226d5 100644 --- a/code/core/src/core-server/utils/get-component-variable-name.test.ts +++ b/code/core/src/core-server/utils/get-component-variable-name.test.ts @@ -1,4 +1,5 @@ import { describe, expect, it } from 'vitest'; + import { getComponentVariableName } from './get-component-variable-name'; describe('get-variable-name', () => { diff --git a/code/core/src/core-server/utils/get-new-story-file.test.ts b/code/core/src/core-server/utils/get-new-story-file.test.ts index c1a4e5e083d..354e4470cfa 100644 --- a/code/core/src/core-server/utils/get-new-story-file.test.ts +++ b/code/core/src/core-server/utils/get-new-story-file.test.ts @@ -1,6 +1,8 @@ +import path from 'node:path'; + import { describe, expect, it, vi } from 'vitest'; + import { getNewStoryFile } from './get-new-story-file'; -import path from 'node:path'; vi.mock('@storybook/core/common', async (importOriginal) => { const actual = await importOriginal(); diff --git a/code/core/src/core-server/utils/get-new-story-file.ts b/code/core/src/core-server/utils/get-new-story-file.ts index 61de2023499..969bca51006 100644 --- a/code/core/src/core-server/utils/get-new-story-file.ts +++ b/code/core/src/core-server/utils/get-new-story-file.ts @@ -1,16 +1,19 @@ -import type { Options } from '@storybook/core/types'; +import fs from 'node:fs'; +import path from 'node:path'; + import { extractProperRendererNameFromFramework, getFrameworkName, getProjectRoot, rendererPackages, } from '@storybook/core/common'; -import path from 'node:path'; -import fs from 'node:fs'; -import { getTypeScriptTemplateForNewStoryFile } from './new-story-templates/typescript'; -import { getJavaScriptTemplateForNewStoryFile } from './new-story-templates/javascript'; +import type { Options } from '@storybook/core/types'; + import type { CreateNewStoryRequestPayload } from '@storybook/core/core-events'; +import { getJavaScriptTemplateForNewStoryFile } from './new-story-templates/javascript'; +import { getTypeScriptTemplateForNewStoryFile } from './new-story-templates/typescript'; + export async function getNewStoryFile( { componentFilePath, diff --git a/code/core/src/core-server/utils/get-server-channel.ts b/code/core/src/core-server/utils/get-server-channel.ts index d7f8c4721de..ce5844e6235 100644 --- a/code/core/src/core-server/utils/get-server-channel.ts +++ b/code/core/src/core-server/utils/get-server-channel.ts @@ -1,8 +1,9 @@ -import WebSocket, { WebSocketServer } from 'ws'; -import { isJSON, parse, stringify } from 'telejson'; import type { ChannelHandler } from '@storybook/core/channels'; import { Channel } from '@storybook/core/channels'; +import { isJSON, parse, stringify } from 'telejson'; +import WebSocket, { WebSocketServer } from 'ws'; + type Server = NonNullable[0]>['server']>; /** diff --git a/code/core/src/core-server/utils/get-story-id.test.ts b/code/core/src/core-server/utils/get-story-id.test.ts index 26fedcbe03e..7132aeea13e 100644 --- a/code/core/src/core-server/utils/get-story-id.test.ts +++ b/code/core/src/core-server/utils/get-story-id.test.ts @@ -1,5 +1,7 @@ import path from 'node:path'; + import { describe, expect, it } from 'vitest'; + import { getStoryId } from './get-story-id'; describe('getStoryId', () => { diff --git a/code/core/src/core-server/utils/get-story-id.ts b/code/core/src/core-server/utils/get-story-id.ts index ef44c263f09..5abbb799a48 100644 --- a/code/core/src/core-server/utils/get-story-id.ts +++ b/code/core/src/core-server/utils/get-story-id.ts @@ -1,9 +1,13 @@ -import type { Options } from '@storybook/core/types'; -import { dedent } from 'ts-dedent'; -import { normalizeStories, normalizeStoryPath } from '@storybook/core/common'; import path from 'node:path'; + +import { normalizeStories, normalizeStoryPath } from '@storybook/core/common'; +import type { Options } from '@storybook/core/types'; import { sanitize, storyNameFromExport, toId } from '@storybook/csf'; + import { userOrAutoTitleFromSpecifier } from '@storybook/core/preview-api'; + +import { dedent } from 'ts-dedent'; + import { posix } from './posix'; interface StoryIdData { diff --git a/code/core/src/core-server/utils/getStoryIndexGenerator.ts b/code/core/src/core-server/utils/getStoryIndexGenerator.ts index b61a5490c3b..6e5e4960b13 100644 --- a/code/core/src/core-server/utils/getStoryIndexGenerator.ts +++ b/code/core/src/core-server/utils/getStoryIndexGenerator.ts @@ -1,9 +1,10 @@ -import type { DocsOptions, Options } from '@storybook/core/types'; import { normalizeStories } from '@storybook/core/common'; -import { useStoriesJson } from './stories-json'; -import type { ServerChannel } from './get-server-channel'; +import type { DocsOptions, Options } from '@storybook/core/types'; + import { StoryIndexGenerator } from './StoryIndexGenerator'; +import type { ServerChannel } from './get-server-channel'; import { router } from './router'; +import { useStoriesJson } from './stories-json'; export async function getStoryIndexGenerator( features: { diff --git a/code/core/src/core-server/utils/metadata.ts b/code/core/src/core-server/utils/metadata.ts index a3a2c755b33..cc047d84176 100644 --- a/code/core/src/core-server/utils/metadata.ts +++ b/code/core/src/core-server/utils/metadata.ts @@ -1,7 +1,8 @@ -import { writeJSON } from 'fs-extra'; -import type { Request, Response, Router } from 'express'; import { getStorybookMetadata } from '@storybook/core/telemetry'; +import type { Request, Response, Router } from 'express'; +import { writeJSON } from 'fs-extra'; + export async function extractStorybookMetadata(outputFile: string, configDir: string) { const storybookMetadata = await getStorybookMetadata(configDir); diff --git a/code/core/src/core-server/utils/middleware.ts b/code/core/src/core-server/utils/middleware.ts index 33ad1e64177..a583c5c7029 100644 --- a/code/core/src/core-server/utils/middleware.ts +++ b/code/core/src/core-server/utils/middleware.ts @@ -1,5 +1,5 @@ -import path from 'node:path'; import fs from 'node:fs'; +import path from 'node:path'; const fileExists = (basename: string) => ['.js', '.cjs'].reduce((found: string, ext: string) => { diff --git a/code/core/src/core-server/utils/new-story-templates/javascript.test.ts b/code/core/src/core-server/utils/new-story-templates/javascript.test.ts index 525c0fe25f4..31d7f768603 100644 --- a/code/core/src/core-server/utils/new-story-templates/javascript.test.ts +++ b/code/core/src/core-server/utils/new-story-templates/javascript.test.ts @@ -1,4 +1,5 @@ import { describe, expect, it } from 'vitest'; + import { getJavaScriptTemplateForNewStoryFile } from './javascript'; describe('javascript', () => { diff --git a/code/core/src/core-server/utils/new-story-templates/javascript.ts b/code/core/src/core-server/utils/new-story-templates/javascript.ts index cc59e78cf34..12742502b41 100644 --- a/code/core/src/core-server/utils/new-story-templates/javascript.ts +++ b/code/core/src/core-server/utils/new-story-templates/javascript.ts @@ -1,4 +1,5 @@ import { dedent } from 'ts-dedent'; + import { getComponentVariableName } from '../get-component-variable-name'; interface JavaScriptTemplateData { diff --git a/code/core/src/core-server/utils/new-story-templates/typescript.test.ts b/code/core/src/core-server/utils/new-story-templates/typescript.test.ts index 338b3209ce9..b470cf0699b 100644 --- a/code/core/src/core-server/utils/new-story-templates/typescript.test.ts +++ b/code/core/src/core-server/utils/new-story-templates/typescript.test.ts @@ -1,4 +1,5 @@ import { describe, expect, it } from 'vitest'; + import { getTypeScriptTemplateForNewStoryFile } from './typescript'; describe('typescript', () => { diff --git a/code/core/src/core-server/utils/new-story-templates/typescript.ts b/code/core/src/core-server/utils/new-story-templates/typescript.ts index d9e0acaa12c..892772f06f2 100644 --- a/code/core/src/core-server/utils/new-story-templates/typescript.ts +++ b/code/core/src/core-server/utils/new-story-templates/typescript.ts @@ -1,4 +1,5 @@ import { dedent } from 'ts-dedent'; + import { getComponentVariableName } from '../get-component-variable-name'; interface TypeScriptTemplateData { diff --git a/code/core/src/core-server/utils/open-in-browser.ts b/code/core/src/core-server/utils/open-in-browser.ts index b4fe5d77d96..aa5f745b8ce 100644 --- a/code/core/src/core-server/utils/open-in-browser.ts +++ b/code/core/src/core-server/utils/open-in-browser.ts @@ -1,7 +1,9 @@ import { logger } from '@storybook/core/node-logger'; -import betterOpn from 'better-opn'; // betterOpn alias used because also loading open -import open from 'open'; + import getDefaultBrowser from '@aw-web-design/x-default-browser'; +import betterOpn from 'better-opn'; +// betterOpn alias used because also loading open +import open from 'open'; import { dedent } from 'ts-dedent'; export function openInBrowser(address: string) { diff --git a/code/core/src/core-server/utils/output-startup-information.ts b/code/core/src/core-server/utils/output-startup-information.ts index 092a29671aa..cfe60bef6cc 100644 --- a/code/core/src/core-server/utils/output-startup-information.ts +++ b/code/core/src/core-server/utils/output-startup-information.ts @@ -1,10 +1,13 @@ -import chalk from 'chalk'; +import type { VersionCheck } from '@storybook/core/types'; + import { colors } from '@storybook/core/node-logger'; + import boxen from 'boxen'; -import { dedent } from 'ts-dedent'; +import chalk from 'chalk'; import Table from 'cli-table3'; import prettyTime from 'pretty-hrtime'; -import type { VersionCheck } from '@storybook/core/types'; +import { dedent } from 'ts-dedent'; + import { createUpdateMessage } from './update-check'; export function outputStartupInformation(options: { diff --git a/code/core/src/core-server/utils/output-stats.ts b/code/core/src/core-server/utils/output-stats.ts index 0b99ef1f4eb..d54bc6938b4 100644 --- a/code/core/src/core-server/utils/output-stats.ts +++ b/code/core/src/core-server/utils/output-stats.ts @@ -1,9 +1,12 @@ -import { stringifyStream } from '@discoveryjs/json-ext'; -import { logger } from '@storybook/core/node-logger'; +import path from 'node:path'; + import type { Stats } from '@storybook/core/types'; + +import { logger } from '@storybook/core/node-logger'; + +import { stringifyStream } from '@discoveryjs/json-ext'; import chalk from 'chalk'; import fs from 'fs-extra'; -import path from 'node:path'; export async function outputStats(directory: string, previewStats?: any, managerStats?: any) { if (previewStats) { diff --git a/code/core/src/core-server/utils/parser/generic-parser.test.ts b/code/core/src/core-server/utils/parser/generic-parser.test.ts index 17995e7ec0f..3a0002dde4a 100644 --- a/code/core/src/core-server/utils/parser/generic-parser.test.ts +++ b/code/core/src/core-server/utils/parser/generic-parser.test.ts @@ -1,7 +1,9 @@ -import { describe, expect, it } from 'vitest'; +import fs from 'node:fs'; import path from 'node:path'; + +import { describe, expect, it } from 'vitest'; + import { GenericParser } from './generic-parser'; -import fs from 'node:fs'; const genericParser = new GenericParser(); diff --git a/code/core/src/core-server/utils/parser/generic-parser.ts b/code/core/src/core-server/utils/parser/generic-parser.ts index e3c4754fab4..cbce263ac9e 100644 --- a/code/core/src/core-server/utils/parser/generic-parser.ts +++ b/code/core/src/core-server/utils/parser/generic-parser.ts @@ -1,5 +1,5 @@ -import * as babelParser from '@babel/parser'; import { types } from '@babel/core'; +import * as babelParser from '@babel/parser'; import type { Parser, ParserResult } from './types'; diff --git a/code/core/src/core-server/utils/parser/index.ts b/code/core/src/core-server/utils/parser/index.ts index 5e3aa13fd86..753e2c1d8af 100644 --- a/code/core/src/core-server/utils/parser/index.ts +++ b/code/core/src/core-server/utils/parser/index.ts @@ -1,4 +1,5 @@ import type { SupportedRenderers } from '@storybook/core/types'; + import { GenericParser } from './generic-parser'; import type { Parser } from './types'; diff --git a/code/core/src/core-server/utils/posix.test.ts b/code/core/src/core-server/utils/posix.test.ts index 23c8d2ca3be..960d799e30b 100644 --- a/code/core/src/core-server/utils/posix.test.ts +++ b/code/core/src/core-server/utils/posix.test.ts @@ -1,4 +1,5 @@ import { describe, expect, it } from 'vitest'; + import { posix } from './posix'; describe('posix', () => { diff --git a/code/core/src/core-server/utils/remove-mdx-entries.ts b/code/core/src/core-server/utils/remove-mdx-entries.ts index d9d5a285dcc..f71488712a4 100644 --- a/code/core/src/core-server/utils/remove-mdx-entries.ts +++ b/code/core/src/core-server/utils/remove-mdx-entries.ts @@ -1,8 +1,10 @@ -import type { Options, StoriesEntry } from '@storybook/core/types'; -import { normalizeStories, commonGlobOptions } from '@storybook/core/common'; import { isAbsolute, join, relative } from 'node:path'; -import slash from 'slash'; + +import { commonGlobOptions, normalizeStories } from '@storybook/core/common'; +import type { Options, StoriesEntry } from '@storybook/core/types'; + import { glob } from 'glob'; +import slash from 'slash'; export async function removeMDXEntries( entries: StoriesEntry[], diff --git a/code/core/src/core-server/utils/save-story/duplicate-story-with-new-name.test.ts b/code/core/src/core-server/utils/save-story/duplicate-story-with-new-name.test.ts index da4b26eabb2..2bdb98544d2 100644 --- a/code/core/src/core-server/utils/save-story/duplicate-story-with-new-name.test.ts +++ b/code/core/src/core-server/utils/save-story/duplicate-story-with-new-name.test.ts @@ -1,11 +1,14 @@ /* eslint-disable no-underscore-dangle */ -import { describe, test, expect } from 'vitest'; -import { readCsf, printCsf } from '@storybook/core/csf-tools'; +import { join } from 'node:path'; + +import { describe, expect, test } from 'vitest'; + +import { printCsf, readCsf } from '@storybook/core/csf-tools'; -import { duplicateStoryWithNewName } from './duplicate-story-with-new-name'; import { readFile } from 'fs/promises'; -import { join } from 'node:path'; import { format } from 'prettier'; + +import { duplicateStoryWithNewName } from './duplicate-story-with-new-name'; import { getDiff } from './getDiff'; const makeTitle = (userTitle: string) => userTitle; diff --git a/code/core/src/core-server/utils/save-story/duplicate-story-with-new-name.ts b/code/core/src/core-server/utils/save-story/duplicate-story-with-new-name.ts index f93c02d12af..25e634a0faf 100644 --- a/code/core/src/core-server/utils/save-story/duplicate-story-with-new-name.ts +++ b/code/core/src/core-server/utils/save-story/duplicate-story-with-new-name.ts @@ -1,7 +1,9 @@ /* eslint-disable no-underscore-dangle */ import type { CsfFile } from '@storybook/core/csf-tools'; -import * as t from '@babel/types'; + import bt from '@babel/traverse'; +import * as t from '@babel/types'; + import { SaveStoryError } from './utils'; // @ts-expect-error (needed due to it's use of `exports.default`) diff --git a/code/core/src/core-server/utils/save-story/mocks/csf-variances.stories.tsx b/code/core/src/core-server/utils/save-story/mocks/csf-variances.stories.tsx index 9fcbc4bd4df..35081f422ae 100644 --- a/code/core/src/core-server/utils/save-story/mocks/csf-variances.stories.tsx +++ b/code/core/src/core-server/utils/save-story/mocks/csf-variances.stories.tsx @@ -1,5 +1,6 @@ import React from 'react'; import type { FC } from 'react'; + import type { Meta, StoryObj } from '@storybook/react'; export default { diff --git a/code/core/src/core-server/utils/save-story/mocks/data-variances.stories.tsx b/code/core/src/core-server/utils/save-story/mocks/data-variances.stories.tsx index ea2f79bdcc3..e049efd5339 100644 --- a/code/core/src/core-server/utils/save-story/mocks/data-variances.stories.tsx +++ b/code/core/src/core-server/utils/save-story/mocks/data-variances.stories.tsx @@ -1,5 +1,6 @@ import React from 'react'; import type { FC } from 'react'; + import type { Meta, StoryObj } from '@storybook/react'; export default { diff --git a/code/core/src/core-server/utils/save-story/mocks/export-variances.stories.tsx b/code/core/src/core-server/utils/save-story/mocks/export-variances.stories.tsx index 7c853f48446..3fc94bcceaa 100644 --- a/code/core/src/core-server/utils/save-story/mocks/export-variances.stories.tsx +++ b/code/core/src/core-server/utils/save-story/mocks/export-variances.stories.tsx @@ -1,5 +1,6 @@ import React from 'react'; import type { FC } from 'react'; + import type { Meta, StoryObj } from '@storybook/react'; export default { diff --git a/code/core/src/core-server/utils/save-story/mocks/typescript-constructs.stories.tsx b/code/core/src/core-server/utils/save-story/mocks/typescript-constructs.stories.tsx index d44c95c446b..0d4aa951ad8 100644 --- a/code/core/src/core-server/utils/save-story/mocks/typescript-constructs.stories.tsx +++ b/code/core/src/core-server/utils/save-story/mocks/typescript-constructs.stories.tsx @@ -1,5 +1,6 @@ import React from 'react'; import type { FC } from 'react'; + import type { Meta, StoryObj } from '@storybook/react'; export default { diff --git a/code/core/src/core-server/utils/save-story/mocks/unsupported-csf-variances.stories.tsx b/code/core/src/core-server/utils/save-story/mocks/unsupported-csf-variances.stories.tsx index b86095381fa..7a300959e0a 100644 --- a/code/core/src/core-server/utils/save-story/mocks/unsupported-csf-variances.stories.tsx +++ b/code/core/src/core-server/utils/save-story/mocks/unsupported-csf-variances.stories.tsx @@ -1,5 +1,6 @@ import React from 'react'; import type { FC } from 'react'; + import type { Meta } from '@storybook/react'; export default { diff --git a/code/core/src/core-server/utils/save-story/save-story.ts b/code/core/src/core-server/utils/save-story/save-story.ts index 5369d99a4cb..c912647770d 100644 --- a/code/core/src/core-server/utils/save-story/save-story.ts +++ b/code/core/src/core-server/utils/save-story/save-story.ts @@ -1,6 +1,13 @@ /* eslint-disable no-underscore-dangle */ import fs from 'node:fs/promises'; +import { basename, join } from 'node:path'; + import type { Channel } from '@storybook/core/channels'; +import { formatFileContent } from '@storybook/core/common'; +import { telemetry } from '@storybook/core/telemetry'; +import type { CoreConfig, Options } from '@storybook/core/types'; +import { storyNameFromExport, toId } from '@storybook/csf'; + import type { RequestData, ResponseData, @@ -12,16 +19,11 @@ import { SAVE_STORY_RESPONSE, STORY_RENDERED, } from '@storybook/core/core-events'; -import { storyNameFromExport, toId } from '@storybook/csf'; import { printCsf, readCsf } from '@storybook/core/csf-tools'; import { logger } from '@storybook/core/node-logger'; -import type { CoreConfig, Options } from '@storybook/core/types'; -import { telemetry } from '@storybook/core/telemetry'; -import { basename, join } from 'node:path'; -import { updateArgsInCsfFile } from './update-args-in-csf-file'; import { duplicateStoryWithNewName } from './duplicate-story-with-new-name'; -import { formatFileContent } from '@storybook/core/common'; +import { updateArgsInCsfFile } from './update-args-in-csf-file'; import { SaveStoryError } from './utils'; const parseArgs = (args: string): Record => diff --git a/code/core/src/core-server/utils/save-story/update-args-in-csf-file.test.ts b/code/core/src/core-server/utils/save-story/update-args-in-csf-file.test.ts index c06f71de482..4a87fbeff6c 100644 --- a/code/core/src/core-server/utils/save-story/update-args-in-csf-file.test.ts +++ b/code/core/src/core-server/utils/save-story/update-args-in-csf-file.test.ts @@ -1,12 +1,15 @@ /* eslint-disable no-underscore-dangle */ -import { describe, test, expect } from 'vitest'; -import { readCsf, printCsf } from '@storybook/core/csf-tools'; +import { join } from 'node:path'; + +import { describe, expect, test } from 'vitest'; + +import { printCsf, readCsf } from '@storybook/core/csf-tools'; -import { updateArgsInCsfFile } from './update-args-in-csf-file'; import { readFile } from 'fs/promises'; -import { join } from 'node:path'; import { format } from 'prettier'; + import { getDiff } from './getDiff'; +import { updateArgsInCsfFile } from './update-args-in-csf-file'; const makeTitle = (userTitle: string) => userTitle; diff --git a/code/core/src/core-server/utils/save-story/update-args-in-csf-file.ts b/code/core/src/core-server/utils/save-story/update-args-in-csf-file.ts index 8446594f1c7..9f7466ccfc0 100644 --- a/code/core/src/core-server/utils/save-story/update-args-in-csf-file.ts +++ b/code/core/src/core-server/utils/save-story/update-args-in-csf-file.ts @@ -1,7 +1,8 @@ -import * as t from '@babel/types'; import bt from '@babel/traverse'; -import { valueToAST } from './valueToAST'; +import * as t from '@babel/types'; + import { SaveStoryError } from './utils'; +import { valueToAST } from './valueToAST'; // @ts-expect-error (needed due to it's use of `exports.default`) const traverse = (bt.default || bt) as typeof bt; diff --git a/code/core/src/core-server/utils/save-story/valueToAST.ts b/code/core/src/core-server/utils/save-story/valueToAST.ts index f09dd7b65a6..b1227d8619a 100644 --- a/code/core/src/core-server/utils/save-story/valueToAST.ts +++ b/code/core/src/core-server/utils/save-story/valueToAST.ts @@ -1,5 +1,5 @@ -import * as t from '@babel/types'; import * as babylon from '@babel/parser'; +import * as t from '@babel/types'; export function valueToAST(literal: T): any { if (literal === null) { diff --git a/code/core/src/core-server/utils/search-files.test.ts b/code/core/src/core-server/utils/search-files.test.ts index 58899c35d35..81ecfe45079 100644 --- a/code/core/src/core-server/utils/search-files.test.ts +++ b/code/core/src/core-server/utils/search-files.test.ts @@ -1,5 +1,7 @@ -import { describe, expect, it } from 'vitest'; import path from 'node:path'; + +import { describe, expect, it } from 'vitest'; + import { searchFiles } from './search-files'; describe('search-files', () => { diff --git a/code/core/src/core-server/utils/server-address.test.ts b/code/core/src/core-server/utils/server-address.test.ts index 81f228c9abd..114fbfd9608 100644 --- a/code/core/src/core-server/utils/server-address.test.ts +++ b/code/core/src/core-server/utils/server-address.test.ts @@ -1,6 +1,8 @@ -import { describe, it, expect, vi } from 'vitest'; +import { describe, expect, it, vi } from 'vitest'; + import detectPort from 'detect-port'; -import { getServerAddresses, getServerPort, getServerChannelUrl } from './server-address'; + +import { getServerAddresses, getServerChannelUrl, getServerPort } from './server-address'; vi.mock('os', () => ({ default: { release: () => '' }, diff --git a/code/core/src/core-server/utils/server-address.ts b/code/core/src/core-server/utils/server-address.ts index a7c8f9f2d28..7fc59312a08 100644 --- a/code/core/src/core-server/utils/server-address.ts +++ b/code/core/src/core-server/utils/server-address.ts @@ -1,7 +1,7 @@ -import os from 'os'; - import { logger } from '@storybook/core/node-logger'; + import detectFreePort from 'detect-port'; +import os from 'os'; export function getServerAddresses( port: number, diff --git a/code/core/src/core-server/utils/server-init.ts b/code/core/src/core-server/utils/server-init.ts index 0888c37fde4..b63d663e685 100644 --- a/code/core/src/core-server/utils/server-init.ts +++ b/code/core/src/core-server/utils/server-init.ts @@ -1,4 +1,5 @@ import { logger } from '@storybook/core/node-logger'; + import type { Express } from 'express'; import { readFile } from 'fs-extra'; import http from 'http'; diff --git a/code/core/src/core-server/utils/server-statics.ts b/code/core/src/core-server/utils/server-statics.ts index a2fd5cc8a25..d359e13653c 100644 --- a/code/core/src/core-server/utils/server-statics.ts +++ b/code/core/src/core-server/utils/server-statics.ts @@ -1,12 +1,14 @@ -import { logger } from '@storybook/core/node-logger'; -import type { Options } from '@storybook/core/types'; +import path, { basename, isAbsolute } from 'node:path'; + import { getDirectoryFromWorkingDir } from '@storybook/core/common'; +import type { Options } from '@storybook/core/types'; + +import { logger } from '@storybook/core/node-logger'; + import chalk from 'chalk'; import type { Router } from 'express'; import express from 'express'; import { pathExists } from 'fs-extra'; -import path, { basename, isAbsolute } from 'node:path'; - import { dedent } from 'ts-dedent'; export async function useStatics(router: Router, options: Options) { diff --git a/code/core/src/core-server/utils/stories-json.test.ts b/code/core/src/core-server/utils/stories-json.test.ts index a4ad0fa780b..b28c2cc95a5 100644 --- a/code/core/src/core-server/utils/stories-json.test.ts +++ b/code/core/src/core-server/utils/stories-json.test.ts @@ -1,17 +1,20 @@ -import { describe, beforeEach, it, expect, vi } from 'vitest'; - -import type { Router, Request, Response } from 'express'; -import Watchpack from 'watchpack'; import path from 'node:path'; -import debounce from 'lodash/debounce.js'; -import { STORY_INDEX_INVALIDATED } from '@storybook/core/core-events'; + +import { beforeEach, describe, expect, it, vi } from 'vitest'; + import { normalizeStoriesEntry } from '@storybook/core/common'; -import { useStoriesJson, DEBOUNCE } from './stories-json'; -import type { ServerChannel } from './get-server-channel'; +import { STORY_INDEX_INVALIDATED } from '@storybook/core/core-events'; + +import type { Request, Response, Router } from 'express'; +import debounce from 'lodash/debounce.js'; +import Watchpack from 'watchpack'; + +import { csfIndexer } from '../presets/common-preset'; import type { StoryIndexGeneratorOptions } from './StoryIndexGenerator'; import { StoryIndexGenerator } from './StoryIndexGenerator'; -import { csfIndexer } from '../presets/common-preset'; +import type { ServerChannel } from './get-server-channel'; +import { DEBOUNCE, useStoriesJson } from './stories-json'; vi.mock('watchpack'); vi.mock('lodash/debounce'); diff --git a/code/core/src/core-server/utils/stories-json.ts b/code/core/src/core-server/utils/stories-json.ts index a85791dd6a9..8956a4ed7ab 100644 --- a/code/core/src/core-server/utils/stories-json.ts +++ b/code/core/src/core-server/utils/stories-json.ts @@ -1,15 +1,17 @@ import { basename } from 'node:path'; -import type { Router, Request, Response } from 'express'; -import { writeJSON } from 'fs-extra'; import type { NormalizedStoriesSpecifier, StoryIndex } from '@storybook/core/types'; -import debounce from 'lodash/debounce.js'; import { STORY_INDEX_INVALIDATED } from '@storybook/core/core-events'; + +import type { Request, Response, Router } from 'express'; +import { writeJSON } from 'fs-extra'; +import debounce from 'lodash/debounce.js'; + import type { StoryIndexGenerator } from './StoryIndexGenerator'; +import type { ServerChannel } from './get-server-channel'; import { watchStorySpecifiers } from './watch-story-specifiers'; import { watchConfig } from './watchConfig'; -import type { ServerChannel } from './get-server-channel'; export const DEBOUNCE = 100; diff --git a/code/core/src/core-server/utils/summarizeIndex.test.ts b/code/core/src/core-server/utils/summarizeIndex.test.ts index e1be61027c2..5307f05252d 100644 --- a/code/core/src/core-server/utils/summarizeIndex.test.ts +++ b/code/core/src/core-server/utils/summarizeIndex.test.ts @@ -1,4 +1,5 @@ -import { describe, it, expect } from 'vitest'; +import { describe, expect, it } from 'vitest'; + import { isPageStory, summarizeIndex } from './summarizeIndex'; describe('isPageStory', () => { diff --git a/code/core/src/core-server/utils/summarizeIndex.ts b/code/core/src/core-server/utils/summarizeIndex.ts index 56b4b27ad92..fa6ac93bcf5 100644 --- a/code/core/src/core-server/utils/summarizeIndex.ts +++ b/code/core/src/core-server/utils/summarizeIndex.ts @@ -1,6 +1,6 @@ import type { IndexEntry, StoryIndex } from '@storybook/core/types'; -import { isMdxEntry, AUTODOCS_TAG, PLAY_FN_TAG } from './StoryIndexGenerator'; +import { AUTODOCS_TAG, PLAY_FN_TAG, isMdxEntry } from './StoryIndexGenerator'; const PAGE_REGEX = /(page|screen)/i; diff --git a/code/core/src/core-server/utils/summarizeStats.test.ts b/code/core/src/core-server/utils/summarizeStats.test.ts index e1e342e9426..735671fb3c5 100644 --- a/code/core/src/core-server/utils/summarizeStats.test.ts +++ b/code/core/src/core-server/utils/summarizeStats.test.ts @@ -1,4 +1,5 @@ -import { it, expect } from 'vitest'; +import { expect, it } from 'vitest'; + import { summarizeStats } from './summarizeStats'; it('should summarize stats', () => { diff --git a/code/core/src/core-server/utils/update-check.ts b/code/core/src/core-server/utils/update-check.ts index 93bf3ac9668..4d1fe03c685 100644 --- a/code/core/src/core-server/utils/update-check.ts +++ b/code/core/src/core-server/utils/update-check.ts @@ -1,9 +1,11 @@ -import chalk from 'chalk'; +import { cache } from '@storybook/core/common'; +import type { VersionCheck } from '@storybook/core/types'; + import { colors } from '@storybook/core/node-logger'; + +import chalk from 'chalk'; import semver from 'semver'; import { dedent } from 'ts-dedent'; -import { cache } from '@storybook/core/common'; -import type { VersionCheck } from '@storybook/core/types'; const { STORYBOOK_VERSION_BASE = 'https://storybook.js.org', CI } = process.env; diff --git a/code/core/src/core-server/utils/warnOnIncompatibleAddons.ts b/code/core/src/core-server/utils/warnOnIncompatibleAddons.ts index a921f4ba364..aaf64313fd6 100644 --- a/code/core/src/core-server/utils/warnOnIncompatibleAddons.ts +++ b/code/core/src/core-server/utils/warnOnIncompatibleAddons.ts @@ -1,7 +1,8 @@ import { logger } from '@storybook/core/node-logger'; + import { - getIncompatibleStorybookPackages, getIncompatiblePackagesSummary, + getIncompatibleStorybookPackages, } from '../../../../lib/cli-storybook/src/doctor/getIncompatibleStorybookPackages'; export const warnOnIncompatibleAddons = async (currentStorybookVersion: string) => { diff --git a/code/core/src/core-server/utils/warnWhenUsingArgTypesRegex.ts b/code/core/src/core-server/utils/warnWhenUsingArgTypesRegex.ts index c4ab825e51a..b36755fcd6a 100644 --- a/code/core/src/core-server/utils/warnWhenUsingArgTypesRegex.ts +++ b/code/core/src/core-server/utils/warnWhenUsingArgTypesRegex.ts @@ -1,11 +1,13 @@ -import type { PackageJson, StorybookConfig } from '@storybook/core/types'; import { getConfigInfo } from '@storybook/core/common'; -import { readFile } from 'fs-extra'; +import type { PackageJson, StorybookConfig } from '@storybook/core/types'; + +import { babelParse } from '@storybook/core/csf-tools'; + import * as babel from '@babel/core'; import type { BabelFile } from '@babel/core'; -import { babelParse } from '@storybook/core/csf-tools'; -import { dedent } from 'ts-dedent'; import chalk from 'chalk'; +import { readFile } from 'fs-extra'; +import { dedent } from 'ts-dedent'; export async function warnWhenUsingArgTypesRegex( packageJson: PackageJson, diff --git a/code/core/src/core-server/utils/watch-story-specifiers.test.ts b/code/core/src/core-server/utils/watch-story-specifiers.test.ts index 7d93002ab37..0a9f3f367ff 100644 --- a/code/core/src/core-server/utils/watch-story-specifiers.test.ts +++ b/code/core/src/core-server/utils/watch-story-specifiers.test.ts @@ -1,6 +1,9 @@ -import { describe, afterEach, it, expect, vi } from 'vitest'; -import { normalizeStoriesEntry } from '@storybook/core/common'; import path from 'node:path'; + +import { afterEach, describe, expect, it, vi } from 'vitest'; + +import { normalizeStoriesEntry } from '@storybook/core/common'; + import Watchpack from 'watchpack'; import { watchStorySpecifiers } from './watch-story-specifiers'; diff --git a/code/core/src/core-server/utils/watch-story-specifiers.ts b/code/core/src/core-server/utils/watch-story-specifiers.ts index 068d626d8ad..e7fba3290a7 100644 --- a/code/core/src/core-server/utils/watch-story-specifiers.ts +++ b/code/core/src/core-server/utils/watch-story-specifiers.ts @@ -1,10 +1,11 @@ -import Watchpack from 'watchpack'; -import slash from 'slash'; import fs from 'node:fs'; import path from 'node:path'; -import type { NormalizedStoriesSpecifier, Path } from '@storybook/core/types'; import { commonGlobOptions } from '@storybook/core/common'; +import type { NormalizedStoriesSpecifier, Path } from '@storybook/core/types'; + +import slash from 'slash'; +import Watchpack from 'watchpack'; const isDirectory = (directory: Path) => { try { diff --git a/code/core/src/core-server/utils/watchConfig.ts b/code/core/src/core-server/utils/watchConfig.ts index 614504a1b95..bf8e055c8ce 100644 --- a/code/core/src/core-server/utils/watchConfig.ts +++ b/code/core/src/core-server/utils/watchConfig.ts @@ -1,6 +1,7 @@ -import Watchpack from 'watchpack'; import type { Path } from '@storybook/core/types'; +import Watchpack from 'watchpack'; + // copied from './watch-story-specifiers.ts' /** Watch the .storybook dir for changes */ export function watchConfig( diff --git a/code/core/src/core-server/utils/whats-new.ts b/code/core/src/core-server/utils/whats-new.ts index 024889025d0..324680c8e0c 100644 --- a/code/core/src/core-server/utils/whats-new.ts +++ b/code/core/src/core-server/utils/whats-new.ts @@ -1,19 +1,22 @@ -import fs from 'fs-extra'; -import { logger } from '@storybook/core/node-logger'; -import { telemetry } from '@storybook/core/telemetry'; +import type { Channel } from '@storybook/core/channels'; import { findConfigFile } from '@storybook/core/common'; +import { telemetry } from '@storybook/core/telemetry'; import type { CoreConfig, Options } from '@storybook/core/types'; -import { printConfig, readConfig } from '@storybook/core/csf-tools'; -import type { Channel } from '@storybook/core/channels'; + import type { WhatsNewCache, WhatsNewData } from '@storybook/core/core-events'; import { REQUEST_WHATS_NEW_DATA, RESULT_WHATS_NEW_DATA, - TELEMETRY_ERROR, SET_WHATS_NEW_CACHE, + TELEMETRY_ERROR, TOGGLE_WHATS_NEW_NOTIFICATIONS, } from '@storybook/core/core-events'; +import { printConfig, readConfig } from '@storybook/core/csf-tools'; +import { logger } from '@storybook/core/node-logger'; + +import fs from 'fs-extra'; import invariant from 'tiny-invariant'; + import { sendTelemetryError } from '../withTelemetry'; export type OptionsWithRequiredCache = Exclude & Required>; diff --git a/code/core/src/core-server/withTelemetry.test.ts b/code/core/src/core-server/withTelemetry.test.ts index 6c085b6dc9e..6c0628ec4e1 100644 --- a/code/core/src/core-server/withTelemetry.test.ts +++ b/code/core/src/core-server/withTelemetry.test.ts @@ -1,7 +1,9 @@ +import { beforeEach, describe, expect, it, vi } from 'vitest'; + +import { cache, loadAllPresets } from '@storybook/core/common'; +import { oneWayHash, telemetry } from '@storybook/core/telemetry'; + import prompts from 'prompts'; -import { describe, beforeEach, it, expect, vi } from 'vitest'; -import { loadAllPresets, cache } from '@storybook/core/common'; -import { telemetry, oneWayHash } from '@storybook/core/telemetry'; import { getErrorLevel, sendTelemetryError, withTelemetry } from './withTelemetry'; diff --git a/code/core/src/core-server/withTelemetry.ts b/code/core/src/core-server/withTelemetry.ts index 7be18cbe15f..af38bed50a2 100644 --- a/code/core/src/core-server/withTelemetry.ts +++ b/code/core/src/core-server/withTelemetry.ts @@ -1,10 +1,12 @@ -import prompts from 'prompts'; -import type { CLIOptions } from '@storybook/core/types'; -import { loadAllPresets, cache } from '@storybook/core/common'; -import { telemetry, getPrecedingUpgrade, oneWayHash } from '@storybook/core/telemetry'; +import { cache, loadAllPresets } from '@storybook/core/common'; +import { getPrecedingUpgrade, oneWayHash, telemetry } from '@storybook/core/telemetry'; import type { EventType } from '@storybook/core/telemetry'; +import type { CLIOptions } from '@storybook/core/types'; + import { logger } from '@storybook/core/node-logger'; +import prompts from 'prompts'; + type TelemetryOptions = { cliOptions: CLIOptions; presetOptions?: Parameters[0]; diff --git a/code/core/src/csf-tools/ConfigFile.test.ts b/code/core/src/csf-tools/ConfigFile.test.ts index b43e98c93d5..9846837cac4 100644 --- a/code/core/src/csf-tools/ConfigFile.test.ts +++ b/code/core/src/csf-tools/ConfigFile.test.ts @@ -1,5 +1,7 @@ +import { describe, expect, it } from 'vitest'; + import { dedent } from 'ts-dedent'; -import { describe, it, expect } from 'vitest'; + import { loadConfig, printConfig } from './ConfigFile'; import { babelPrint } from './babelParse'; diff --git a/code/core/src/csf-tools/ConfigFile.ts b/code/core/src/csf-tools/ConfigFile.ts index b13e42175a4..a56e3ecf098 100644 --- a/code/core/src/csf-tools/ConfigFile.ts +++ b/code/core/src/csf-tools/ConfigFile.ts @@ -1,16 +1,15 @@ /* eslint-disable no-underscore-dangle */ import { readFile, writeFile } from 'node:fs/promises'; -import { dedent } from 'ts-dedent'; -import * as t from '@babel/types'; import bg from '@babel/generator'; import bt from '@babel/traverse'; - +import * as t from '@babel/types'; import type { Options } from 'recast'; import * as recast from 'recast'; +import { dedent } from 'ts-dedent'; -import { babelParse } from './babelParse'; import type { PrintResultType } from './PrintResultType'; +import { babelParse } from './babelParse'; // @ts-expect-error (needed due to it's use of `exports.default`) const traverse = (bt.default || bt) as typeof bt; diff --git a/code/core/src/csf-tools/CsfFile.test.ts b/code/core/src/csf-tools/CsfFile.test.ts index 34be1e2dbbf..f90f25d209f 100644 --- a/code/core/src/csf-tools/CsfFile.test.ts +++ b/code/core/src/csf-tools/CsfFile.test.ts @@ -1,8 +1,10 @@ /* eslint-disable no-underscore-dangle */ -import { dedent } from 'ts-dedent'; -import { describe, it, expect, vi } from 'vitest'; +import { describe, expect, it, vi } from 'vitest'; + import yaml from 'js-yaml'; -import { loadCsf, isModuleMock } from './CsfFile'; +import { dedent } from 'ts-dedent'; + +import { isModuleMock, loadCsf } from './CsfFile'; expect.addSnapshotSerializer({ print: (val: any) => yaml.dump(val).trimEnd(), diff --git a/code/core/src/csf-tools/CsfFile.ts b/code/core/src/csf-tools/CsfFile.ts index 70d9b5b1006..de422f32133 100644 --- a/code/core/src/csf-tools/CsfFile.ts +++ b/code/core/src/csf-tools/CsfFile.ts @@ -1,26 +1,26 @@ /* eslint-disable no-underscore-dangle */ import { readFile, writeFile } from 'node:fs/promises'; -import { dedent } from 'ts-dedent'; - -import * as t from '@babel/types'; -import bg, { type GeneratorOptions } from '@babel/generator'; -import bt from '@babel/traverse'; -import * as recast from 'recast'; - -import { toId, isExportStory, storyNameFromExport } from '@storybook/csf'; import type { - Tag, - StoryAnnotations, ComponentAnnotations, - IndexedCSFFile, IndexInput, IndexInputStats, + IndexedCSFFile, + StoryAnnotations, + Tag, } from '@storybook/core/types'; +import { isExportStory, storyNameFromExport, toId } from '@storybook/csf'; + +import bg, { type GeneratorOptions } from '@babel/generator'; +import bt from '@babel/traverse'; +import * as t from '@babel/types'; +import * as recast from 'recast'; import type { Options } from 'recast'; +import { dedent } from 'ts-dedent'; + +import type { PrintResultType } from './PrintResultType'; import { babelParse } from './babelParse'; import { findVarInitialization } from './findVarInitialization'; -import type { PrintResultType } from './PrintResultType'; // @ts-expect-error (needed due to it's use of `exports.default`) const traverse = (bt.default || bt) as typeof bt; diff --git a/code/core/src/csf-tools/babelParse.ts b/code/core/src/csf-tools/babelParse.ts index 9e3aaf8b53d..c802734ef67 100644 --- a/code/core/src/csf-tools/babelParse.ts +++ b/code/core/src/csf-tools/babelParse.ts @@ -1,7 +1,7 @@ -import type * as t from '@babel/types'; import * as babelParser from '@babel/parser'; -import * as recast from 'recast'; import type { ParserOptions } from '@babel/parser'; +import type * as t from '@babel/types'; +import * as recast from 'recast'; function parseWithFlowOrTypescript(source: string, parserOptions: babelParser.ParserOptions) { const flowCommentPattern = /^\s*\/\/\s*@flow/; diff --git a/code/core/src/csf-tools/enrichCsf.test.ts b/code/core/src/csf-tools/enrichCsf.test.ts index 562cacd8c04..e8c0ce6250e 100644 --- a/code/core/src/csf-tools/enrichCsf.test.ts +++ b/code/core/src/csf-tools/enrichCsf.test.ts @@ -1,6 +1,8 @@ /* eslint-disable no-underscore-dangle */ +import { describe, expect, it } from 'vitest'; + import { dedent } from 'ts-dedent'; -import { describe, it, expect } from 'vitest'; + import { formatCsf, loadCsf } from './CsfFile'; import type { EnrichCsfOptions } from './enrichCsf'; import { enrichCsf, extractSource } from './enrichCsf'; diff --git a/code/core/src/csf-tools/enrichCsf.ts b/code/core/src/csf-tools/enrichCsf.ts index dc267458854..b14e146b1d3 100644 --- a/code/core/src/csf-tools/enrichCsf.ts +++ b/code/core/src/csf-tools/enrichCsf.ts @@ -1,7 +1,7 @@ /* eslint-disable no-underscore-dangle */ +import bg from '@babel/generator'; import * as t from '@babel/types'; -import bg from '@babel/generator'; import type { CsfFile } from './CsfFile'; // @ts-expect-error (needed due to it's use of `exports.default`) diff --git a/code/core/src/csf-tools/getStorySortParameter.test.ts b/code/core/src/csf-tools/getStorySortParameter.test.ts index b2672bb0198..565e0e10fdf 100644 --- a/code/core/src/csf-tools/getStorySortParameter.test.ts +++ b/code/core/src/csf-tools/getStorySortParameter.test.ts @@ -1,5 +1,7 @@ -import { describe, it, expect } from 'vitest'; +import { describe, expect, it } from 'vitest'; + import { dedent } from 'ts-dedent'; + import { getStorySortParameter } from './getStorySortParameter'; describe('getStorySortParameter', () => { diff --git a/code/core/src/csf-tools/getStorySortParameter.ts b/code/core/src/csf-tools/getStorySortParameter.ts index 07202029aba..7766b114935 100644 --- a/code/core/src/csf-tools/getStorySortParameter.ts +++ b/code/core/src/csf-tools/getStorySortParameter.ts @@ -1,8 +1,8 @@ -import * as t from '@babel/types'; -import bt from '@babel/traverse'; import bg from '@babel/generator'; - +import bt from '@babel/traverse'; +import * as t from '@babel/types'; import { dedent } from 'ts-dedent'; + import { babelParse } from './babelParse'; import { findVarInitialization } from './findVarInitialization'; diff --git a/code/core/src/docs-tools/argTypes/convert/__testfixtures__/proptypes/arrays.js b/code/core/src/docs-tools/argTypes/convert/__testfixtures__/proptypes/arrays.js index 0f1ebcdae09..b3cb9649b70 100644 --- a/code/core/src/docs-tools/argTypes/convert/__testfixtures__/proptypes/arrays.js +++ b/code/core/src/docs-tools/argTypes/convert/__testfixtures__/proptypes/arrays.js @@ -1,4 +1,5 @@ import React from 'react'; + import PropTypes from 'prop-types'; export const Component = (props) => <>JSON.stringify(props); diff --git a/code/core/src/docs-tools/argTypes/convert/__testfixtures__/proptypes/enums.js b/code/core/src/docs-tools/argTypes/convert/__testfixtures__/proptypes/enums.js index d8baae69312..2bfa6a5e741 100644 --- a/code/core/src/docs-tools/argTypes/convert/__testfixtures__/proptypes/enums.js +++ b/code/core/src/docs-tools/argTypes/convert/__testfixtures__/proptypes/enums.js @@ -1,4 +1,5 @@ import React from 'react'; + import PropTypes from 'prop-types'; export const Component = (props) => <>JSON.stringify(props); diff --git a/code/core/src/docs-tools/argTypes/convert/__testfixtures__/proptypes/misc.js b/code/core/src/docs-tools/argTypes/convert/__testfixtures__/proptypes/misc.js index e662474d1ab..a5e0d60dcf7 100644 --- a/code/core/src/docs-tools/argTypes/convert/__testfixtures__/proptypes/misc.js +++ b/code/core/src/docs-tools/argTypes/convert/__testfixtures__/proptypes/misc.js @@ -1,4 +1,5 @@ import React from 'react'; + import PropTypes from 'prop-types'; export const Component = (props) => <>JSON.stringify(props); diff --git a/code/core/src/docs-tools/argTypes/convert/__testfixtures__/proptypes/objects.js b/code/core/src/docs-tools/argTypes/convert/__testfixtures__/proptypes/objects.js index 09036cf8808..12d81862672 100644 --- a/code/core/src/docs-tools/argTypes/convert/__testfixtures__/proptypes/objects.js +++ b/code/core/src/docs-tools/argTypes/convert/__testfixtures__/proptypes/objects.js @@ -1,4 +1,5 @@ import React from 'react'; + import PropTypes from 'prop-types'; export const Component = (props) => <>JSON.stringify(props); diff --git a/code/core/src/docs-tools/argTypes/convert/__testfixtures__/proptypes/react.js b/code/core/src/docs-tools/argTypes/convert/__testfixtures__/proptypes/react.js index fd54e930766..0b772151166 100644 --- a/code/core/src/docs-tools/argTypes/convert/__testfixtures__/proptypes/react.js +++ b/code/core/src/docs-tools/argTypes/convert/__testfixtures__/proptypes/react.js @@ -1,4 +1,5 @@ import React from 'react'; + import PropTypes from 'prop-types'; export const Component = (props) => <>JSON.stringify(props); diff --git a/code/core/src/docs-tools/argTypes/convert/__testfixtures__/proptypes/scalars.js b/code/core/src/docs-tools/argTypes/convert/__testfixtures__/proptypes/scalars.js index 7e74151596b..c28a4e4bb99 100644 --- a/code/core/src/docs-tools/argTypes/convert/__testfixtures__/proptypes/scalars.js +++ b/code/core/src/docs-tools/argTypes/convert/__testfixtures__/proptypes/scalars.js @@ -1,4 +1,5 @@ import React from 'react'; + import PropTypes from 'prop-types'; export const Component = (props) => <>JSON.stringify(props); diff --git a/code/core/src/docs-tools/argTypes/convert/convert.test.ts b/code/core/src/docs-tools/argTypes/convert/convert.test.ts index 3d33efd5ea7..a541f876e54 100644 --- a/code/core/src/docs-tools/argTypes/convert/convert.test.ts +++ b/code/core/src/docs-tools/argTypes/convert/convert.test.ts @@ -1,11 +1,13 @@ -import { describe, it, expect } from 'vitest'; -import mapValues from 'lodash/mapValues.js'; +import fs from 'node:fs'; + +import { describe, expect, it } from 'vitest'; + import { transformSync } from '@babel/core'; +import mapValues from 'lodash/mapValues.js'; import requireFromString from 'require-from-string'; -import fs from 'node:fs'; -import { convert } from './index'; import { normalizeNewlines } from '../utils'; +import { convert } from './index'; expect.addSnapshotSerializer({ print: (val: any) => JSON.stringify(val, null, 2), diff --git a/code/core/src/docs-tools/argTypes/convert/flow/convert.ts b/code/core/src/docs-tools/argTypes/convert/flow/convert.ts index 0166ccfb86d..fe5ecc6a8b7 100644 --- a/code/core/src/docs-tools/argTypes/convert/flow/convert.ts +++ b/code/core/src/docs-tools/argTypes/convert/flow/convert.ts @@ -1,6 +1,8 @@ -import { UnknownArgTypesError } from '@storybook/core/preview-errors'; import type { SBType } from '@storybook/core/types'; -import type { FlowType, FlowSigType, FlowLiteralType } from './types'; + +import { UnknownArgTypesError } from '@storybook/core/preview-errors'; + +import type { FlowLiteralType, FlowSigType, FlowType } from './types'; const isLiteral = (type: FlowType): type is FlowLiteralType => type.name === 'literal'; const toEnumOption = (element: FlowLiteralType) => element.value.replace(/['|"]/g, ''); diff --git a/code/core/src/docs-tools/argTypes/convert/index.ts b/code/core/src/docs-tools/argTypes/convert/index.ts index 812fcf51789..1076e9950e9 100644 --- a/code/core/src/docs-tools/argTypes/convert/index.ts +++ b/code/core/src/docs-tools/argTypes/convert/index.ts @@ -1,9 +1,9 @@ import type { DocgenInfo } from '../docgen/types'; -import type { TSType } from './typescript'; -import { convert as tsConvert } from './typescript'; import type { FlowType } from './flow'; import { convert as flowConvert } from './flow'; import { convert as propTypesConvert } from './proptypes'; +import type { TSType } from './typescript'; +import { convert as tsConvert } from './typescript'; export const convert = (docgenInfo: DocgenInfo) => { const { type, tsType, flowType } = docgenInfo; diff --git a/code/core/src/docs-tools/argTypes/convert/proptypes/convert.ts b/code/core/src/docs-tools/argTypes/convert/proptypes/convert.ts index 895b275e244..4934af202b4 100644 --- a/code/core/src/docs-tools/argTypes/convert/proptypes/convert.ts +++ b/code/core/src/docs-tools/argTypes/convert/proptypes/convert.ts @@ -1,7 +1,9 @@ -import mapValues from 'lodash/mapValues.js'; import type { SBType } from '@storybook/core/types'; -import type { PTType } from './types'; + +import mapValues from 'lodash/mapValues.js'; + import { parseLiteral } from '../utils'; +import type { PTType } from './types'; const SIGNATURE_REGEXP = /^\(.*\) => /; diff --git a/code/core/src/docs-tools/argTypes/convert/typescript/convert.ts b/code/core/src/docs-tools/argTypes/convert/typescript/convert.ts index 248dfba4f2b..bfb8312d204 100644 --- a/code/core/src/docs-tools/argTypes/convert/typescript/convert.ts +++ b/code/core/src/docs-tools/argTypes/convert/typescript/convert.ts @@ -1,7 +1,9 @@ -import { UnknownArgTypesError } from '@storybook/core/preview-errors'; import type { SBType } from '@storybook/core/types'; -import type { TSType, TSSigType } from './types'; + +import { UnknownArgTypesError } from '@storybook/core/preview-errors'; + import { parseLiteral } from '../utils'; +import type { TSSigType, TSType } from './types'; const convertSig = (type: TSSigType) => { switch (type.type) { diff --git a/code/core/src/docs-tools/argTypes/docgen/createPropDef.ts b/code/core/src/docs-tools/argTypes/docgen/createPropDef.ts index 4fd5b7f48b0..ea903a9378d 100644 --- a/code/core/src/docs-tools/argTypes/docgen/createPropDef.ts +++ b/code/core/src/docs-tools/argTypes/docgen/createPropDef.ts @@ -1,15 +1,12 @@ -import type { JsDocParam, PropDefaultValue } from './PropDef'; -import type { PropDef, DocgenInfo, DocgenType, DocgenPropDefaultValue } from './types'; -import { TypeSystem } from './types'; +import { convert } from '../convert'; import type { JsDocParsingResult } from '../jsdocParser'; - import { createSummaryValue } from '../utils'; - +import type { JsDocParam, PropDefaultValue } from './PropDef'; import { createFlowPropDef } from './flow/createPropDef'; -import { isDefaultValueBlacklisted } from './utils/defaultValue'; - import { createTsPropDef } from './typeScript/createPropDef'; -import { convert } from '../convert'; +import type { DocgenInfo, DocgenPropDefaultValue, DocgenType, PropDef } from './types'; +import { TypeSystem } from './types'; +import { isDefaultValueBlacklisted } from './utils/defaultValue'; export type PropDefFactory = ( propName: string, diff --git a/code/core/src/docs-tools/argTypes/docgen/extractDocgenProps.test.ts b/code/core/src/docs-tools/argTypes/docgen/extractDocgenProps.test.ts index 3a8cdc650bf..83e8f09b867 100644 --- a/code/core/src/docs-tools/argTypes/docgen/extractDocgenProps.test.ts +++ b/code/core/src/docs-tools/argTypes/docgen/extractDocgenProps.test.ts @@ -1,5 +1,5 @@ /* eslint-disable no-underscore-dangle */ -import { describe, it, expect } from 'vitest'; +import { describe, expect, it } from 'vitest'; import type { Component } from '../types'; import { extractComponentProps } from './extractDocgenProps'; diff --git a/code/core/src/docs-tools/argTypes/docgen/extractDocgenProps.ts b/code/core/src/docs-tools/argTypes/docgen/extractDocgenProps.ts index 3ed22e31d22..1a4d595ad84 100644 --- a/code/core/src/docs-tools/argTypes/docgen/extractDocgenProps.ts +++ b/code/core/src/docs-tools/argTypes/docgen/extractDocgenProps.ts @@ -1,12 +1,11 @@ -import type { Component } from '../types'; import type { ExtractedJsDoc } from '../jsdocParser'; import { parseJsDoc } from '../jsdocParser'; -import type { PropDef, DocgenInfo } from './types'; -import { TypeSystem } from './types'; -import { getDocgenSection, isValidDocgenSection, getDocgenDescription } from './utils'; - +import type { Component } from '../types'; import type { PropDefFactory } from './createPropDef'; import { getPropDefFactory } from './createPropDef'; +import type { DocgenInfo, PropDef } from './types'; +import { TypeSystem } from './types'; +import { getDocgenDescription, getDocgenSection, isValidDocgenSection } from './utils'; export interface ExtractedProp { propDef: PropDef; diff --git a/code/core/src/docs-tools/argTypes/docgen/flow/createDefaultValue.ts b/code/core/src/docs-tools/argTypes/docgen/flow/createDefaultValue.ts index 3bb55aec2c6..00645488910 100644 --- a/code/core/src/docs-tools/argTypes/docgen/flow/createDefaultValue.ts +++ b/code/core/src/docs-tools/argTypes/docgen/flow/createDefaultValue.ts @@ -1,7 +1,6 @@ +import { createSummaryValue, isTooLongForDefaultValueSummary } from '../../utils'; import type { PropDefaultValue } from '../PropDef'; import type { DocgenPropDefaultValue, DocgenPropType } from '../types'; - -import { createSummaryValue, isTooLongForDefaultValueSummary } from '../../utils'; import { isDefaultValueBlacklisted } from '../utils/defaultValue'; export function createDefaultValue( diff --git a/code/core/src/docs-tools/argTypes/docgen/flow/createPropDef.test.ts b/code/core/src/docs-tools/argTypes/docgen/flow/createPropDef.test.ts index 50cc5d8e95e..95959caec2f 100644 --- a/code/core/src/docs-tools/argTypes/docgen/flow/createPropDef.test.ts +++ b/code/core/src/docs-tools/argTypes/docgen/flow/createPropDef.test.ts @@ -1,6 +1,7 @@ -import { describe, it, expect } from 'vitest'; -import { createFlowPropDef } from './createPropDef'; +import { describe, expect, it } from 'vitest'; + import type { DocgenInfo } from '../types'; +import { createFlowPropDef } from './createPropDef'; const PROP_NAME = 'propName'; diff --git a/code/core/src/docs-tools/argTypes/docgen/flow/createPropDef.ts b/code/core/src/docs-tools/argTypes/docgen/flow/createPropDef.ts index edbad170e70..53c07e36551 100644 --- a/code/core/src/docs-tools/argTypes/docgen/flow/createPropDef.ts +++ b/code/core/src/docs-tools/argTypes/docgen/flow/createPropDef.ts @@ -1,8 +1,6 @@ import type { PropDefFactory } from '../createPropDef'; - -import { createType } from './createType'; - import { createDefaultValue } from './createDefaultValue'; +import { createType } from './createType'; export const createFlowPropDef: PropDefFactory = (propName, docgenInfo) => { const { flowType, description, required, defaultValue } = docgenInfo; diff --git a/code/core/src/docs-tools/argTypes/docgen/flow/createType.ts b/code/core/src/docs-tools/argTypes/docgen/flow/createType.ts index d4c4bb358f2..03a4dc7885f 100644 --- a/code/core/src/docs-tools/argTypes/docgen/flow/createType.ts +++ b/code/core/src/docs-tools/argTypes/docgen/flow/createType.ts @@ -1,8 +1,7 @@ +import { createSummaryValue, isTooLongForTypeSummary } from '../../utils'; import type { PropType } from '../PropDef'; import type { DocgenFlowType } from '../types'; -import { createSummaryValue, isTooLongForTypeSummary } from '../../utils'; - enum FlowTypesType { UNION = 'union', SIGNATURE = 'signature', diff --git a/code/core/src/docs-tools/argTypes/docgen/typeScript/createDefaultValue.ts b/code/core/src/docs-tools/argTypes/docgen/typeScript/createDefaultValue.ts index 79dc5bcc1c5..de1d5335063 100644 --- a/code/core/src/docs-tools/argTypes/docgen/typeScript/createDefaultValue.ts +++ b/code/core/src/docs-tools/argTypes/docgen/typeScript/createDefaultValue.ts @@ -1,7 +1,6 @@ +import { createSummaryValue } from '../../utils'; import type { PropDefaultValue } from '../PropDef'; import type { DocgenInfo } from '../types'; - -import { createSummaryValue } from '../../utils'; import { isDefaultValueBlacklisted } from '../utils/defaultValue'; export function createDefaultValue({ defaultValue }: DocgenInfo): PropDefaultValue | null { diff --git a/code/core/src/docs-tools/argTypes/docgen/typeScript/createPropDef.test.ts b/code/core/src/docs-tools/argTypes/docgen/typeScript/createPropDef.test.ts index 12fe6c24b51..e816d87ecc1 100644 --- a/code/core/src/docs-tools/argTypes/docgen/typeScript/createPropDef.test.ts +++ b/code/core/src/docs-tools/argTypes/docgen/typeScript/createPropDef.test.ts @@ -1,6 +1,7 @@ -import { describe, it, expect } from 'vitest'; -import { createTsPropDef } from './createPropDef'; +import { describe, expect, it } from 'vitest'; + import type { DocgenInfo } from '../types'; +import { createTsPropDef } from './createPropDef'; const PROP_NAME = 'propName'; diff --git a/code/core/src/docs-tools/argTypes/docgen/typeScript/createPropDef.ts b/code/core/src/docs-tools/argTypes/docgen/typeScript/createPropDef.ts index c6a7f904e3b..fd81a7a6ed6 100644 --- a/code/core/src/docs-tools/argTypes/docgen/typeScript/createPropDef.ts +++ b/code/core/src/docs-tools/argTypes/docgen/typeScript/createPropDef.ts @@ -1,8 +1,6 @@ import type { PropDefFactory } from '../createPropDef'; - -import { createType } from './createType'; - import { createDefaultValue } from './createDefaultValue'; +import { createType } from './createType'; export const createTsPropDef: PropDefFactory = (propName, docgenInfo) => { const { description, required } = docgenInfo; diff --git a/code/core/src/docs-tools/argTypes/docgen/typeScript/createType.ts b/code/core/src/docs-tools/argTypes/docgen/typeScript/createType.ts index af37d97e1dc..c7408df13b3 100644 --- a/code/core/src/docs-tools/argTypes/docgen/typeScript/createType.ts +++ b/code/core/src/docs-tools/argTypes/docgen/typeScript/createType.ts @@ -1,8 +1,7 @@ +import { createSummaryValue } from '../../utils'; import type { PropType } from '../PropDef'; import type { DocgenInfo } from '../types'; -import { createSummaryValue } from '../../utils'; - export function createType({ tsType, required }: DocgenInfo): PropType | null { // A type could be null if a defaultProp has been provided without a type definition. if (tsType == null) { diff --git a/code/core/src/docs-tools/argTypes/docgen/types.ts b/code/core/src/docs-tools/argTypes/docgen/types.ts index dc059af40ed..9639be964e0 100644 --- a/code/core/src/docs-tools/argTypes/docgen/types.ts +++ b/code/core/src/docs-tools/argTypes/docgen/types.ts @@ -1,6 +1,7 @@ import type { StrictArgTypes } from '@storybook/core/types'; -import type { PropDef } from './PropDef'; + import type { Component } from '../types'; +import type { PropDef } from './PropDef'; export type PropsExtractor = (component: Component) => { rows?: PropDef[] } | null; diff --git a/code/core/src/docs-tools/argTypes/docgen/utils/docgenInfo.ts b/code/core/src/docs-tools/argTypes/docgen/utils/docgenInfo.ts index 6d1a7005ca0..03cd442cf80 100644 --- a/code/core/src/docs-tools/argTypes/docgen/utils/docgenInfo.ts +++ b/code/core/src/docs-tools/argTypes/docgen/utils/docgenInfo.ts @@ -1,5 +1,4 @@ /* eslint-disable no-underscore-dangle */ - import type { Component } from '../../types'; import { str } from './string'; diff --git a/code/core/src/docs-tools/argTypes/enhanceArgTypes.test.ts b/code/core/src/docs-tools/argTypes/enhanceArgTypes.test.ts index a3a83ab2c93..55b70ef2ea5 100644 --- a/code/core/src/docs-tools/argTypes/enhanceArgTypes.test.ts +++ b/code/core/src/docs-tools/argTypes/enhanceArgTypes.test.ts @@ -1,5 +1,7 @@ -import { describe, it, expect } from 'vitest'; +import { describe, expect, it } from 'vitest'; + import type { ArgTypes, StrictInputType } from '@storybook/core/types'; + import { enhanceArgTypes } from './enhanceArgTypes'; expect.addSnapshotSerializer({ diff --git a/code/core/src/docs-tools/argTypes/enhanceArgTypes.ts b/code/core/src/docs-tools/argTypes/enhanceArgTypes.ts index 09736e160ce..96cc2ce44d6 100644 --- a/code/core/src/docs-tools/argTypes/enhanceArgTypes.ts +++ b/code/core/src/docs-tools/argTypes/enhanceArgTypes.ts @@ -1,4 +1,5 @@ import type { Renderer, StoryContextForEnhancers } from '@storybook/core/types'; + import { combineParameters } from '@storybook/core/preview-api'; export const enhanceArgTypes = ( diff --git a/code/core/src/docs-tools/argTypes/jsdocParser.test.ts b/code/core/src/docs-tools/argTypes/jsdocParser.test.ts index e0f83617605..89973651347 100644 --- a/code/core/src/docs-tools/argTypes/jsdocParser.test.ts +++ b/code/core/src/docs-tools/argTypes/jsdocParser.test.ts @@ -1,4 +1,5 @@ -import { describe, it, expect } from 'vitest'; +import { describe, expect, it } from 'vitest'; + import { parseJsDoc } from './jsdocParser'; describe('parseJsDoc', () => { diff --git a/code/core/src/docs-tools/argTypes/jsdocParser.ts b/code/core/src/docs-tools/argTypes/jsdocParser.ts index 0990865a14c..887bab58c71 100644 --- a/code/core/src/docs-tools/argTypes/jsdocParser.ts +++ b/code/core/src/docs-tools/argTypes/jsdocParser.ts @@ -1,11 +1,12 @@ import type { Block, Spec } from 'comment-parser'; -import type { RootResult as JSDocType } from 'jsdoc-type-pratt-parser'; import { parse as parseJSDoc } from 'comment-parser'; +import type { RootResult as JSDocType } from 'jsdoc-type-pratt-parser'; import { parse as parseJSDocType, - transform as transformJSDocType, stringifyRules, + transform as transformJSDocType, } from 'jsdoc-type-pratt-parser'; + import type { JsDocParam, JsDocReturns } from './docgen'; export interface ExtractedJsDocParam extends JsDocParam { diff --git a/code/core/src/docs-tools/argTypes/utils.test.ts b/code/core/src/docs-tools/argTypes/utils.test.ts index fc0a204a531..4ebfba01584 100644 --- a/code/core/src/docs-tools/argTypes/utils.test.ts +++ b/code/core/src/docs-tools/argTypes/utils.test.ts @@ -1,4 +1,5 @@ -import { describe, it, expect } from 'vitest'; +import { describe, expect, it } from 'vitest'; + import { createSummaryValue } from './utils'; describe('createSummaryValue', () => { diff --git a/code/core/src/manager-api/context.ts b/code/core/src/manager-api/context.ts index c0e2053c4ff..2344d8361ac 100644 --- a/code/core/src/manager-api/context.ts +++ b/code/core/src/manager-api/context.ts @@ -1,4 +1,5 @@ import { createContext as ReactCreateContext } from 'react'; + import type { Combo } from './root'; export const createContext = ({ api, state }: Combo) => ReactCreateContext({ api, state }); diff --git a/code/core/src/manager-api/initial-state.ts b/code/core/src/manager-api/initial-state.ts index fa862a9b589..583944b81be 100644 --- a/code/core/src/manager-api/initial-state.ts +++ b/code/core/src/manager-api/initial-state.ts @@ -1,5 +1,4 @@ import merge from './lib/merge'; - import type { State } from './root'; interface Addition { diff --git a/code/core/src/manager-api/lib/addons.ts b/code/core/src/manager-api/lib/addons.ts index c463a9ca474..f782e80713e 100644 --- a/code/core/src/manager-api/lib/addons.ts +++ b/code/core/src/manager-api/lib/addons.ts @@ -1,23 +1,24 @@ -import { global } from '@storybook/global'; - import type { Channel } from '@storybook/core/channels'; -import { SET_CONFIG } from '@storybook/core/core-events'; import type { + Addon_BaseType, Addon_Collection, Addon_Config, Addon_Elements, Addon_Loaders, - Addon_Type, - Addon_BaseType, Addon_PageType, + Addon_SidebarBottomType, + Addon_SidebarTopType, + Addon_Type, Addon_Types, Addon_TypesMapping, Addon_WrapperType, - Addon_SidebarBottomType, - Addon_SidebarTopType, } from '@storybook/core/types'; import { Addon_TypesEnum } from '@storybook/core/types'; +import { global } from '@storybook/global'; + import { logger } from '@storybook/core/client-logger'; +import { SET_CONFIG } from '@storybook/core/core-events'; + import type { API } from '../root'; import { mockChannel } from './storybook-channel-mock'; diff --git a/code/core/src/manager-api/lib/events.ts b/code/core/src/manager-api/lib/events.ts index b896961187c..f964626ac8e 100644 --- a/code/core/src/manager-api/lib/events.ts +++ b/code/core/src/manager-api/lib/events.ts @@ -1,7 +1,7 @@ -import { logger } from '@storybook/core/client-logger'; - import type { API_ComposedRef } from '@storybook/core/types'; +import { logger } from '@storybook/core/client-logger'; + import { getSourceType } from '../modules/refs'; import type { API } from '../root'; diff --git a/code/core/src/manager-api/lib/merge.ts b/code/core/src/manager-api/lib/merge.ts index e6b7eabf8e9..ec4c474942b 100644 --- a/code/core/src/manager-api/lib/merge.ts +++ b/code/core/src/manager-api/lib/merge.ts @@ -1,8 +1,8 @@ -import mergeWith from 'lodash/mergeWith.js'; -import isEqual from 'lodash/isEqual.js'; - import { logger } from '@storybook/core/client-logger'; +import isEqual from 'lodash/isEqual.js'; +import mergeWith from 'lodash/mergeWith.js'; + export default (a: TObj, b: Partial) => mergeWith({}, a, b, (objValue: TObj, srcValue: Partial) => { if (Array.isArray(srcValue) && Array.isArray(objValue)) { diff --git a/code/core/src/manager-api/lib/shortcut.ts b/code/core/src/manager-api/lib/shortcut.ts index 9ca5b2d7afe..0db5c65f659 100644 --- a/code/core/src/manager-api/lib/shortcut.ts +++ b/code/core/src/manager-api/lib/shortcut.ts @@ -1,4 +1,5 @@ import { global } from '@storybook/global'; + import type { API_KeyCollection } from '../modules/shortcuts'; const { navigator } = global; diff --git a/code/core/src/manager-api/lib/store-setup.ts b/code/core/src/manager-api/lib/store-setup.ts index 805b3237ab0..291898bede0 100644 --- a/code/core/src/manager-api/lib/store-setup.ts +++ b/code/core/src/manager-api/lib/store-setup.ts @@ -1,5 +1,4 @@ /* eslint-disable no-underscore-dangle */ - import { parse, stringify } from 'telejson'; // setting up the store, overriding set and get to use telejson diff --git a/code/core/src/manager-api/lib/stories.test.ts b/code/core/src/manager-api/lib/stories.test.ts index 5f005eef9e2..76aaadd7f99 100644 --- a/code/core/src/manager-api/lib/stories.test.ts +++ b/code/core/src/manager-api/lib/stories.test.ts @@ -1,11 +1,13 @@ -import { describe, it, expect } from 'vitest'; -import type { StoryIndexV2, StoryIndexV3, API_PreparedStoryIndex } from '@storybook/core/types'; +import { describe, expect, it } from 'vitest'; + +import type { API_PreparedStoryIndex, StoryIndexV2, StoryIndexV3 } from '@storybook/core/types'; + +import { mockEntries } from '../tests/mockStoriesEntries'; import { transformStoryIndexV2toV3, transformStoryIndexV3toV4, transformStoryIndexV4toV5, } from './stories'; -import { mockEntries } from '../tests/mockStoriesEntries'; const baseV2: StoryIndexV2['stories'][0] = { id: '1', diff --git a/code/core/src/manager-api/lib/stories.ts b/code/core/src/manager-api/lib/stories.ts index 52366345ca0..139b6acaf85 100644 --- a/code/core/src/manager-api/lib/stories.ts +++ b/code/core/src/manager-api/lib/stories.ts @@ -1,29 +1,30 @@ -import memoize from 'memoizerific'; -import { dedent } from 'ts-dedent'; -import countBy from 'lodash/countBy.js'; -import mapValues from 'lodash/mapValues.js'; -import { sanitize } from '@storybook/csf'; import type { - StoryId, - Parameters, - DocsOptions, - API_Provider, - SetStoriesStoryData, - API_PreparedStoryIndex, - StoryIndexV3, - IndexEntry, - API_RootEntry, - API_GroupEntry, API_ComponentEntry, - API_IndexHash, API_DocsEntry, - API_StoryEntry, + API_GroupEntry, API_HashEntry, + API_IndexHash, + API_PreparedStoryIndex, + API_Provider, + API_RootEntry, + API_StoryEntry, + DocsOptions, + IndexEntry, + Parameters, SetStoriesPayload, + SetStoriesStoryData, + StoryId, StoryIndexV2, + StoryIndexV3, } from '@storybook/core/types'; +import { sanitize } from '@storybook/csf'; + +import countBy from 'lodash/countBy.js'; +import mapValues from 'lodash/mapValues.js'; +import memoize from 'memoizerific'; +import { dedent } from 'ts-dedent'; -import { type API, combineParameters, type State } from '../root'; +import { type API, type State, combineParameters } from '../root'; import merge from './merge'; const TITLE_PATH_SEPARATOR = /\s*\/\s*/; diff --git a/code/core/src/manager-api/lib/types.tsx b/code/core/src/manager-api/lib/types.tsx index 2b7a31e2498..1579954f7e1 100644 --- a/code/core/src/manager-api/lib/types.tsx +++ b/code/core/src/manager-api/lib/types.tsx @@ -1,5 +1,5 @@ -import type { API_ProviderData } from '@storybook/core/types'; import type { RouterData } from '@storybook/core/router'; +import type { API_ProviderData } from '@storybook/core/types'; import type { API, State } from '../root'; import type Store from '../store'; diff --git a/code/core/src/manager-api/modules/addons.ts b/code/core/src/manager-api/modules/addons.ts index 2cefd4d9b39..61e65084f95 100644 --- a/code/core/src/manager-api/modules/addons.ts +++ b/code/core/src/manager-api/modules/addons.ts @@ -1,11 +1,12 @@ import type { + API_StateMerger, Addon_BaseType, Addon_Collection, Addon_Types, Addon_TypesMapping, - API_StateMerger, } from '@storybook/core/types'; import { Addon_TypesEnum } from '@storybook/core/types'; + import type { ModuleFn } from '../lib/types'; import type { Options } from '../store'; diff --git a/code/core/src/manager-api/modules/channel.ts b/code/core/src/manager-api/modules/channel.ts index 8fdc688cf81..6621aafa2ea 100644 --- a/code/core/src/manager-api/modules/channel.ts +++ b/code/core/src/manager-api/modules/channel.ts @@ -1,8 +1,8 @@ import type { Listener } from '@storybook/core/channels'; - import type { API_Provider } from '@storybook/core/types'; -import type { API } from '../root'; + import type { ModuleFn } from '../lib/types'; +import type { API } from '../root'; export interface SubAPI { /** diff --git a/code/core/src/manager-api/modules/globals.ts b/code/core/src/manager-api/modules/globals.ts index cd990975ad1..0d3c790cf41 100644 --- a/code/core/src/manager-api/modules/globals.ts +++ b/code/core/src/manager-api/modules/globals.ts @@ -1,16 +1,17 @@ -import { SET_GLOBALS, UPDATE_GLOBALS, GLOBALS_UPDATED } from '@storybook/core/core-events'; -import { logger } from '@storybook/core/client-logger'; -import { dequal as deepEqual } from 'dequal'; import type { - SetGlobalsPayload, - Globals, GlobalTypes, + Globals, GlobalsUpdatedPayload, + SetGlobalsPayload, } from '@storybook/core/types'; -import type { ModuleFn } from '../lib/types'; +import { logger } from '@storybook/core/client-logger'; +import { GLOBALS_UPDATED, SET_GLOBALS, UPDATE_GLOBALS } from '@storybook/core/core-events'; + +import { dequal as deepEqual } from 'dequal'; import { getEventMetadata } from '../lib/events'; +import type { ModuleFn } from '../lib/types'; export interface SubState { globals?: Globals; diff --git a/code/core/src/manager-api/modules/layout.ts b/code/core/src/manager-api/modules/layout.ts index 89bd0ab19af..de5ea65e1f5 100644 --- a/code/core/src/manager-api/modules/layout.ts +++ b/code/core/src/manager-api/modules/layout.ts @@ -1,14 +1,16 @@ -import { global } from '@storybook/global'; -import pick from 'lodash/pick.js'; -import { dequal as deepEqual } from 'dequal'; +import type { ThemeVars } from '@storybook/core/theming'; import { create } from '@storybook/core/theming/create'; +import type { API_Layout, API_PanelPositions, API_UI } from '@storybook/core/types'; +import { global } from '@storybook/global'; + import { SET_CONFIG } from '@storybook/core/core-events'; -import type { ThemeVars } from '@storybook/core/theming'; -import type { API_Layout, API_PanelPositions, API_UI } from '@storybook/core/types'; +import { dequal as deepEqual } from 'dequal'; +import pick from 'lodash/pick.js'; + import merge from '../lib/merge'; -import type { State } from '../root'; import type { ModuleFn } from '../lib/types'; +import type { State } from '../root'; const { document } = global; diff --git a/code/core/src/manager-api/modules/notifications.ts b/code/core/src/manager-api/modules/notifications.ts index dcabddd628e..c234191d014 100644 --- a/code/core/src/manager-api/modules/notifications.ts +++ b/code/core/src/manager-api/modules/notifications.ts @@ -1,5 +1,7 @@ import type { API_Notification } from '@storybook/core/types'; + import partition from 'lodash/partition.js'; + import type { ModuleFn } from '../lib/types'; export interface SubState { diff --git a/code/core/src/manager-api/modules/provider.ts b/code/core/src/manager-api/modules/provider.ts index 730195392fc..0e22115369e 100644 --- a/code/core/src/manager-api/modules/provider.ts +++ b/code/core/src/manager-api/modules/provider.ts @@ -1,4 +1,5 @@ import type { API_IframeRenderer } from '@storybook/core/types'; + import type { ModuleFn } from '../lib/types'; export interface SubAPI { diff --git a/code/core/src/manager-api/modules/refs.ts b/code/core/src/manager-api/modules/refs.ts index 50901f28190..29b03eadf11 100644 --- a/code/core/src/manager-api/modules/refs.ts +++ b/code/core/src/manager-api/modules/refs.ts @@ -1,21 +1,21 @@ -import { global } from '@storybook/global'; -import { dedent } from 'ts-dedent'; import type { API_ComposedRef, API_ComposedRefUpdate, + API_IndexHash, API_Refs, API_SetRefData, - SetStoriesStoryData, - API_IndexHash, API_StoryMapper, + SetStoriesStoryData, StoryIndex, } from '@storybook/core/types'; +import { global } from '@storybook/global'; + +import { dedent } from 'ts-dedent'; import { transformSetStoriesStoryDataToPreparedStoryIndex, transformStoryIndexToStoriesHash, } from '../lib/stories'; - import type { ModuleFn } from '../lib/types'; const { location, fetch } = global; diff --git a/code/core/src/manager-api/modules/settings.ts b/code/core/src/manager-api/modules/settings.ts index 24bd16c327d..59fdab20706 100644 --- a/code/core/src/manager-api/modules/settings.ts +++ b/code/core/src/manager-api/modules/settings.ts @@ -1,4 +1,5 @@ import type { API_Settings, StoryId } from '@storybook/core/types'; + import type { ModuleFn } from '../lib/types'; export interface SubAPI { diff --git a/code/core/src/manager-api/modules/shortcuts.ts b/code/core/src/manager-api/modules/shortcuts.ts index e65a7767faa..58d2c2d642d 100644 --- a/code/core/src/manager-api/modules/shortcuts.ts +++ b/code/core/src/manager-api/modules/shortcuts.ts @@ -1,5 +1,6 @@ /* eslint-disable @typescript-eslint/naming-convention */ import { global } from '@storybook/global'; + import { FORCE_REMOUNT, PREVIEW_KEYDOWN, @@ -7,10 +8,9 @@ import { STORIES_EXPAND_ALL, } from '@storybook/core/core-events'; -import type { ModuleFn } from '../lib/types'; - import type { KeyboardEventLike } from '../lib/shortcut'; -import { shortcutMatchesShortcut, eventToShortcut } from '../lib/shortcut'; +import { eventToShortcut, shortcutMatchesShortcut } from '../lib/shortcut'; +import type { ModuleFn } from '../lib/types'; import { focusableUIElements } from './layout'; const { navigator, document } = global; diff --git a/code/core/src/manager-api/modules/stories.ts b/code/core/src/manager-api/modules/stories.ts index 23edae60ad9..20bfdee92db 100644 --- a/code/core/src/manager-api/modules/stories.ts +++ b/code/core/src/manager-api/modules/stories.ts @@ -1,61 +1,60 @@ -import { global } from '@storybook/global'; -import { toId, sanitize } from '@storybook/csf'; import type { - StoryKind, - ComponentTitle, - StoryName, - StoryId, - Args, API_ComposedRef, + API_DocsEntry, + API_FilterFunction, API_HashEntry, + API_IndexHash, API_LeafEntry, + API_LoadedRefData, API_PreparedStoryIndex, - SetStoriesPayload, + API_StatusState, + API_StatusUpdate, API_StoryEntry, + API_ViewMode, + Args, + ComponentTitle, + DocsPreparedPayload, + SetStoriesPayload, + StoryId, StoryIndex, - API_LoadedRefData, - API_IndexHash, + StoryKind, + StoryName, StoryPreparedPayload, - DocsPreparedPayload, - API_DocsEntry, - API_ViewMode, - API_StatusState, - API_StatusUpdate, - API_FilterFunction, } from '@storybook/core/types'; +import { sanitize, toId } from '@storybook/csf'; +import { global } from '@storybook/global'; + +import { logger } from '@storybook/core/client-logger'; import { + CONFIG_ERROR, + CURRENT_STORY_WAS_SET, + DOCS_PREPARED, PRELOAD_ENTRIES, - STORY_PREPARED, - UPDATE_STORY_ARGS, RESET_STORY_ARGS, - STORY_ARGS_UPDATED, - STORY_CHANGED, SELECT_STORY, - SET_STORIES, + SET_CONFIG, + SET_CURRENT_STORY, SET_INDEX, - STORY_SPECIFIED, + SET_STORIES, + STORY_ARGS_UPDATED, + STORY_CHANGED, STORY_INDEX_INVALIDATED, - CONFIG_ERROR, - CURRENT_STORY_WAS_SET, STORY_MISSING, - DOCS_PREPARED, - SET_CURRENT_STORY, - SET_CONFIG, + STORY_PREPARED, + STORY_SPECIFIED, + UPDATE_STORY_ARGS, } from '@storybook/core/core-events'; -import { logger } from '@storybook/core/client-logger'; import { getEventMetadata } from '../lib/events'; - import { + addPreparedStories, denormalizeStoryParameters, - transformStoryIndexToStoriesHash, getComponentLookupList, getStoriesLookupList, - addPreparedStories, + transformStoryIndexToStoriesHash, } from '../lib/stories'; - -import type { ComposedRef } from '../root'; import type { ModuleFn } from '../lib/types'; +import type { ComposedRef } from '../root'; const { fetch } = global; const STORY_INDEX_PATH = './index.json'; diff --git a/code/core/src/manager-api/modules/url.ts b/code/core/src/manager-api/modules/url.ts index d69e194a694..c5a23e57a4f 100644 --- a/code/core/src/manager-api/modules/url.ts +++ b/code/core/src/manager-api/modules/url.ts @@ -1,16 +1,18 @@ +import type { NavigateOptions } from '@storybook/core/router'; +import { buildArgsParam, queryFromLocation } from '@storybook/core/router'; +import type { API_Layout, API_UI, Args } from '@storybook/core/types'; +import { global } from '@storybook/global'; + import { + GLOBALS_UPDATED, NAVIGATE_URL, - STORY_ARGS_UPDATED, SET_CURRENT_STORY, - GLOBALS_UPDATED, + STORY_ARGS_UPDATED, UPDATE_QUERY_PARAMS, } from '@storybook/core/core-events'; -import type { NavigateOptions } from '@storybook/core/router'; -import { queryFromLocation, buildArgsParam } from '@storybook/core/router'; + import { dequal as deepEqual } from 'dequal'; -import { global } from '@storybook/global'; -import type { API_Layout, API_UI, Args } from '@storybook/core/types'; import type { ModuleArgs, ModuleFn } from '../lib/types'; import { defaultLayoutState } from './layout'; diff --git a/code/core/src/manager-api/modules/versions.ts b/code/core/src/manager-api/modules/versions.ts index 16015cde837..734ba044283 100644 --- a/code/core/src/manager-api/modules/versions.ts +++ b/code/core/src/manager-api/modules/versions.ts @@ -1,11 +1,11 @@ +import type { API_UnknownEntries, API_Version, API_Versions } from '@storybook/core/types'; import { global } from '@storybook/global'; -import semver from 'semver'; -import memoize from 'memoizerific'; -import type { API_UnknownEntries, API_Version, API_Versions } from '@storybook/core/types'; -import { version as currentVersion } from '../version'; +import memoize from 'memoizerific'; +import semver from 'semver'; import type { ModuleFn } from '../lib/types'; +import { version as currentVersion } from '../version'; const { VERSIONCHECK } = global; diff --git a/code/core/src/manager-api/modules/whatsnew.tsx b/code/core/src/manager-api/modules/whatsnew.tsx index 71e6b9e03d8..7878f592006 100644 --- a/code/core/src/manager-api/modules/whatsnew.tsx +++ b/code/core/src/manager-api/modules/whatsnew.tsx @@ -1,5 +1,8 @@ import React from 'react'; + import { global } from '@storybook/global'; +import { StorybookIcon } from '@storybook/icons'; + import type { WhatsNewCache, WhatsNewData } from '@storybook/core/core-events'; import { REQUEST_WHATS_NEW_DATA, @@ -7,8 +10,8 @@ import { SET_WHATS_NEW_CACHE, TOGGLE_WHATS_NEW_NOTIFICATIONS, } from '@storybook/core/core-events'; + import type { ModuleFn } from '../lib/types'; -import { StorybookIcon } from '@storybook/icons'; export type SubState = { whatsNewData?: WhatsNewData; diff --git a/code/core/src/manager-api/root.tsx b/code/core/src/manager-api/root.tsx index 8d23d1d8fcd..0a1fad42c3e 100644 --- a/code/core/src/manager-api/root.tsx +++ b/code/core/src/manager-api/root.tsx @@ -9,10 +9,10 @@ import React, { useMemo, useRef, } from 'react'; -import mergeWith from 'lodash/mergeWith.js'; + +import type { Listener } from '@storybook/core/channels'; +import type { RouterData } from '@storybook/core/router'; import type { - Args, - ArgTypes, API_ComponentEntry, API_ComposedRef, API_DocsEntry, @@ -26,49 +26,42 @@ import type { API_RootEntry, API_StateMerger, API_StoryEntry, + ArgTypes, + Args, + Globals, Parameters, StoryId, - Globals, } from '@storybook/core/types'; +import { deprecate } from '@storybook/core/client-logger'; import { - STORY_CHANGED, + SET_STORIES, SHARED_STATE_CHANGED, SHARED_STATE_SET, - SET_STORIES, + STORY_CHANGED, } from '@storybook/core/core-events'; -import type { RouterData } from '@storybook/core/router'; -import type { Listener } from '@storybook/core/channels'; -import { deprecate } from '@storybook/core/client-logger'; + +import mergeWith from 'lodash/mergeWith.js'; import { createContext } from './context'; -import type { Options } from './store'; -import Store from './store'; import getInitialState from './initial-state'; - -import * as provider from './modules/provider'; - +import { types } from './lib/addons'; +import type { ModuleFn } from './lib/types'; import * as addons from './modules/addons'; - import * as channel from './modules/channel'; - +import * as globals from './modules/globals'; +import * as layout from './modules/layout'; import * as notifications from './modules/notifications'; -import * as settings from './modules/settings'; - -import * as stories from './modules/stories'; - +import * as provider from './modules/provider'; import * as refs from './modules/refs'; -import * as layout from './modules/layout'; +import * as settings from './modules/settings'; import * as shortcuts from './modules/shortcuts'; - +import * as stories from './modules/stories'; import * as url from './modules/url'; import * as version from './modules/versions'; import * as whatsnew from './modules/whatsnew'; - -import * as globals from './modules/globals'; -import type { ModuleFn } from './lib/types'; - -import { types } from './lib/addons'; +import type { Options } from './store'; +import Store from './store'; export * from './lib/request-response'; export * from './lib/shortcut'; diff --git a/code/core/src/manager-api/store.ts b/code/core/src/manager-api/store.ts index ffb3b43dbc8..ca19eb4f429 100644 --- a/code/core/src/manager-api/store.ts +++ b/code/core/src/manager-api/store.ts @@ -1,7 +1,7 @@ import type { StoreAPI } from 'store2'; import store from 'store2'; -import storeSetup from './lib/store-setup'; +import storeSetup from './lib/store-setup'; import type { State } from './root'; // setting up the store, overriding set and get to use telejson diff --git a/code/core/src/manager-api/tests/addons.test.js b/code/core/src/manager-api/tests/addons.test.js index 8d0928d9f82..4d64ecc9522 100644 --- a/code/core/src/manager-api/tests/addons.test.js +++ b/code/core/src/manager-api/tests/addons.test.js @@ -1,5 +1,7 @@ -import { describe, it, expect, vi } from 'vitest'; +import { describe, expect, it, vi } from 'vitest'; + import { Addon_TypesEnum as types } from '@storybook/core/types'; + import { init as initAddons } from '../modules/addons'; const PANELS = { diff --git a/code/core/src/manager-api/tests/events.test.ts b/code/core/src/manager-api/tests/events.test.ts index ac0c4ed7887..9adc7a06eb1 100644 --- a/code/core/src/manager-api/tests/events.test.ts +++ b/code/core/src/manager-api/tests/events.test.ts @@ -1,4 +1,5 @@ -import { describe, it, expect, vi } from 'vitest'; +import { describe, expect, it, vi } from 'vitest'; + import { getEventMetadata } from '../lib/events'; import type { API } from '../root'; diff --git a/code/core/src/manager-api/tests/globals.test.ts b/code/core/src/manager-api/tests/globals.test.ts index 52f3fa37947..96da32051f2 100644 --- a/code/core/src/manager-api/tests/globals.test.ts +++ b/code/core/src/manager-api/tests/globals.test.ts @@ -1,20 +1,22 @@ -import { describe, beforeEach, it, expect, vi } from 'vitest'; -import { EventEmitter } from 'events'; +import { beforeEach, describe, expect, it, vi } from 'vitest'; + +import type { GlobalsUpdatedPayload, SetGlobalsPayload } from '@storybook/core/types'; + +import { logger as _logger } from '@storybook/core/client-logger'; import { - SET_STORIES, + GLOBALS_UPDATED, SET_GLOBALS, + SET_STORIES, UPDATE_GLOBALS, - GLOBALS_UPDATED, } from '@storybook/core/core-events'; -import { logger as _logger } from '@storybook/core/client-logger'; -import type { API } from '../root'; -import type { SubAPI } from '../modules/globals'; -import { init as initModule } from '../modules/globals'; -import type { ModuleArgs } from '../lib/types'; +import { EventEmitter } from 'events'; import { getEventMetadata as _getEventData } from '../lib/events'; -import type { GlobalsUpdatedPayload, SetGlobalsPayload } from '@storybook/core/types'; +import type { ModuleArgs } from '../lib/types'; +import type { SubAPI } from '../modules/globals'; +import { init as initModule } from '../modules/globals'; +import type { API } from '../root'; const getEventMetadata = vi.mocked(_getEventData, true); const logger = vi.mocked(_logger, true); diff --git a/code/core/src/manager-api/tests/layout.test.ts b/code/core/src/manager-api/tests/layout.test.ts index a9ced49e1ac..7b1c7361f25 100644 --- a/code/core/src/manager-api/tests/layout.test.ts +++ b/code/core/src/manager-api/tests/layout.test.ts @@ -1,15 +1,17 @@ import type { Mock } from 'vitest'; -import { expect, describe, beforeEach, it, vi } from 'vitest'; +import { beforeEach, describe, expect, it, vi } from 'vitest'; import { themes } from '@storybook/core/theming'; import type { API_Provider } from '@storybook/core/types'; + import EventEmitter from 'events'; -import type { SubAPI, SubState } from '../modules/layout'; + +import type { ModuleArgs } from '../lib/types'; import type { SubState as AddonsSubState } from '../modules/addons'; +import type { SubAPI, SubState } from '../modules/layout'; import { defaultLayoutState, init as initLayout } from '../modules/layout'; -import type Store from '../store'; import type { API, State } from '../root'; -import type { ModuleArgs } from '../lib/types'; +import type Store from '../store'; describe('layout API', () => { let layoutApi: SubAPI; diff --git a/code/core/src/manager-api/tests/mockStoriesEntries.ts b/code/core/src/manager-api/tests/mockStoriesEntries.ts index 0bb2df381aa..2bccab05718 100644 --- a/code/core/src/manager-api/tests/mockStoriesEntries.ts +++ b/code/core/src/manager-api/tests/mockStoriesEntries.ts @@ -1,4 +1,4 @@ -import type { StoryIndex, API_PreparedStoryIndex } from '@storybook/core/types'; +import type { API_PreparedStoryIndex, StoryIndex } from '@storybook/core/types'; export const mockEntries: StoryIndex['entries'] = { 'component-a--docs': { diff --git a/code/core/src/manager-api/tests/notifications.test.js b/code/core/src/manager-api/tests/notifications.test.js index 8d2005db683..95ccbe1f118 100644 --- a/code/core/src/manager-api/tests/notifications.test.js +++ b/code/core/src/manager-api/tests/notifications.test.js @@ -1,4 +1,5 @@ -import { describe, it, expect, vi } from 'vitest'; +import { describe, expect, it, vi } from 'vitest'; + import { init as initNotifications } from '../modules/notifications'; describe('notifications API', () => { diff --git a/code/core/src/manager-api/tests/refs.test.ts b/code/core/src/manager-api/tests/refs.test.ts index 96d2b3b8d84..c8d65baafc5 100644 --- a/code/core/src/manager-api/tests/refs.test.ts +++ b/code/core/src/manager-api/tests/refs.test.ts @@ -1,9 +1,11 @@ -import { describe, it, expect, vi } from 'vitest'; -import { global } from '@storybook/global'; +import { describe, expect, it, vi } from 'vitest'; + import type { StoryIndex } from '@storybook/core/types'; -import type { State } from '../root'; +import { global } from '@storybook/global'; + import { transformStoryIndexToStoriesHash } from '../lib/stories'; import { getSourceType, init as initRefs } from '../modules/refs'; +import type { State } from '../root'; import type Store from '../store'; const { fetch } = global; diff --git a/code/core/src/manager-api/tests/shortcut.test.js b/code/core/src/manager-api/tests/shortcut.test.js index 5b0db8e3967..d45d50afb18 100644 --- a/code/core/src/manager-api/tests/shortcut.test.js +++ b/code/core/src/manager-api/tests/shortcut.test.js @@ -2,6 +2,7 @@ import { describe, expect, it } from 'vitest'; import { global } from '@storybook/global'; + import { eventToShortcut, keyToSymbol } from '../lib/shortcut'; const { KeyboardEvent } = global; diff --git a/code/core/src/manager-api/tests/shortcuts.test.js b/code/core/src/manager-api/tests/shortcuts.test.js index 9aba57c756f..be1efd4063d 100644 --- a/code/core/src/manager-api/tests/shortcuts.test.js +++ b/code/core/src/manager-api/tests/shortcuts.test.js @@ -1,4 +1,5 @@ -import { describe, it, expect, vi } from 'vitest'; +import { describe, expect, it, vi } from 'vitest'; + import { init as initShortcuts } from '../modules/shortcuts'; function createMockStore() { diff --git a/code/core/src/manager-api/tests/store.test.js b/code/core/src/manager-api/tests/store.test.js index c0f88f58640..e77bc1cd289 100644 --- a/code/core/src/manager-api/tests/store.test.js +++ b/code/core/src/manager-api/tests/store.test.js @@ -1,6 +1,8 @@ -import { describe, it, expect, vi } from 'vitest'; -import store2 from 'store2'; +import { describe, expect, it, vi } from 'vitest'; + import flushPromises from 'flush-promises'; +import store2 from 'store2'; + import Store, { STORAGE_KEY } from '../store'; vi.mock('store2', () => ({ diff --git a/code/core/src/manager-api/tests/stories.test.ts b/code/core/src/manager-api/tests/stories.test.ts index ea02cdfd464..16b5c926c9c 100644 --- a/code/core/src/manager-api/tests/stories.test.ts +++ b/code/core/src/manager-api/tests/stories.test.ts @@ -1,30 +1,32 @@ import type { Mocked } from 'vitest'; -import { describe, it, expect, vi } from 'vitest'; +import { describe, expect, it, vi } from 'vitest'; + +import type { API_StoryEntry } from '@storybook/core/types'; +import { global } from '@storybook/global'; + import { - STORY_ARGS_UPDATED, - UPDATE_STORY_ARGS, + CONFIG_ERROR, + CURRENT_STORY_WAS_SET, + DOCS_PREPARED, RESET_STORY_ARGS, + SET_INDEX, SET_STORIES, - STORY_SPECIFIED, - STORY_PREPARED, + STORY_ARGS_UPDATED, STORY_INDEX_INVALIDATED, - CONFIG_ERROR, - SET_INDEX, - CURRENT_STORY_WAS_SET, STORY_MISSING, - DOCS_PREPARED, + STORY_PREPARED, + STORY_SPECIFIED, + UPDATE_STORY_ARGS, } from '@storybook/core/core-events'; + import { EventEmitter } from 'events'; -import { global } from '@storybook/global'; -import type { API_StoryEntry } from '@storybook/core/types'; import { getEventMetadata as getEventMetadataOriginal } from '../lib/events'; - +import type { ModuleArgs } from '../lib/types'; import { init as initStories } from '../modules/stories'; -import type Store from '../store'; import type { API, State } from '../root'; -import { mockEntries, docsEntries, preparedEntries, navigationEntries } from './mockStoriesEntries'; -import type { ModuleArgs } from '../lib/types'; +import type Store from '../store'; +import { docsEntries, mockEntries, navigationEntries, preparedEntries } from './mockStoriesEntries'; const mockGetEntries = vi.fn(); const fetch = vi.mocked(global.fetch); diff --git a/code/core/src/manager-api/tests/url.test.js b/code/core/src/manager-api/tests/url.test.js index a4a9de83ba7..a3612650530 100644 --- a/code/core/src/manager-api/tests/url.test.js +++ b/code/core/src/manager-api/tests/url.test.js @@ -1,12 +1,13 @@ -import { describe, beforeEach, it, expect, vi } from 'vitest'; +import { beforeEach, describe, expect, it, vi } from 'vitest'; import { - SET_CURRENT_STORY, GLOBALS_UPDATED, + SET_CURRENT_STORY, UPDATE_QUERY_PARAMS, } from '@storybook/core/core-events'; import EventEmitter from 'events'; + import { init as initURL } from '../modules/url'; vi.mock('@storybook/core/client-logger'); diff --git a/code/core/src/manager-api/tests/versions.test.js b/code/core/src/manager-api/tests/versions.test.js index 4ed44dc5059..280deaeed2a 100644 --- a/code/core/src/manager-api/tests/versions.test.js +++ b/code/core/src/manager-api/tests/versions.test.js @@ -1,4 +1,5 @@ -import { describe, it, expect, vi, beforeEach } from 'vitest'; +import { beforeEach, describe, expect, it, vi } from 'vitest'; + import { global } from '@storybook/global'; import { init as initVersions } from '../modules/versions'; diff --git a/code/core/src/manager/App.tsx b/code/core/src/manager/App.tsx index c4679ffe43c..287f9736cc7 100644 --- a/code/core/src/manager/App.tsx +++ b/code/core/src/manager/App.tsx @@ -1,13 +1,14 @@ import type { ComponentProps } from 'react'; import React from 'react'; + import { Global, createGlobal } from '@storybook/core/theming'; import type { Addon_PageType } from '@storybook/core/types'; -import Sidebar from './container/Sidebar'; -import Preview from './container/Preview'; -import Panel from './container/Panel'; import { Layout } from './components/layout/Layout'; import { useLayout } from './components/layout/LayoutProvider'; +import Panel from './container/Panel'; +import Preview from './container/Preview'; +import Sidebar from './container/Sidebar'; type Props = { managerLayoutState: ComponentProps['managerLayoutState']; diff --git a/code/core/src/manager/FakeProvider.tsx b/code/core/src/manager/FakeProvider.tsx index 397a91b86a6..dc66dedf0f6 100644 --- a/code/core/src/manager/FakeProvider.tsx +++ b/code/core/src/manager/FakeProvider.tsx @@ -1,6 +1,9 @@ import React from 'react'; + import { styled } from '@storybook/core/theming'; + import { addons } from '@storybook/core/manager-api'; + import Provider from './provider'; export class FakeProvider extends Provider { diff --git a/code/core/src/manager/README.md b/code/core/src/manager/README.md index c91e4b2cb06..ff55e2830fd 100644 --- a/code/core/src/manager/README.md +++ b/code/core/src/manager/README.md @@ -55,8 +55,8 @@ export default class MyProvider extends Provider { Then you need to initialize the UI like this: ```js -import global from 'global'; import { renderStorybookUI } from '@storybook/manager'; +import global from 'global'; import Provider from './provider'; const { document } = global; diff --git a/code/core/src/manager/__tests__/index.test.ts b/code/core/src/manager/__tests__/index.test.ts index ce85a45e293..792484347ad 100644 --- a/code/core/src/manager/__tests__/index.test.ts +++ b/code/core/src/manager/__tests__/index.test.ts @@ -1,6 +1,6 @@ // @vitest-environment happy-dom +import { describe, expect, it } from 'vitest'; -import { describe, it, expect } from 'vitest'; import { renderStorybookUI } from '..'; describe('Main API', () => { diff --git a/code/core/src/manager/components/layout/Layout.stories.tsx b/code/core/src/manager/components/layout/Layout.stories.tsx index 8282d843458..6a133d6c492 100644 --- a/code/core/src/manager/components/layout/Layout.stories.tsx +++ b/code/core/src/manager/components/layout/Layout.stories.tsx @@ -1,14 +1,16 @@ -import { action } from '@storybook/addon-actions'; import type { FC, PropsWithChildren } from 'react'; import React, { useState } from 'react'; +import { LocationProvider } from '@storybook/core/router'; import { styled } from '@storybook/core/theming'; import type { Meta, StoryObj } from '@storybook/react'; import { fn } from '@storybook/test'; + +import { action } from '@storybook/addon-actions'; + +import MobileNavigationStoriesMeta from '../mobile/navigation/MobileNavigation.stories'; import { Layout } from './Layout'; import { LayoutProvider } from './LayoutProvider'; -import { LocationProvider } from '@storybook/core/router'; -import MobileNavigationStoriesMeta from '../mobile/navigation/MobileNavigation.stories'; const PlaceholderBlock = styled.div({ width: '100%', diff --git a/code/core/src/manager/components/layout/Layout.tsx b/code/core/src/manager/components/layout/Layout.tsx index 82e6b532c9a..a984a5a266d 100644 --- a/code/core/src/manager/components/layout/Layout.tsx +++ b/code/core/src/manager/components/layout/Layout.tsx @@ -1,12 +1,14 @@ import React, { useEffect, useLayoutEffect, useState } from 'react'; + +import { Match } from '@storybook/core/router'; import { styled } from '@storybook/core/theming'; import type { API_Layout, API_ViewMode } from '@storybook/core/types'; -import { useDragging } from './useDragging'; -import { MobileNavigation } from '../mobile/navigation/MobileNavigation'; + import { MEDIA_DESKTOP_BREAKPOINT } from '../../constants'; -import { useLayout } from './LayoutProvider'; import { Notifications } from '../../container/Notifications'; -import { Match } from '@storybook/core/router'; +import { MobileNavigation } from '../mobile/navigation/MobileNavigation'; +import { useLayout } from './LayoutProvider'; +import { useDragging } from './useDragging'; interface InternalLayoutState { isDragging: boolean; diff --git a/code/core/src/manager/components/layout/LayoutProvider.tsx b/code/core/src/manager/components/layout/LayoutProvider.tsx index 81c342e0546..88f3b7a781f 100644 --- a/code/core/src/manager/components/layout/LayoutProvider.tsx +++ b/code/core/src/manager/components/layout/LayoutProvider.tsx @@ -1,7 +1,8 @@ import type { FC, PropsWithChildren } from 'react'; import React, { createContext, useContext, useMemo, useState } from 'react'; -import { useMediaQuery } from '../hooks/useMedia'; + import { BREAKPOINT } from '../../constants'; +import { useMediaQuery } from '../hooks/useMedia'; type LayoutContextType = { isMobileMenuOpen: boolean; diff --git a/code/core/src/manager/components/layout/useDragging.ts b/code/core/src/manager/components/layout/useDragging.ts index 1c00f516c23..a62f6c29e4a 100644 --- a/code/core/src/manager/components/layout/useDragging.ts +++ b/code/core/src/manager/components/layout/useDragging.ts @@ -1,5 +1,6 @@ import type { Dispatch, SetStateAction } from 'react'; import { useEffect, useRef } from 'react'; + import type { LayoutState } from './Layout'; // the distance from the edge of the screen at which the panel/sidebar will snap to the edge diff --git a/code/core/src/manager/components/mobile/about/MobileAbout.stories.tsx b/code/core/src/manager/components/mobile/about/MobileAbout.stories.tsx index e552171cca4..ee13d985f3c 100644 --- a/code/core/src/manager/components/mobile/about/MobileAbout.stories.tsx +++ b/code/core/src/manager/components/mobile/about/MobileAbout.stories.tsx @@ -1,9 +1,12 @@ -import type { Meta, StoryObj } from '@storybook/react'; -import { ManagerContext } from '@storybook/core/manager-api'; import React, { useEffect } from 'react'; + +import type { Meta, StoryObj } from '@storybook/react'; import { within } from '@storybook/test'; -import { MobileAbout } from './MobileAbout'; + +import { ManagerContext } from '@storybook/core/manager-api'; + import { LayoutProvider, useLayout } from '../../layout/LayoutProvider'; +import { MobileAbout } from './MobileAbout'; /** * A helper component to open the about page via the MobileLayoutContext diff --git a/code/core/src/manager/components/mobile/about/MobileAbout.tsx b/code/core/src/manager/components/mobile/about/MobileAbout.tsx index 2b65bf59c5a..a794ba00ea9 100644 --- a/code/core/src/manager/components/mobile/about/MobileAbout.tsx +++ b/code/core/src/manager/components/mobile/about/MobileAbout.tsx @@ -1,12 +1,15 @@ import type { FC } from 'react'; import React, { useRef } from 'react'; -import { Transition, type TransitionStatus } from 'react-transition-group'; -import { styled } from '@storybook/core/theming'; + import { Link } from '@storybook/core/components'; +import { styled } from '@storybook/core/theming'; import { ArrowLeftIcon, GithubIcon, ShareAltIcon, StorybookIcon } from '@storybook/icons'; -import { UpgradeBlock } from '../../upgrade/UpgradeBlock'; + +import { Transition, type TransitionStatus } from 'react-transition-group'; + import { MOBILE_TRANSITION_DURATION } from '../../../constants'; import { useLayout } from '../../layout/LayoutProvider'; +import { UpgradeBlock } from '../../upgrade/UpgradeBlock'; export const MobileAbout: FC = () => { const { isMobileAboutOpen, setMobileAboutOpen } = useLayout(); diff --git a/code/core/src/manager/components/mobile/navigation/MobileAddonsDrawer.tsx b/code/core/src/manager/components/mobile/navigation/MobileAddonsDrawer.tsx index b17ec5e55c5..def0c9e2bdf 100644 --- a/code/core/src/manager/components/mobile/navigation/MobileAddonsDrawer.tsx +++ b/code/core/src/manager/components/mobile/navigation/MobileAddonsDrawer.tsx @@ -1,5 +1,6 @@ import type { FC, ReactNode } from 'react'; import React from 'react'; + import { styled } from '@storybook/core/theming'; interface MobileAddonsDrawerProps { diff --git a/code/core/src/manager/components/mobile/navigation/MobileMenuDrawer.tsx b/code/core/src/manager/components/mobile/navigation/MobileMenuDrawer.tsx index 8c3ac21152b..8e3de4b5158 100644 --- a/code/core/src/manager/components/mobile/navigation/MobileMenuDrawer.tsx +++ b/code/core/src/manager/components/mobile/navigation/MobileMenuDrawer.tsx @@ -1,11 +1,14 @@ import type { FC } from 'react'; import React, { useRef } from 'react'; + import { styled } from '@storybook/core/theming'; + import { Transition } from 'react-transition-group'; import type { TransitionStatus } from 'react-transition-group/Transition'; -import { MobileAbout } from '../about/MobileAbout'; + import { MOBILE_TRANSITION_DURATION } from '../../../constants'; import { useLayout } from '../../layout/LayoutProvider'; +import { MobileAbout } from '../about/MobileAbout'; interface MobileMenuDrawerProps { children?: React.ReactNode; diff --git a/code/core/src/manager/components/mobile/navigation/MobileNavigation.stories.tsx b/code/core/src/manager/components/mobile/navigation/MobileNavigation.stories.tsx index 552556add58..e445d73dea2 100644 --- a/code/core/src/manager/components/mobile/navigation/MobileNavigation.stories.tsx +++ b/code/core/src/manager/components/mobile/navigation/MobileNavigation.stories.tsx @@ -1,10 +1,14 @@ -import type { Meta, StoryObj } from '@storybook/react'; import React from 'react'; -import { ManagerContext } from '@storybook/core/manager-api'; + +import type { Meta, StoryObj } from '@storybook/react'; import { within } from '@storybook/test'; + +import { ManagerContext } from '@storybook/core/manager-api'; + import { startCase } from 'lodash'; -import { MobileNavigation } from './MobileNavigation'; + import { LayoutProvider, useLayout } from '../../layout/LayoutProvider'; +import { MobileNavigation } from './MobileNavigation'; const MockPanel = () => { const { setMobilePanelOpen } = useLayout(); diff --git a/code/core/src/manager/components/mobile/navigation/MobileNavigation.tsx b/code/core/src/manager/components/mobile/navigation/MobileNavigation.tsx index 963c56360f1..cef5b139b62 100644 --- a/code/core/src/manager/components/mobile/navigation/MobileNavigation.tsx +++ b/code/core/src/manager/components/mobile/navigation/MobileNavigation.tsx @@ -1,12 +1,15 @@ import type { FC } from 'react'; import React from 'react'; -import { styled } from '@storybook/core/theming'; + import { IconButton } from '@storybook/core/components'; -import { useStorybookApi, useStorybookState } from '@storybook/core/manager-api'; +import { styled } from '@storybook/core/theming'; import { BottomBarToggleIcon, MenuIcon } from '@storybook/icons'; -import { MobileMenuDrawer } from './MobileMenuDrawer'; -import { MobileAddonsDrawer } from './MobileAddonsDrawer'; + +import { useStorybookApi, useStorybookState } from '@storybook/core/manager-api'; + import { useLayout } from '../../layout/LayoutProvider'; +import { MobileAddonsDrawer } from './MobileAddonsDrawer'; +import { MobileMenuDrawer } from './MobileMenuDrawer'; interface MobileNavigationProps { menu?: React.ReactNode; diff --git a/code/core/src/manager/components/notifications/NotificationItem.stories.tsx b/code/core/src/manager/components/notifications/NotificationItem.stories.tsx index 93588e4a535..1914a0fe798 100644 --- a/code/core/src/manager/components/notifications/NotificationItem.stories.tsx +++ b/code/core/src/manager/components/notifications/NotificationItem.stories.tsx @@ -1,15 +1,18 @@ import React from 'react'; -import { action } from '@storybook/addon-actions'; + import { LocationProvider } from '@storybook/core/router'; -import type { Meta, StoryObj } from '@storybook/react'; -import NotificationItem from './NotificationItem'; import { AccessibilityIcon as AccessibilityIconIcon, BookIcon as BookIconIcon, FaceHappyIcon, } from '@storybook/icons'; +import type { Meta, StoryObj } from '@storybook/react'; import { expect, fn, userEvent, waitFor, within } from '@storybook/test'; +import { action } from '@storybook/addon-actions'; + +import NotificationItem from './NotificationItem'; + const meta = { component: NotificationItem, title: 'Notifications/NotificationItem', diff --git a/code/core/src/manager/components/notifications/NotificationItem.tsx b/code/core/src/manager/components/notifications/NotificationItem.tsx index f912828783a..66a8cef66bf 100644 --- a/code/core/src/manager/components/notifications/NotificationItem.tsx +++ b/code/core/src/manager/components/notifications/NotificationItem.tsx @@ -1,13 +1,16 @@ import type { FC, SyntheticEvent } from 'react'; import React, { useCallback, useEffect, useRef } from 'react'; -import { type State } from '@storybook/core/manager-api'; -import { Link } from '@storybook/core/router'; -import { keyframes, styled, useTheme } from '@storybook/core/theming'; + import type { IconsProps } from '@storybook/core/components'; import { IconButton, Icons } from '@storybook/core/components'; -import { transparentize } from 'polished'; +import { Link } from '@storybook/core/router'; +import { keyframes, styled, useTheme } from '@storybook/core/theming'; import { CloseAltIcon } from '@storybook/icons'; +import { type State } from '@storybook/core/manager-api'; + +import { transparentize } from 'polished'; + const slideIn = keyframes({ '0%': { opacity: 0, diff --git a/code/core/src/manager/components/notifications/NotificationList.stories.tsx b/code/core/src/manager/components/notifications/NotificationList.stories.tsx index d2842e5eb87..60554232747 100644 --- a/code/core/src/manager/components/notifications/NotificationList.stories.tsx +++ b/code/core/src/manager/components/notifications/NotificationList.stories.tsx @@ -1,9 +1,10 @@ import React from 'react'; + import { LocationProvider } from '@storybook/core/router'; import type { Meta, StoryObj } from '@storybook/react'; -import { NotificationList } from './NotificationList'; import * as itemStories from './NotificationItem.stories'; +import { NotificationList } from './NotificationList'; const meta = { component: NotificationList, diff --git a/code/core/src/manager/components/notifications/NotificationList.tsx b/code/core/src/manager/components/notifications/NotificationList.tsx index 604ed50c510..a0c8fabd13c 100644 --- a/code/core/src/manager/components/notifications/NotificationList.tsx +++ b/code/core/src/manager/components/notifications/NotificationList.tsx @@ -1,10 +1,13 @@ import type { FC } from 'react'; import React from 'react'; -import type { State } from '@storybook/core/manager-api'; + import { styled } from '@storybook/core/theming'; import type { CSSObject } from '@storybook/core/theming'; -import NotificationItem from './NotificationItem'; + +import type { State } from '@storybook/core/manager-api'; + import { MEDIA_DESKTOP_BREAKPOINT } from '../../constants'; +import NotificationItem from './NotificationItem'; interface NotificationListProps { notifications: State['notifications']; diff --git a/code/core/src/manager/components/panel/Panel.stories.tsx b/code/core/src/manager/components/panel/Panel.stories.tsx index 7b6691c314c..3caa6a3c0fb 100644 --- a/code/core/src/manager/components/panel/Panel.stories.tsx +++ b/code/core/src/manager/components/panel/Panel.stories.tsx @@ -1,12 +1,15 @@ import type { EventHandler, FocusEvent, MouseEvent } from 'react'; import React, { useCallback, useRef, useState } from 'react'; -import { action } from '@storybook/addon-actions'; + import { Badge, Spaced } from '@storybook/core/components'; import type { Addon_BaseType, Addon_Collection } from '@storybook/core/types'; import { Addon_TypesEnum } from '@storybook/core/types'; import { BellIcon } from '@storybook/icons'; -import { AddonPanel } from './Panel'; + +import { action } from '@storybook/addon-actions'; + import { defaultShortcuts } from '../../settings/defaultShortcuts'; +import { AddonPanel } from './Panel'; const onSelect = action('onSelect'); const toggleVisibility = action('toggleVisibility'); diff --git a/code/core/src/manager/components/panel/Panel.tsx b/code/core/src/manager/components/panel/Panel.tsx index dad5d7f9b85..701cd94925e 100644 --- a/code/core/src/manager/components/panel/Panel.tsx +++ b/code/core/src/manager/components/panel/Panel.tsx @@ -1,10 +1,13 @@ import React, { Component } from 'react'; -import { Tabs, IconButton, Link, EmptyTabContent } from '@storybook/core/components'; -import type { State } from '@storybook/core/manager-api'; -import { shortcutToHumanString } from '@storybook/core/manager-api'; -import type { Addon_BaseType } from '@storybook/core/types'; + +import { EmptyTabContent, IconButton, Link, Tabs } from '@storybook/core/components'; import { styled } from '@storybook/core/theming'; +import type { Addon_BaseType } from '@storybook/core/types'; import { BottomBarIcon, CloseIcon, DocumentIcon, SidebarAltIcon } from '@storybook/icons'; + +import type { State } from '@storybook/core/manager-api'; +import { shortcutToHumanString } from '@storybook/core/manager-api'; + import { useLayout } from '../layout/LayoutProvider'; export interface SafeTabProps { diff --git a/code/core/src/manager/components/preview/FramesRenderer.tsx b/code/core/src/manager/components/preview/FramesRenderer.tsx index ecf627be9df..40a42c3fbe9 100644 --- a/code/core/src/manager/components/preview/FramesRenderer.tsx +++ b/code/core/src/manager/components/preview/FramesRenderer.tsx @@ -1,13 +1,16 @@ import type { FC } from 'react'; -import React, { useRef, Fragment } from 'react'; -import type { Combo } from '@storybook/core/manager-api'; -import { Consumer } from '@storybook/core/manager-api'; +import React, { Fragment, useRef } from 'react'; + import { Button, getStoryHref } from '@storybook/core/components'; import { Global, styled } from '@storybook/core/theming'; import type { CSSObject } from '@storybook/core/theming'; + +import type { Combo } from '@storybook/core/manager-api'; +import { Consumer } from '@storybook/core/manager-api'; + import { IFrame } from './Iframe'; -import type { FramesRendererProps } from './utils/types'; import { stringifyQueryParams } from './utils/stringifyQueryParams'; +import type { FramesRendererProps } from './utils/types'; const getActive = (refId: FramesRendererProps['refId'], refs: FramesRendererProps['refs']) => { if (refId && refs[refId]) { diff --git a/code/core/src/manager/components/preview/Iframe.tsx b/code/core/src/manager/components/preview/Iframe.tsx index e7f0df25114..13fd65261ec 100644 --- a/code/core/src/manager/components/preview/Iframe.tsx +++ b/code/core/src/manager/components/preview/Iframe.tsx @@ -1,7 +1,8 @@ import type { IframeHTMLAttributes } from 'react'; import React from 'react'; -import { styled } from '@storybook/core/theming'; + import { Zoom } from '@storybook/core/components'; +import { styled } from '@storybook/core/theming'; const StyledIframe = styled.iframe(({ theme }) => ({ backgroundColor: theme.background.preview, diff --git a/code/core/src/manager/components/preview/Preview.tsx b/code/core/src/manager/components/preview/Preview.tsx index 2350b58f1b3..8a459276f0e 100644 --- a/code/core/src/manager/components/preview/Preview.tsx +++ b/code/core/src/manager/components/preview/Preview.tsx @@ -1,20 +1,20 @@ import type { FC } from 'react'; import React, { Fragment, useEffect, useRef, useState } from 'react'; -import { Helmet } from 'react-helmet-async'; -import { global } from '@storybook/global'; -import { Consumer, type Combo, merge, addons, types } from '@storybook/core/manager-api'; +import { Loader } from '@storybook/core/components'; import type { Addon_BaseType, Addon_WrapperType } from '@storybook/core/types'; +import { global } from '@storybook/global'; + import { PREVIEW_BUILDER_PROGRESS, SET_CURRENT_STORY } from '@storybook/core/core-events'; +import { type Combo, Consumer, addons, merge, types } from '@storybook/core/manager-api'; -import { Loader } from '@storybook/core/components'; +import { Helmet } from 'react-helmet-async'; -import * as S from './utils/components'; -import { ZoomProvider, ZoomConsumer } from './tools/zoom'; -import { ApplyWrappers } from './Wrappers'; -import { ToolbarComp } from './Toolbar'; import { FramesRenderer } from './FramesRenderer'; - +import { ToolbarComp } from './Toolbar'; +import { ApplyWrappers } from './Wrappers'; +import { ZoomConsumer, ZoomProvider } from './tools/zoom'; +import * as S from './utils/components'; import type { PreviewProps } from './utils/types'; const canvasMapper = ({ state, api }: Combo) => ({ diff --git a/code/core/src/manager/components/preview/Toolbar.tsx b/code/core/src/manager/components/preview/Toolbar.tsx index 297764e3983..de8c1aab066 100644 --- a/code/core/src/manager/components/preview/Toolbar.tsx +++ b/code/core/src/manager/components/preview/Toolbar.tsx @@ -1,30 +1,29 @@ import React, { Fragment } from 'react'; +import { IconButton, Separator, TabBar, TabButton } from '@storybook/core/components'; import { styled } from '@storybook/core/theming'; +import { type Addon_BaseType, Addon_TypesEnum } from '@storybook/core/types'; +import { CloseIcon, ExpandIcon } from '@storybook/icons'; -import { IconButton, Separator, TabButton, TabBar } from '@storybook/core/components'; import { - shortcutToHumanString, - Consumer, - type Combo, type API, - type State, - merge, + type Combo, + Consumer, type LeafEntry, + type State, addons, + merge, + shortcutToHumanString, types, } from '@storybook/core/manager-api'; -import { Addon_TypesEnum, type Addon_BaseType } from '@storybook/core/types'; -import { CloseIcon, ExpandIcon } from '@storybook/icons'; -import { zoomTool } from './tools/zoom'; - -import type { PreviewProps } from './utils/types'; +import { useLayout } from '../layout/LayoutProvider'; +import { addonsTool } from './tools/addons'; import { copyTool } from './tools/copy'; import { ejectTool } from './tools/eject'; -import { addonsTool } from './tools/addons'; import { remountTool } from './tools/remount'; -import { useLayout } from '../layout/LayoutProvider'; +import { zoomTool } from './tools/zoom'; +import type { PreviewProps } from './utils/types'; export const getTools = (getFn: API['getElements']) => Object.values(getFn(types.TOOL)); export const getToolsExtra = (getFn: API['getElements']) => Object.values(getFn(types.TOOLEXTRA)); diff --git a/code/core/src/manager/components/preview/Wrappers.tsx b/code/core/src/manager/components/preview/Wrappers.tsx index a6ecc04a4af..299db428b1d 100644 --- a/code/core/src/manager/components/preview/Wrappers.tsx +++ b/code/core/src/manager/components/preview/Wrappers.tsx @@ -1,9 +1,11 @@ import type { FC, PropsWithChildren } from 'react'; import React, { Fragment } from 'react'; + import type { Addon_WrapperType } from '@storybook/core/types'; import { Addon_TypesEnum } from '@storybook/core/types'; -import type { ApplyWrappersProps } from './utils/types'; + import { IframeWrapper } from './utils/components'; +import type { ApplyWrappersProps } from './utils/types'; export const ApplyWrappers: FC> = ({ wrappers, diff --git a/code/core/src/manager/components/preview/tools/addons.tsx b/code/core/src/manager/components/preview/tools/addons.tsx index a0beb24f768..46d45f6eac0 100644 --- a/code/core/src/manager/components/preview/tools/addons.tsx +++ b/code/core/src/manager/components/preview/tools/addons.tsx @@ -1,10 +1,12 @@ import React from 'react'; + import { IconButton } from '@storybook/core/components'; -import { Consumer, types } from '@storybook/core/manager-api'; -import type { Combo } from '@storybook/core/manager-api'; import type { Addon_BaseType } from '@storybook/core/types'; import { BottomBarIcon, SidebarAltIcon } from '@storybook/icons'; +import { Consumer, types } from '@storybook/core/manager-api'; +import type { Combo } from '@storybook/core/manager-api'; + const menuMapper = ({ api, state }: Combo) => ({ isVisible: api.getIsPanelShown(), singleStory: state.singleStory, diff --git a/code/core/src/manager/components/preview/tools/copy.tsx b/code/core/src/manager/components/preview/tools/copy.tsx index 2fdc098cffe..adf9b54efd2 100644 --- a/code/core/src/manager/components/preview/tools/copy.tsx +++ b/code/core/src/manager/components/preview/tools/copy.tsx @@ -1,12 +1,15 @@ -import { global } from '@storybook/global'; import React from 'react'; -import copy from 'copy-to-clipboard'; -import { getStoryHref, IconButton } from '@storybook/core/components'; -import { Consumer, types } from '@storybook/core/manager-api'; -import type { Combo } from '@storybook/core/manager-api'; + +import { IconButton, getStoryHref } from '@storybook/core/components'; import type { Addon_BaseType } from '@storybook/core/types'; +import { global } from '@storybook/global'; import { LinkIcon } from '@storybook/icons'; +import { Consumer, types } from '@storybook/core/manager-api'; +import type { Combo } from '@storybook/core/manager-api'; + +import copy from 'copy-to-clipboard'; + const { PREVIEW_URL, document } = global; const copyMapper = ({ state }: Combo) => { diff --git a/code/core/src/manager/components/preview/tools/eject.tsx b/code/core/src/manager/components/preview/tools/eject.tsx index 25bf9676c8d..dda18c7db1f 100644 --- a/code/core/src/manager/components/preview/tools/eject.tsx +++ b/code/core/src/manager/components/preview/tools/eject.tsx @@ -1,11 +1,13 @@ -import { global } from '@storybook/global'; import React from 'react'; -import { getStoryHref, IconButton } from '@storybook/core/components'; -import { Consumer, types } from '@storybook/core/manager-api'; -import type { Combo } from '@storybook/core/manager-api'; + +import { IconButton, getStoryHref } from '@storybook/core/components'; import type { Addon_BaseType } from '@storybook/core/types'; +import { global } from '@storybook/global'; import { ShareAltIcon } from '@storybook/icons'; +import { Consumer, types } from '@storybook/core/manager-api'; +import type { Combo } from '@storybook/core/manager-api'; + const { PREVIEW_URL } = global; const ejectMapper = ({ state }: Combo) => { diff --git a/code/core/src/manager/components/preview/tools/menu.tsx b/code/core/src/manager/components/preview/tools/menu.tsx index 9cf7a3a1ea6..f61f8955c54 100644 --- a/code/core/src/manager/components/preview/tools/menu.tsx +++ b/code/core/src/manager/components/preview/tools/menu.tsx @@ -1,10 +1,12 @@ import React from 'react'; + import { IconButton, Separator } from '@storybook/core/components'; -import { Consumer, types } from '@storybook/core/manager-api'; -import type { Combo } from '@storybook/core/manager-api'; import type { Addon_BaseType } from '@storybook/core/types'; import { MenuIcon } from '@storybook/icons'; +import { Consumer, types } from '@storybook/core/manager-api'; +import type { Combo } from '@storybook/core/manager-api'; + const menuMapper = ({ api, state }: Combo) => ({ isVisible: api.getIsNavShown(), singleStory: state.singleStory, diff --git a/code/core/src/manager/components/preview/tools/remount.tsx b/code/core/src/manager/components/preview/tools/remount.tsx index 1d8735b7dec..2facd7a8465 100644 --- a/code/core/src/manager/components/preview/tools/remount.tsx +++ b/code/core/src/manager/components/preview/tools/remount.tsx @@ -1,13 +1,15 @@ import type { ComponentProps } from 'react'; import React, { useState } from 'react'; + import { IconButton } from '@storybook/core/components'; -import { Consumer, types } from '@storybook/core/manager-api'; -import type { Combo } from '@storybook/core/manager-api'; import { styled } from '@storybook/core/theming'; -import { FORCE_REMOUNT } from '@storybook/core/core-events'; import type { Addon_BaseType } from '@storybook/core/types'; import { SyncIcon } from '@storybook/icons'; +import { FORCE_REMOUNT } from '@storybook/core/core-events'; +import { Consumer, types } from '@storybook/core/manager-api'; +import type { Combo } from '@storybook/core/manager-api'; + interface AnimatedButtonProps { animating?: boolean; } diff --git a/code/core/src/manager/components/preview/tools/zoom.tsx b/code/core/src/manager/components/preview/tools/zoom.tsx index 9af3c17d9c3..aba59a2da27 100644 --- a/code/core/src/manager/components/preview/tools/zoom.tsx +++ b/code/core/src/manager/components/preview/tools/zoom.tsx @@ -1,11 +1,12 @@ -import type { SyntheticEvent, MouseEventHandler, PropsWithChildren } from 'react'; +import type { MouseEventHandler, PropsWithChildren, SyntheticEvent } from 'react'; import React, { Component, createContext, memo, useCallback } from 'react'; import { IconButton, Separator } from '@storybook/core/components'; import type { Addon_BaseType } from '@storybook/core/types'; -import { types } from '@storybook/core/manager-api'; import { ZoomIcon, ZoomOutIcon, ZoomResetIcon } from '@storybook/icons'; +import { types } from '@storybook/core/manager-api'; + const initialZoom = 1 as const; const Context = createContext({ value: initialZoom, set: (v: number) => {} }); diff --git a/code/core/src/manager/components/preview/utils/components.ts b/code/core/src/manager/components/preview/utils/components.ts index b9cd39b097a..e38f44164e5 100644 --- a/code/core/src/manager/components/preview/utils/components.ts +++ b/code/core/src/manager/components/preview/utils/components.ts @@ -1,5 +1,5 @@ -import { styled } from '@storybook/core/theming'; import { Link } from '@storybook/core/router'; +import { styled } from '@storybook/core/theming'; export const PreviewContainer = styled.main({ display: 'flex', diff --git a/code/core/src/manager/components/preview/utils/types.tsx b/code/core/src/manager/components/preview/utils/types.tsx index 2a1fd83c2e6..6c18cb6bddd 100644 --- a/code/core/src/manager/components/preview/utils/types.tsx +++ b/code/core/src/manager/components/preview/utils/types.tsx @@ -1,12 +1,14 @@ import type { ReactElement } from 'react'; -import type { State, API, LeafEntry } from '@storybook/core/manager-api'; + import type { + API_ViewMode, Addon_BaseType, Addon_WrapperType, - API_ViewMode, StoryId, } from '@storybook/core/types'; +import type { API, LeafEntry, State } from '@storybook/core/manager-api'; + export interface PreviewProps { api: API; viewMode: API_ViewMode; diff --git a/code/core/src/manager/components/sidebar/Brand.tsx b/code/core/src/manager/components/sidebar/Brand.tsx index f3c0a89c046..05ff72a23c0 100644 --- a/code/core/src/manager/components/sidebar/Brand.tsx +++ b/code/core/src/manager/components/sidebar/Brand.tsx @@ -1,7 +1,7 @@ import React from 'react'; -import { styled, withTheme } from '@storybook/core/theming'; import { StorybookLogo } from '@storybook/core/components'; +import { styled, withTheme } from '@storybook/core/theming'; export const StorybookLogoStyled = styled(StorybookLogo)(({ theme }) => ({ width: 'auto', diff --git a/code/core/src/manager/components/sidebar/CreateNewStoryFileModal.tsx b/code/core/src/manager/components/sidebar/CreateNewStoryFileModal.tsx index 4c45bcc5164..70ad346fbdb 100644 --- a/code/core/src/manager/components/sidebar/CreateNewStoryFileModal.tsx +++ b/code/core/src/manager/components/sidebar/CreateNewStoryFileModal.tsx @@ -1,5 +1,7 @@ import React, { useCallback, useDeferredValue, useEffect, useRef, useState } from 'react'; + import { CheckIcon } from '@storybook/icons'; + import type { ArgTypesRequestPayload, ArgTypesResponsePayload, @@ -28,8 +30,8 @@ import { addons, experimental_requestResponse, useStorybookApi } from '@storyboo import { useDebounce } from '../../hooks/useDebounce'; import type { NewStoryPayload, SearchResult } from './FileSearchList'; -import { extractSeededRequiredArgs, trySelectNewStory } from './FileSearchModal.utils'; import { FileSearchModal } from './FileSearchModal'; +import { extractSeededRequiredArgs, trySelectNewStory } from './FileSearchModal.utils'; interface CreateNewStoryFileModalProps { open: boolean; diff --git a/code/core/src/manager/components/sidebar/Explorer.stories.tsx b/code/core/src/manager/components/sidebar/Explorer.stories.tsx index 9cf8c887397..908ead2be9f 100644 --- a/code/core/src/manager/components/sidebar/Explorer.stories.tsx +++ b/code/core/src/manager/components/sidebar/Explorer.stories.tsx @@ -1,10 +1,10 @@ import React from 'react'; import { Explorer } from './Explorer'; +import { IconSymbols } from './IconSymbols'; +import * as RefStories from './Refs.stories'; import { mockDataset } from './mockdata'; import type { RefType } from './types'; -import * as RefStories from './Refs.stories'; -import { IconSymbols } from './IconSymbols'; export default { component: Explorer, diff --git a/code/core/src/manager/components/sidebar/Explorer.tsx b/code/core/src/manager/components/sidebar/Explorer.tsx index dae74f34e21..1c4a93825eb 100644 --- a/code/core/src/manager/components/sidebar/Explorer.tsx +++ b/code/core/src/manager/components/sidebar/Explorer.tsx @@ -1,11 +1,10 @@ import type { FC } from 'react'; import React, { useRef } from 'react'; +import { HighlightStyles } from './HighlightStyles'; import { Ref } from './Refs'; import type { CombinedDataset, Selection } from './types'; - import { useHighlighted } from './useHighlighted'; -import { HighlightStyles } from './HighlightStyles'; export interface ExplorerProps { isLoading: boolean; diff --git a/code/core/src/manager/components/sidebar/FileList.tsx b/code/core/src/manager/components/sidebar/FileList.tsx index 9f7cc75c290..bc2d46eee82 100644 --- a/code/core/src/manager/components/sidebar/FileList.tsx +++ b/code/core/src/manager/components/sidebar/FileList.tsx @@ -1,4 +1,5 @@ import { styled } from '@storybook/core/theming'; + import { rgba } from 'polished'; export const FileListWrapper = styled('div')(({ theme }) => ({ diff --git a/code/core/src/manager/components/sidebar/FileSearchList.stories.tsx b/code/core/src/manager/components/sidebar/FileSearchList.stories.tsx index a1f9ca9d9df..2c5ec140ee8 100644 --- a/code/core/src/manager/components/sidebar/FileSearchList.stories.tsx +++ b/code/core/src/manager/components/sidebar/FileSearchList.stories.tsx @@ -1,5 +1,5 @@ import type { Meta, StoryObj } from '@storybook/react'; -import { fn, fireEvent, findByText, expect } from '@storybook/test'; +import { expect, findByText, fireEvent, fn } from '@storybook/test'; import { FileSearchList } from './FileSearchList'; diff --git a/code/core/src/manager/components/sidebar/FileSearchList.tsx b/code/core/src/manager/components/sidebar/FileSearchList.tsx index 9ba2fd205c4..3a4eacbbf03 100644 --- a/code/core/src/manager/components/sidebar/FileSearchList.tsx +++ b/code/core/src/manager/components/sidebar/FileSearchList.tsx @@ -1,7 +1,18 @@ import React, { memo, useCallback, useMemo, useState } from 'react'; -import { ChevronDownIcon, ChevronRightIcon, ComponentIcon } from '@storybook/icons'; + +import { TooltipNote, WithTooltip } from '@storybook/core/components'; import { styled } from '@storybook/core/theming'; -import { FileSearchListLoadingSkeleton } from './FileSearchListSkeleton'; +import { ChevronDownIcon, ChevronRightIcon, ComponentIcon } from '@storybook/icons'; + +import type { + CreateNewStoryRequestPayload, + FileComponentSearchResponsePayload, +} from '@storybook/core/core-events'; + +import type { VirtualItem } from '@tanstack/react-virtual'; +import { useVirtualizer } from '@tanstack/react-virtual'; + +import { useArrowKeyNavigation } from './FIleSearchList.utils'; import { DefaultExport, FileList, @@ -21,14 +32,7 @@ import { NoResults, NoResultsDescription, } from './FileList'; -import type { VirtualItem } from '@tanstack/react-virtual'; -import { useVirtualizer } from '@tanstack/react-virtual'; -import type { - CreateNewStoryRequestPayload, - FileComponentSearchResponsePayload, -} from '@storybook/core/core-events'; -import { WithTooltip, TooltipNote } from '@storybook/core/components'; -import { useArrowKeyNavigation } from './FIleSearchList.utils'; +import { FileSearchListLoadingSkeleton } from './FileSearchListSkeleton'; export type SearchResult = NonNullable[0]; diff --git a/code/core/src/manager/components/sidebar/FileSearchListSkeleton.tsx b/code/core/src/manager/components/sidebar/FileSearchListSkeleton.tsx index ddbb757e1fe..33e6e0dd890 100644 --- a/code/core/src/manager/components/sidebar/FileSearchListSkeleton.tsx +++ b/code/core/src/manager/components/sidebar/FileSearchListSkeleton.tsx @@ -1,5 +1,7 @@ import React from 'react'; + import { styled } from '@storybook/core/theming'; + import { FileList, FileListItem } from './FileList'; const FileListItemContentWrapperSkeleton = styled('div')(({ theme }) => ({ diff --git a/code/core/src/manager/components/sidebar/FileSearchModal.stories.tsx b/code/core/src/manager/components/sidebar/FileSearchModal.stories.tsx index 8d6d2b7e9c3..a2a10005b88 100644 --- a/code/core/src/manager/components/sidebar/FileSearchModal.stories.tsx +++ b/code/core/src/manager/components/sidebar/FileSearchModal.stories.tsx @@ -1,8 +1,9 @@ -import type { Meta, StoryObj } from '@storybook/react'; -import { findByText, fireEvent, fn, expect } from '@storybook/test'; -import { WithResults } from './FileSearchList.stories'; import React, { useState } from 'react'; +import type { Meta, StoryObj } from '@storybook/react'; +import { expect, findByText, fireEvent, fn } from '@storybook/test'; + +import { WithResults } from './FileSearchList.stories'; import { FileSearchModal } from './FileSearchModal'; const meta = { diff --git a/code/core/src/manager/components/sidebar/FileSearchModal.tsx b/code/core/src/manager/components/sidebar/FileSearchModal.tsx index 9762c822263..469493744d4 100644 --- a/code/core/src/manager/components/sidebar/FileSearchModal.tsx +++ b/code/core/src/manager/components/sidebar/FileSearchModal.tsx @@ -1,11 +1,12 @@ import React, { useEffect, useState, useTransition } from 'react'; -import { Modal, Form } from '@storybook/core/components'; + +import { Form, Modal } from '@storybook/core/components'; import { styled } from '@storybook/core/theming'; import { CloseAltIcon, SearchIcon, SyncIcon } from '@storybook/icons'; +import { useMeasure } from '../../hooks/useMeasure'; import type { NewStoryPayload, SearchResult } from './FileSearchList'; import { FileSearchList } from './FileSearchList'; -import { useMeasure } from '../../hooks/useMeasure'; const MODAL_HEIGHT = 418; diff --git a/code/core/src/manager/components/sidebar/FileSearchModal.utils.test.tsx b/code/core/src/manager/components/sidebar/FileSearchModal.utils.test.tsx index d86a9c208d6..34f1f4ec8a6 100644 --- a/code/core/src/manager/components/sidebar/FileSearchModal.utils.test.tsx +++ b/code/core/src/manager/components/sidebar/FileSearchModal.utils.test.tsx @@ -1,7 +1,9 @@ import { describe, expect, it } from 'vitest'; -import { extractSeededRequiredArgs } from './FileSearchModal.utils'; + import type { ArgTypes } from '@storybook/csf'; +import { extractSeededRequiredArgs } from './FileSearchModal.utils'; + describe('FileSearchModal.utils', () => { describe('extractSeededRequiredArgs', () => { it('should extract seeded required args', () => { diff --git a/code/core/src/manager/components/sidebar/Heading.stories.tsx b/code/core/src/manager/components/sidebar/Heading.stories.tsx index 0308cae7dd5..678a6c8e2ae 100644 --- a/code/core/src/manager/components/sidebar/Heading.stories.tsx +++ b/code/core/src/manager/components/sidebar/Heading.stories.tsx @@ -1,11 +1,13 @@ // @TODO: use addon-interactions and remove the rule disable above import React from 'react'; -import type { Meta, StoryObj, StoryFn } from '@storybook/react'; + import { ThemeProvider, useTheme } from '@storybook/core/theming'; import type { Theme } from '@storybook/core/theming'; -import { action } from '@storybook/addon-actions'; +import type { Meta, StoryFn, StoryObj } from '@storybook/react'; import { screen } from '@storybook/test'; +import { action } from '@storybook/addon-actions'; + import { Heading } from './Heading'; type Story = StoryFn; diff --git a/code/core/src/manager/components/sidebar/Heading.tsx b/code/core/src/manager/components/sidebar/Heading.tsx index 962e91bbc8a..905ae1f6108 100644 --- a/code/core/src/manager/components/sidebar/Heading.tsx +++ b/code/core/src/manager/components/sidebar/Heading.tsx @@ -1,9 +1,10 @@ -import type { FC, ComponentProps } from 'react'; +import type { ComponentProps, FC } from 'react'; import React from 'react'; -import { styled } from '@storybook/core/theming'; -import { Button } from '@storybook/core/components'; +import { Button } from '@storybook/core/components'; +import { styled } from '@storybook/core/theming'; import type { Addon_SidebarTopType } from '@storybook/core/types'; + import { Brand } from './Brand'; import type { MenuList, SidebarMenuProps } from './Menu'; import { SidebarMenu } from './Menu'; diff --git a/code/core/src/manager/components/sidebar/HighlightStyles.tsx b/code/core/src/manager/components/sidebar/HighlightStyles.tsx index 0683a04c955..71f85366686 100644 --- a/code/core/src/manager/components/sidebar/HighlightStyles.tsx +++ b/code/core/src/manager/components/sidebar/HighlightStyles.tsx @@ -1,7 +1,10 @@ -import { transparentize } from 'polished'; import type { FC } from 'react'; import React from 'react'; + import { Global } from '@storybook/core/theming'; + +import { transparentize } from 'polished'; + import type { Highlight } from './types'; // @ts-expect-error (non strict) diff --git a/code/core/src/manager/components/sidebar/IconSymbols.tsx b/code/core/src/manager/components/sidebar/IconSymbols.tsx index 8dec99d6e24..20101343e7b 100644 --- a/code/core/src/manager/components/sidebar/IconSymbols.tsx +++ b/code/core/src/manager/components/sidebar/IconSymbols.tsx @@ -1,7 +1,8 @@ -import { styled } from '@storybook/core/theming'; import type { FC } from 'react'; import React from 'react'; +import { styled } from '@storybook/core/theming'; + const Svg = styled.svg` position: absolute; width: 0; diff --git a/code/core/src/manager/components/sidebar/Loader.tsx b/code/core/src/manager/components/sidebar/Loader.tsx index 254626aa0b7..96499c4b2ad 100644 --- a/code/core/src/manager/components/sidebar/Loader.tsx +++ b/code/core/src/manager/components/sidebar/Loader.tsx @@ -1,5 +1,6 @@ import type { FC } from 'react'; import React, { Fragment } from 'react'; + import { styled } from '@storybook/core/theming'; const LOADER_SEQUENCE = [0, 0, 1, 1, 2, 3, 3, 3, 1, 1, 1, 2, 2, 2, 3]; diff --git a/code/core/src/manager/components/sidebar/Menu.stories.tsx b/code/core/src/manager/components/sidebar/Menu.stories.tsx index e4873e751b0..663bd4caa3b 100644 --- a/code/core/src/manager/components/sidebar/Menu.stories.tsx +++ b/code/core/src/manager/components/sidebar/Menu.stories.tsx @@ -1,15 +1,17 @@ import type { ComponentProps } from 'react'; import React from 'react'; -import type { Meta, StoryObj } from '@storybook/react'; import { TooltipLinkList } from '@storybook/core/components'; import { styled } from '@storybook/core/theming'; -import { screen, userEvent, within, expect } from '@storybook/test'; -import type { State } from '@storybook/core/manager-api'; import { LinkIcon } from '@storybook/icons'; -import { SidebarMenu } from './Menu'; +import type { Meta, StoryObj } from '@storybook/react'; +import { expect, screen, userEvent, within } from '@storybook/test'; + +import type { State } from '@storybook/core/manager-api'; + import { useMenu } from '../../container/Menu'; import { LayoutProvider } from '../layout/LayoutProvider'; +import { SidebarMenu } from './Menu'; const fakemenu: ComponentProps['links'] = [ { title: 'has icon', icon: , id: 'icon' }, diff --git a/code/core/src/manager/components/sidebar/Menu.tsx b/code/core/src/manager/components/sidebar/Menu.tsx index 960fa8b5884..d24656aa707 100644 --- a/code/core/src/manager/components/sidebar/Menu.tsx +++ b/code/core/src/manager/components/sidebar/Menu.tsx @@ -1,11 +1,13 @@ import type { ComponentProps, FC } from 'react'; import React, { useMemo, useState } from 'react'; -import { styled } from '@storybook/core/theming'; -import { transparentize } from 'polished'; import type { Button, TooltipLinkListLink } from '@storybook/core/components'; -import { WithTooltip, TooltipLinkList, IconButton } from '@storybook/core/components'; +import { IconButton, TooltipLinkList, WithTooltip } from '@storybook/core/components'; +import { styled } from '@storybook/core/theming'; import { CloseIcon, CogIcon } from '@storybook/icons'; + +import { transparentize } from 'polished'; + import { useLayout } from '../layout/LayoutProvider'; export type MenuList = ComponentProps['links']; diff --git a/code/core/src/manager/components/sidebar/RefBlocks.tsx b/code/core/src/manager/components/sidebar/RefBlocks.tsx index d4fd979129b..16af958a8a0 100644 --- a/code/core/src/manager/components/sidebar/RefBlocks.tsx +++ b/code/core/src/manager/components/sidebar/RefBlocks.tsx @@ -1,13 +1,14 @@ -import { global } from '@storybook/global'; import type { FC } from 'react'; -import React, { useState, useCallback, Fragment } from 'react'; +import React, { Fragment, useCallback, useState } from 'react'; -import { WithTooltip, Spaced, Button, Link, ErrorFormatter } from '@storybook/core/components'; -import { logger } from '@storybook/core/client-logger'; +import { Button, ErrorFormatter, Link, Spaced, WithTooltip } from '@storybook/core/components'; import { styled } from '@storybook/core/theming'; - +import { global } from '@storybook/global'; import { ChevronDownIcon, LockIcon, SyncIcon } from '@storybook/icons'; -import { Loader, Contained } from './Loader'; + +import { logger } from '@storybook/core/client-logger'; + +import { Contained, Loader } from './Loader'; const { window: globalWindow } = global; diff --git a/code/core/src/manager/components/sidebar/RefIndicator.tsx b/code/core/src/manager/components/sidebar/RefIndicator.tsx index 6fca6687eff..7c49c95105c 100644 --- a/code/core/src/manager/components/sidebar/RefIndicator.tsx +++ b/code/core/src/manager/components/sidebar/RefIndicator.tsx @@ -1,13 +1,10 @@ -import { global } from '@storybook/global'; import type { FC, MouseEventHandler } from 'react'; -import React, { useMemo, useCallback, forwardRef } from 'react'; +import React, { forwardRef, useCallback, useMemo } from 'react'; import type { TooltipLinkListLink } from '@storybook/core/components'; -import { WithTooltip, Spaced, TooltipLinkList } from '@storybook/core/components'; +import { Spaced, TooltipLinkList, WithTooltip } from '@storybook/core/components'; import { styled, useTheme } from '@storybook/core/theming'; -import { transparentize } from 'polished'; -import { useStorybookApi } from '@storybook/core/manager-api'; - +import { global } from '@storybook/global'; import { AlertIcon, ChevronDownIcon, @@ -18,9 +15,13 @@ import { MarkupIcon, TimeIcon, } from '@storybook/icons'; -import type { RefType } from './types'; + +import { useStorybookApi } from '@storybook/core/manager-api'; + +import { transparentize } from 'polished'; import type { getStateType } from '../../utils/tree'; +import type { RefType } from './types'; const { document, window: globalWindow } = global; diff --git a/code/core/src/manager/components/sidebar/Refs.stories.tsx b/code/core/src/manager/components/sidebar/Refs.stories.tsx index 6b89f1b13a5..a26cad976dc 100644 --- a/code/core/src/manager/components/sidebar/Refs.stories.tsx +++ b/code/core/src/manager/components/sidebar/Refs.stories.tsx @@ -1,11 +1,12 @@ import React from 'react'; + import { ManagerContext } from '@storybook/core/manager-api'; -import { Ref } from './Refs'; import { standardData as standardHeaderData } from './Heading.stories'; +import { IconSymbols } from './IconSymbols'; +import { Ref } from './Refs'; import { mockDataset } from './mockdata'; import type { RefType } from './types'; -import { IconSymbols } from './IconSymbols'; export default { component: Ref, diff --git a/code/core/src/manager/components/sidebar/Refs.tsx b/code/core/src/manager/components/sidebar/Refs.tsx index 756080d63ec..7412a627e88 100644 --- a/code/core/src/manager/components/sidebar/Refs.tsx +++ b/code/core/src/manager/components/sidebar/Refs.tsx @@ -1,21 +1,20 @@ import type { FC, MutableRefObject } from 'react'; -import React, { useEffect, useMemo, useState, useRef, useCallback } from 'react'; +import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'; + +import { styled } from '@storybook/core/theming'; + import type { State } from '@storybook/core/manager-api'; import { useStorybookApi, useStorybookState } from '@storybook/core/manager-api'; -import { styled } from '@storybook/core/theming'; -import { transparentize } from 'polished'; -import { AuthBlock, ErrorBlock, LoaderBlock, EmptyBlock } from './RefBlocks'; +import { transparentize } from 'polished'; +import { getStateType } from '../../utils/tree'; +import { AuthBlock, EmptyBlock, ErrorBlock, LoaderBlock } from './RefBlocks'; import { RefIndicator } from './RefIndicator'; - -import { Tree } from './Tree'; - import { DEFAULT_REF_ID } from './Sidebar'; -import type { Highlight, RefType } from './types'; - -import { getStateType } from '../../utils/tree'; +import { Tree } from './Tree'; import { CollapseIcon } from './components/CollapseIcon'; +import type { Highlight, RefType } from './types'; export interface RefProps { isLoading: boolean; diff --git a/code/core/src/manager/components/sidebar/Search.stories.tsx b/code/core/src/manager/components/sidebar/Search.stories.tsx index 8de58e63337..5c70863735e 100644 --- a/code/core/src/manager/components/sidebar/Search.stories.tsx +++ b/code/core/src/manager/components/sidebar/Search.stories.tsx @@ -1,16 +1,19 @@ import React from 'react'; -import type { StoryFn, Meta } from '@storybook/react'; + +import type { Meta, StoryFn } from '@storybook/react'; + import type { API } from '@storybook/core/manager-api'; import { ManagerContext } from '@storybook/core/manager-api'; + import { action } from '@storybook/addon-actions'; -import { index } from './mockdata.large'; +import { IconSymbols } from './IconSymbols'; import { Search } from './Search'; import { SearchResults } from './SearchResults'; import { noResults } from './SearchResults.stories'; import { DEFAULT_REF_ID } from './Sidebar'; +import { index } from './mockdata.large'; import type { Selection } from './types'; -import { IconSymbols } from './IconSymbols'; const refId = DEFAULT_REF_ID; const data = { [refId]: { id: refId, url: '/', index, previewInitialized: true } }; diff --git a/code/core/src/manager/components/sidebar/Search.tsx b/code/core/src/manager/components/sidebar/Search.tsx index 48abe7637de..470002f85ef 100644 --- a/code/core/src/manager/components/sidebar/Search.tsx +++ b/code/core/src/manager/components/sidebar/Search.tsx @@ -1,28 +1,31 @@ -import { useStorybookApi, shortcutToHumanString } from '@storybook/core/manager-api'; +import React, { useCallback, useRef, useState } from 'react'; + +import { IconButton, TooltipNote, WithTooltip } from '@storybook/core/components'; import { styled } from '@storybook/core/theming'; +import { global } from '@storybook/global'; +import { CloseIcon, PlusIcon, SearchIcon } from '@storybook/icons'; + +import { shortcutToHumanString, useStorybookApi } from '@storybook/core/manager-api'; + import type { DownshiftState, StateChangeOptions } from 'downshift'; import Downshift from 'downshift'; import type { FuseOptions } from 'fuse.js'; import Fuse from 'fuse.js'; -import { global } from '@storybook/global'; -import React, { useRef, useState, useCallback } from 'react'; -import { CloseIcon, PlusIcon, SearchIcon } from '@storybook/icons'; -import { IconButton, TooltipNote, WithTooltip } from '@storybook/core/components'; + +import { getGroupStatus, getHighestStatus } from '../../utils/status'; +import { scrollIntoView, searchItem } from '../../utils/tree'; +import { useLayout } from '../layout/LayoutProvider'; +import { CreateNewStoryFileModal } from './CreateNewStoryFileModal'; import { DEFAULT_REF_ID } from './Sidebar'; import type { CombinedDataset, - SearchItem, - SearchResult, DownshiftItem, SearchChildrenFn, + SearchItem, + SearchResult, Selection, } from './types'; -import { isSearchResult, isExpandType } from './types'; - -import { scrollIntoView, searchItem } from '../../utils/tree'; -import { getGroupStatus, getHighestStatus } from '../../utils/status'; -import { useLayout } from '../layout/LayoutProvider'; -import { CreateNewStoryFileModal } from './CreateNewStoryFileModal'; +import { isExpandType, isSearchResult } from './types'; const { document } = global; diff --git a/code/core/src/manager/components/sidebar/SearchResults.stories.tsx b/code/core/src/manager/components/sidebar/SearchResults.stories.tsx index c45473a9c3d..114f529bcd8 100644 --- a/code/core/src/manager/components/sidebar/SearchResults.stories.tsx +++ b/code/core/src/manager/components/sidebar/SearchResults.stories.tsx @@ -1,11 +1,12 @@ import React from 'react'; + import type { StoriesHash } from '@storybook/core/manager-api'; -import { mockDataset } from './mockdata'; -import { SearchResults } from './SearchResults'; -import type { CombinedDataset, Refs, SearchItem } from './types'; import { searchItem } from '../../utils/tree'; import { IconSymbols } from './IconSymbols'; +import { SearchResults } from './SearchResults'; +import { mockDataset } from './mockdata'; +import type { CombinedDataset, Refs, SearchItem } from './types'; export default { component: SearchResults, diff --git a/code/core/src/manager/components/sidebar/SearchResults.tsx b/code/core/src/manager/components/sidebar/SearchResults.tsx index 0259bd2a92e..4c7793ef9b8 100644 --- a/code/core/src/manager/components/sidebar/SearchResults.tsx +++ b/code/core/src/manager/components/sidebar/SearchResults.tsx @@ -1,21 +1,23 @@ -import { styled } from '@storybook/core/theming'; -import { Button, IconButton } from '@storybook/core/components'; -import { global } from '@storybook/global'; import type { FC, MouseEventHandler, PropsWithChildren, ReactNode } from 'react'; import React, { useCallback, useEffect } from 'react'; -import type { ControllerStateAndHelpers } from 'downshift'; -import { useStorybookApi } from '@storybook/core/manager-api'; +import { Button, IconButton } from '@storybook/core/components'; +import { styled } from '@storybook/core/theming'; +import { global } from '@storybook/global'; +import { TrashIcon } from '@storybook/icons'; + import { PRELOAD_ENTRIES } from '@storybook/core/core-events'; +import { useStorybookApi } from '@storybook/core/manager-api'; + +import type { ControllerStateAndHelpers } from 'downshift'; import { transparentize } from 'polished'; -import { TrashIcon } from '@storybook/icons'; -import { TypeIcon } from './TreeNode'; -import type { Match, DownshiftItem, SearchResult } from './types'; -import { isExpandType } from './types'; -import { matchesKeyCode, matchesModifiers } from '../../keybinding'; +import { matchesKeyCode, matchesModifiers } from '../../keybinding'; import { statusMapping } from '../../utils/status'; import { UseSymbol } from './IconSymbols'; +import { TypeIcon } from './TreeNode'; +import type { DownshiftItem, Match, SearchResult } from './types'; +import { isExpandType } from './types'; const { document } = global; diff --git a/code/core/src/manager/components/sidebar/Sidebar.stories.tsx b/code/core/src/manager/components/sidebar/Sidebar.stories.tsx index 3179587c212..230e68ee203 100644 --- a/code/core/src/manager/components/sidebar/Sidebar.stories.tsx +++ b/code/core/src/manager/components/sidebar/Sidebar.stories.tsx @@ -1,18 +1,20 @@ import React from 'react'; -import type { IndexHash, State } from '@storybook/core/manager-api'; -import { ManagerContext, types } from '@storybook/core/manager-api'; -import type { StoryObj, Meta } from '@storybook/react'; -import { within, userEvent, expect, fn } from '@storybook/test'; -import type { Addon_SidebarTopType } from '@storybook/core/types'; import { Button, IconButton } from '@storybook/core/components'; +import type { Addon_SidebarTopType } from '@storybook/core/types'; import { FaceHappyIcon } from '@storybook/icons'; -import { Sidebar, DEFAULT_REF_ID } from './Sidebar'; +import type { Meta, StoryObj } from '@storybook/react'; +import { expect, fn, userEvent, within } from '@storybook/test'; + +import type { IndexHash, State } from '@storybook/core/manager-api'; +import { ManagerContext, types } from '@storybook/core/manager-api'; + +import { LayoutProvider } from '../layout/LayoutProvider'; import { standardData as standardHeaderData } from './Heading.stories'; +import { IconSymbols } from './IconSymbols'; +import { DEFAULT_REF_ID, Sidebar } from './Sidebar'; import { mockDataset } from './mockdata'; import type { RefType } from './types'; -import { LayoutProvider } from '../layout/LayoutProvider'; -import { IconSymbols } from './IconSymbols'; const wait = (ms: number) => new Promise((resolve) => { diff --git a/code/core/src/manager/components/sidebar/Sidebar.tsx b/code/core/src/manager/components/sidebar/Sidebar.tsx index 583c11518fc..5cc306d796f 100644 --- a/code/core/src/manager/components/sidebar/Sidebar.tsx +++ b/code/core/src/manager/components/sidebar/Sidebar.tsx @@ -1,25 +1,23 @@ import React, { useMemo } from 'react'; -import { styled } from '@storybook/core/theming'; import { ScrollArea, Spaced } from '@storybook/core/components'; -import type { State } from '@storybook/core/manager-api'; - +import { styled } from '@storybook/core/theming'; import type { + API_LoadedRefData, Addon_SidebarBottomType, Addon_SidebarTopType, - API_LoadedRefData, } from '@storybook/core/types'; -import type { HeadingProps } from './Heading'; -import { Heading } from './Heading'; -import { Explorer } from './Explorer'; +import type { State } from '@storybook/core/manager-api'; +import { MEDIA_DESKTOP_BREAKPOINT } from '../../constants'; +import { Explorer } from './Explorer'; +import type { HeadingProps } from './Heading'; +import { Heading } from './Heading'; import { Search } from './Search'; - import { SearchResults } from './SearchResults'; import type { CombinedDataset, Selection } from './types'; import { useLastViewed } from './useLastViewed'; -import { MEDIA_DESKTOP_BREAKPOINT } from '../../constants'; export const DEFAULT_REF_ID = 'storybook_internal'; diff --git a/code/core/src/manager/components/sidebar/Tree.stories.tsx b/code/core/src/manager/components/sidebar/Tree.stories.tsx index ab965dfb7d5..aed8dbd4648 100644 --- a/code/core/src/manager/components/sidebar/Tree.stories.tsx +++ b/code/core/src/manager/components/sidebar/Tree.stories.tsx @@ -1,13 +1,16 @@ // @TODO: use addon-interactions and remove the rule disable above import React, { useState } from 'react'; + +import type { Meta, StoryObj } from '@storybook/react'; +import { expect, within } from '@storybook/test'; + import type { ComponentEntry, IndexHash } from '@storybook/core/manager-api'; + import { action } from '@storybook/addon-actions'; -import type { StoryObj, Meta } from '@storybook/react'; -import { within, expect } from '@storybook/test'; +import { DEFAULT_REF_ID } from './Sidebar'; import { Tree } from './Tree'; import { index } from './mockdata.large'; -import { DEFAULT_REF_ID } from './Sidebar'; const meta = { component: Tree, diff --git a/code/core/src/manager/components/sidebar/Tree.tsx b/code/core/src/manager/components/sidebar/Tree.tsx index f9adf1e1633..41699290cac 100644 --- a/code/core/src/manager/components/sidebar/Tree.tsx +++ b/code/core/src/manager/components/sidebar/Tree.tsx @@ -1,38 +1,38 @@ +import type { MutableRefObject } from 'react'; +import React, { useCallback, useMemo, useRef } from 'react'; + +import { Button, IconButton, TooltipLinkList, WithTooltip } from '@storybook/core/components'; +import { styled } from '@storybook/core/theming'; +import { CollapseIcon as CollapseIconSvg, ExpandAltIcon } from '@storybook/icons'; + +import { PRELOAD_ENTRIES } from '@storybook/core/core-events'; import { useStorybookApi } from '@storybook/core/manager-api'; import type { - StoriesHash, - GroupEntry, + API, ComponentEntry, - StoryEntry, + GroupEntry, State, - API, + StoriesHash, + StoryEntry, } from '@storybook/core/manager-api'; -import { styled } from '@storybook/core/theming'; -import { Button, IconButton, TooltipLinkList, WithTooltip } from '@storybook/core/components'; -import { transparentize } from 'polished'; -import type { MutableRefObject } from 'react'; -import React, { useCallback, useMemo, useRef } from 'react'; -import { PRELOAD_ENTRIES } from '@storybook/core/core-events'; -import { ExpandAltIcon, CollapseIcon as CollapseIconSvg } from '@storybook/icons'; -import { ComponentNode, DocumentNode, GroupNode, RootNode, StoryNode } from './TreeNode'; - -import type { ExpandAction, ExpandedState } from './useExpanded'; - -import { useExpanded } from './useExpanded'; -import type { Highlight, Item } from './types'; +import { transparentize } from 'polished'; +import { getGroupStatus, getHighestStatus, statusMapping } from '../../utils/status'; import { - isStoryHoistable, createId, getAncestorIds, getDescendantIds, getLink, + isStoryHoistable, } from '../../utils/tree'; -import { statusMapping, getHighestStatus, getGroupStatus } from '../../utils/status'; import { useLayout } from '../layout/LayoutProvider'; import { IconSymbols } from './IconSymbols'; +import { ComponentNode, DocumentNode, GroupNode, RootNode, StoryNode } from './TreeNode'; import { CollapseIcon } from './components/CollapseIcon'; +import type { Highlight, Item } from './types'; +import type { ExpandAction, ExpandedState } from './useExpanded'; +import { useExpanded } from './useExpanded'; const Container = styled.div<{ hasOrphans: boolean }>((props) => ({ marginTop: props.hasOrphans ? 20 : 0, diff --git a/code/core/src/manager/components/sidebar/TreeNode.stories.tsx b/code/core/src/manager/components/sidebar/TreeNode.stories.tsx index b78a9b70477..d35daf9060f 100644 --- a/code/core/src/manager/components/sidebar/TreeNode.stories.tsx +++ b/code/core/src/manager/components/sidebar/TreeNode.stories.tsx @@ -1,9 +1,9 @@ import React from 'react'; + import { HighlightStyles } from './HighlightStyles'; +import { IconSymbols } from './IconSymbols'; import { LeafNodeStyleWrapper } from './Tree'; - import { ComponentNode, DocumentNode, GroupNode, StoryNode } from './TreeNode'; -import { IconSymbols } from './IconSymbols'; export default { title: 'Sidebar/TreeNode', diff --git a/code/core/src/manager/components/sidebar/TreeNode.tsx b/code/core/src/manager/components/sidebar/TreeNode.tsx index 7c42a42a8f3..59dd02f04b1 100644 --- a/code/core/src/manager/components/sidebar/TreeNode.tsx +++ b/code/core/src/manager/components/sidebar/TreeNode.tsx @@ -1,7 +1,10 @@ +import type { ComponentProps, FC } from 'react'; +import React from 'react'; + import { styled } from '@storybook/core/theming'; + import { transparentize } from 'polished'; -import type { FC, ComponentProps } from 'react'; -import React from 'react'; + import { UseSymbol } from './IconSymbols'; import { CollapseIcon } from './components/CollapseIcon'; diff --git a/code/core/src/manager/components/sidebar/__tests__/Sidebar.test.tsx b/code/core/src/manager/components/sidebar/__tests__/Sidebar.test.tsx index a24f59333ef..adc05cb07a5 100644 --- a/code/core/src/manager/components/sidebar/__tests__/Sidebar.test.tsx +++ b/code/core/src/manager/components/sidebar/__tests__/Sidebar.test.tsx @@ -1,14 +1,16 @@ // @vitest-environment happy-dom +import { cleanup, fireEvent, render, screen } from '@testing-library/react'; +import type { RenderResult } from '@testing-library/react'; +import { afterEach, describe, expect, test } from 'vitest'; -import { afterEach, describe, test, expect } from 'vitest'; import React from 'react'; -import { render, screen, fireEvent, cleanup } from '@testing-library/react'; -import { ThemeProvider, ensure, themes } from '@storybook/core/theming'; -import type { HashEntry, Refs } from '@storybook/core/manager-api'; +import { ThemeProvider, ensure, themes } from '@storybook/core/theming'; import type { Theme } from '@storybook/core/theming'; -import type { RenderResult } from '@testing-library/react'; import type { API_IndexHash } from '@storybook/core/types'; + +import type { HashEntry, Refs } from '@storybook/core/manager-api'; + import { Sidebar } from '../Sidebar'; import type { SidebarProps } from '../Sidebar'; diff --git a/code/core/src/manager/components/sidebar/components/CollapseIcon.tsx b/code/core/src/manager/components/sidebar/components/CollapseIcon.tsx index fd3bd67752a..f4de9e9cd46 100644 --- a/code/core/src/manager/components/sidebar/components/CollapseIcon.tsx +++ b/code/core/src/manager/components/sidebar/components/CollapseIcon.tsx @@ -1,6 +1,8 @@ -import { styled } from '@storybook/core/theming'; import type { FC } from 'react'; import React from 'react'; + +import { styled } from '@storybook/core/theming'; + import { transparentize } from 'polished'; interface CollapseIconProps { diff --git a/code/core/src/manager/components/sidebar/mockdata.large.ts b/code/core/src/manager/components/sidebar/mockdata.large.ts index b4c2a0b9939..6fb9d233379 100644 --- a/code/core/src/manager/components/sidebar/mockdata.large.ts +++ b/code/core/src/manager/components/sidebar/mockdata.large.ts @@ -10,7 +10,6 @@ * return acc; * }, {}), null, 2) */ - import type { Dataset } from './types'; // @ts-expect-error (TODO) diff --git a/code/core/src/manager/components/sidebar/types.ts b/code/core/src/manager/components/sidebar/types.ts index b9eac9bf806..abf0c686b37 100644 --- a/code/core/src/manager/components/sidebar/types.ts +++ b/code/core/src/manager/components/sidebar/types.ts @@ -1,7 +1,9 @@ -import type { StoriesHash, State } from '@storybook/core/manager-api'; -import type { ControllerStateAndHelpers } from 'downshift'; import type { API_StatusState, API_StatusValue } from '@storybook/core/types'; +import type { State, StoriesHash } from '@storybook/core/manager-api'; + +import type { ControllerStateAndHelpers } from 'downshift'; + export type Refs = State['refs']; export type RefType = Refs[keyof Refs] & { status?: API_StatusState }; export type Item = StoriesHash[keyof StoriesHash]; diff --git a/code/core/src/manager/components/sidebar/useExpanded.ts b/code/core/src/manager/components/sidebar/useExpanded.ts index 3af0ed908b8..dcf49137c96 100644 --- a/code/core/src/manager/components/sidebar/useExpanded.ts +++ b/code/core/src/manager/components/sidebar/useExpanded.ts @@ -1,15 +1,18 @@ +import type { Dispatch, MutableRefObject, Reducer } from 'react'; +import { useCallback, useEffect, useReducer } from 'react'; + +import { global } from '@storybook/global'; + +import { STORIES_COLLAPSE_ALL, STORIES_EXPAND_ALL } from '@storybook/core/core-events'; import type { StoriesHash } from '@storybook/core/manager-api'; import { useStorybookApi } from '@storybook/core/manager-api'; -import { STORIES_COLLAPSE_ALL, STORIES_EXPAND_ALL } from '@storybook/core/core-events'; -import { global } from '@storybook/global'; + import throttle from 'lodash/throttle.js'; -import type { Dispatch, MutableRefObject, Reducer } from 'react'; -import { useCallback, useEffect, useReducer } from 'react'; + import { matchesKeyCode, matchesModifiers } from '../../keybinding'; +import { getAncestorIds, getDescendantIds, isAncestor, scrollIntoView } from '../../utils/tree'; import type { Highlight } from './types'; -import { isAncestor, getAncestorIds, getDescendantIds, scrollIntoView } from '../../utils/tree'; - const { document } = global; export type ExpandedState = Record; diff --git a/code/core/src/manager/components/sidebar/useHighlighted.ts b/code/core/src/manager/components/sidebar/useHighlighted.ts index 5f9df6c2297..1ca9ed1f6b3 100644 --- a/code/core/src/manager/components/sidebar/useHighlighted.ts +++ b/code/core/src/manager/components/sidebar/useHighlighted.ts @@ -1,13 +1,14 @@ -import { global } from '@storybook/global'; import type { Dispatch, MutableRefObject, SetStateAction } from 'react'; import { useCallback, useEffect, useRef, useState } from 'react'; -import { useStorybookApi } from '@storybook/core/manager-api'; -import { PRELOAD_ENTRIES } from '@storybook/core/core-events'; -import { matchesKeyCode, matchesModifiers } from '../../keybinding'; -import type { CombinedDataset, Highlight, Selection } from './types'; +import { global } from '@storybook/global'; +import { PRELOAD_ENTRIES } from '@storybook/core/core-events'; +import { useStorybookApi } from '@storybook/core/manager-api'; + +import { matchesKeyCode, matchesModifiers } from '../../keybinding'; import { cycle, isAncestor, scrollIntoView } from '../../utils/tree'; +import type { CombinedDataset, Highlight, Selection } from './types'; const { document, window: globalWindow } = global; diff --git a/code/core/src/manager/components/sidebar/useLastViewed.ts b/code/core/src/manager/components/sidebar/useLastViewed.ts index 1bc8d679883..0b2f6eddc76 100644 --- a/code/core/src/manager/components/sidebar/useLastViewed.ts +++ b/code/core/src/manager/components/sidebar/useLastViewed.ts @@ -1,5 +1,6 @@ -import debounce from 'lodash/debounce.js'; import { useCallback, useEffect, useMemo, useRef } from 'react'; + +import debounce from 'lodash/debounce.js'; import store from 'store2'; import type { Selection, StoryRef } from './types'; diff --git a/code/core/src/manager/components/upgrade/UpgradeBlock.stories.tsx b/code/core/src/manager/components/upgrade/UpgradeBlock.stories.tsx index 35c180911b2..1ed8698aad0 100644 --- a/code/core/src/manager/components/upgrade/UpgradeBlock.stories.tsx +++ b/code/core/src/manager/components/upgrade/UpgradeBlock.stories.tsx @@ -1,8 +1,11 @@ +import React from 'react'; + import type { Meta, StoryObj } from '@storybook/react'; +import { fn } from '@storybook/test'; + import { ManagerContext } from '@storybook/core/manager-api'; -import React from 'react'; + import { UpgradeBlock } from './UpgradeBlock'; -import { fn } from '@storybook/test'; const meta = { component: UpgradeBlock, diff --git a/code/core/src/manager/components/upgrade/UpgradeBlock.tsx b/code/core/src/manager/components/upgrade/UpgradeBlock.tsx index 023dc81ced0..207b9fcef6b 100644 --- a/code/core/src/manager/components/upgrade/UpgradeBlock.tsx +++ b/code/core/src/manager/components/upgrade/UpgradeBlock.tsx @@ -1,8 +1,11 @@ import type { FC } from 'react'; import React, { useState } from 'react'; + +import { Link } from '@storybook/core/components'; import { styled } from '@storybook/core/theming'; + import { useStorybookApi } from '@storybook/core/manager-api'; -import { Link } from '@storybook/core/components'; + import { MEDIA_DESKTOP_BREAKPOINT } from '../../constants'; interface UpgradeBlockProps { diff --git a/code/core/src/manager/container/Menu.stories.tsx b/code/core/src/manager/container/Menu.stories.tsx index 401a39e7e54..0a2fd0c6b4d 100644 --- a/code/core/src/manager/container/Menu.stories.tsx +++ b/code/core/src/manager/container/Menu.stories.tsx @@ -1,8 +1,11 @@ import type { FC, MouseEvent, PropsWithChildren, ReactElement } from 'react'; import React, { Children, cloneElement } from 'react'; -import { action } from '@storybook/addon-actions'; -import type { Meta, StoryObj } from '@storybook/react'; + import { TooltipLinkList, WithTooltip } from '@storybook/core/components'; +import type { Meta, StoryObj } from '@storybook/react'; + +import { action } from '@storybook/addon-actions'; + import { Shortcut } from './Menu'; const onLinkClick = action('onLinkClick'); diff --git a/code/core/src/manager/container/Menu.tsx b/code/core/src/manager/container/Menu.tsx index ce1cce43422..b2b92ef17ad 100644 --- a/code/core/src/manager/container/Menu.tsx +++ b/code/core/src/manager/container/Menu.tsx @@ -2,11 +2,12 @@ import type { FC } from 'react'; import React, { useCallback, useMemo } from 'react'; import { Badge } from '@storybook/core/components'; -import type { API, State } from '@storybook/core/manager-api'; -import { shortcutToHumanString } from '@storybook/core/manager-api'; import { styled, useTheme } from '@storybook/core/theming'; import { CheckIcon, InfoIcon, ShareAltIcon, WandIcon } from '@storybook/icons'; + import { STORIES_COLLAPSE_ALL } from '@storybook/core/core-events'; +import type { API, State } from '@storybook/core/manager-api'; +import { shortcutToHumanString } from '@storybook/core/manager-api'; const focusableUIElements = { storySearchField: 'storybook-explorer-searchfield', diff --git a/code/core/src/manager/container/Panel.tsx b/code/core/src/manager/container/Panel.tsx index c8accbb6c4e..c81e489d8f6 100644 --- a/code/core/src/manager/container/Panel.tsx +++ b/code/core/src/manager/container/Panel.tsx @@ -1,9 +1,12 @@ import type { FC } from 'react'; import React from 'react'; -import memoize from 'memoizerific'; + +import { Addon_TypesEnum } from '@storybook/core/types'; + import { Consumer } from '@storybook/core/manager-api'; import type { API, Combo } from '@storybook/core/manager-api'; -import { Addon_TypesEnum } from '@storybook/core/types'; + +import memoize from 'memoizerific'; import { AddonPanel } from '../components/panel/Panel'; diff --git a/code/core/src/manager/container/Preview.tsx b/code/core/src/manager/container/Preview.tsx index 9d824b408cc..fabda783bf6 100644 --- a/code/core/src/manager/container/Preview.tsx +++ b/code/core/src/manager/container/Preview.tsx @@ -1,24 +1,25 @@ -import { global } from '@storybook/global'; -import type { Addon_BaseType, Addon_Collection, Addon_WrapperType } from '@storybook/core/types'; -import { Addon_TypesEnum } from '@storybook/core/types'; import type { ComponentProps } from 'react'; import React from 'react'; -import memoizerific from 'memoizerific'; +import type { Addon_BaseType, Addon_Collection, Addon_WrapperType } from '@storybook/core/types'; +import { Addon_TypesEnum } from '@storybook/core/types'; +import { global } from '@storybook/global'; import type { State, StoriesHash } from '@storybook/core/manager-api'; import { Consumer } from '@storybook/core/manager-api'; +import memoizerific from 'memoizerific'; + import { Preview, createCanvasTab, filterTabs } from '../components/preview/Preview'; -import { defaultWrappers } from '../components/preview/Wrappers'; import { filterToolsSide, fullScreenTool } from '../components/preview/Toolbar'; +import { defaultWrappers } from '../components/preview/Wrappers'; +import { addonsTool } from '../components/preview/tools/addons'; +import { copyTool } from '../components/preview/tools/copy'; +import { ejectTool } from '../components/preview/tools/eject'; import { menuTool } from '../components/preview/tools/menu'; import { remountTool } from '../components/preview/tools/remount'; import { zoomTool } from '../components/preview/tools/zoom'; import type { PreviewProps } from '../components/preview/utils/types'; -import { addonsTool } from '../components/preview/tools/addons'; -import { copyTool } from '../components/preview/tools/copy'; -import { ejectTool } from '../components/preview/tools/eject'; const defaultTabs = [createCanvasTab()]; const defaultTools = [menuTool, remountTool, zoomTool]; diff --git a/code/core/src/manager/container/Sidebar.tsx b/code/core/src/manager/container/Sidebar.tsx index 058361de9af..61f0ff57c76 100755 --- a/code/core/src/manager/container/Sidebar.tsx +++ b/code/core/src/manager/container/Sidebar.tsx @@ -1,8 +1,9 @@ import React, { useMemo } from 'react'; +import { Addon_TypesEnum } from '@storybook/core/types'; + import type { Combo, StoriesHash } from '@storybook/core/manager-api'; import { Consumer } from '@storybook/core/manager-api'; -import { Addon_TypesEnum } from '@storybook/core/types'; import type { SidebarProps as SidebarComponentProps } from '../components/sidebar/Sidebar'; import { Sidebar as SidebarComponent } from '../components/sidebar/Sidebar'; diff --git a/code/core/src/manager/globals-runtime.ts b/code/core/src/manager/globals-runtime.ts index 25ce25d7581..7e4c07eccb2 100644 --- a/code/core/src/manager/globals-runtime.ts +++ b/code/core/src/manager/globals-runtime.ts @@ -2,8 +2,8 @@ import { global } from '@storybook/global'; import { TELEMETRY_ERROR } from '@storybook/core/core-events'; -import { globalsNameValueMap } from './globals/runtime'; import { globalPackages, globalsNameReferenceMap } from './globals/globals'; +import { globalsNameValueMap } from './globals/runtime'; import { prepareForTelemetry, shouldSkipError } from './utils/prepareForTelemetry'; // Apply all the globals diff --git a/code/core/src/manager/globals/globals-module-info.ts b/code/core/src/manager/globals/globals-module-info.ts index 193ee13d615..ff5e8f0b9ec 100644 --- a/code/core/src/manager/globals/globals-module-info.ts +++ b/code/core/src/manager/globals/globals-module-info.ts @@ -1,4 +1,5 @@ import type { ModuleInfo } from '@fal-works/esbuild-plugin-global-externals'; + import Exports from './exports'; import { globalPackages, globalsNameReferenceMap } from './globals'; diff --git a/code/core/src/manager/globals/runtime.ts b/code/core/src/manager/globals/runtime.ts index fcca6ea55a5..50fa1568e85 100644 --- a/code/core/src/manager/globals/runtime.ts +++ b/code/core/src/manager/globals/runtime.ts @@ -1,19 +1,20 @@ import * as REACT from 'react'; -import * as REACT_DOM from 'react-dom'; -import * as REACT_DOM_CLIENT from 'react-dom/client'; - -import * as COMPONENTS from '@storybook/core/components'; -import * as ICONS from '@storybook/icons'; -import * as MANAGER_API from '@storybook/core/manager-api'; import * as CHANNELS from '@storybook/core/channels'; -import * as EVENTS from '@storybook/core/core-events'; -import * as EVENTS_MANAGER_ERRORS from '@storybook/core/manager-errors'; +import * as COMPONENTS from '@storybook/core/components'; import * as ROUTER from '@storybook/core/router'; import * as THEMING from '@storybook/core/theming'; import * as THEMINGCREATE from '@storybook/core/theming/create'; import * as TYPES from '@storybook/core/types'; +import * as ICONS from '@storybook/icons'; + import * as CLIENT_LOGGER from '@storybook/core/client-logger'; +import * as EVENTS from '@storybook/core/core-events'; +import * as MANAGER_API from '@storybook/core/manager-api'; +import * as EVENTS_MANAGER_ERRORS from '@storybook/core/manager-errors'; + +import * as REACT_DOM from 'react-dom'; +import * as REACT_DOM_CLIENT from 'react-dom/client'; import type { globalsNameReferenceMap } from './globals'; diff --git a/code/core/src/manager/index.tsx b/code/core/src/manager/index.tsx index 4d01da8e825..fcdca0fa234 100644 --- a/code/core/src/manager/index.tsx +++ b/code/core/src/manager/index.tsx @@ -1,23 +1,23 @@ -import { global } from '@storybook/global'; import type { ComponentProps, FC } from 'react'; -import { createRoot } from 'react-dom/client'; import React, { useCallback, useMemo } from 'react'; import { Location, LocationProvider, useNavigate } from '@storybook/core/router'; +import { ThemeProvider, ensure as ensureTheme } from '@storybook/core/theming'; +import type { Addon_PageType } from '@storybook/core/types'; +import { global } from '@storybook/global'; + import { Provider as ManagerProvider, types } from '@storybook/core/manager-api'; import type { Combo } from '@storybook/core/manager-api'; -import { ThemeProvider, ensure as ensureTheme } from '@storybook/core/theming'; import { ProviderDoesNotExtendBaseProviderError } from '@storybook/core/manager-errors'; +import { createRoot } from 'react-dom/client'; import { HelmetProvider } from 'react-helmet-async'; -import type { Addon_PageType } from '@storybook/core/types'; import { App } from './App'; - +import type { Layout } from './components/layout/Layout'; +import { LayoutProvider } from './components/layout/LayoutProvider'; import Provider from './provider'; import { settingsPageAddon } from './settings/index'; -import { LayoutProvider } from './components/layout/LayoutProvider'; -import type { Layout } from './components/layout/Layout'; // @ts-expect-error (Converted from ts-ignore) ThemeProvider.displayName = 'ThemeProvider'; diff --git a/code/core/src/manager/runtime.ts b/code/core/src/manager/runtime.ts index f73515f425d..2ae3fede77c 100644 --- a/code/core/src/manager/runtime.ts +++ b/code/core/src/manager/runtime.ts @@ -1,13 +1,14 @@ +import type { Channel } from '@storybook/core/channels'; +import { createBrowserChannel } from '@storybook/core/channels'; +import type { Addon_Config, Addon_Types } from '@storybook/core/types'; import { global } from '@storybook/global'; -import type { Channel } from '@storybook/core/channels'; +import { CHANNEL_CREATED } from '@storybook/core/core-events'; import type { AddonStore } from '@storybook/core/manager-api'; import { addons } from '@storybook/core/manager-api'; -import type { Addon_Types, Addon_Config } from '@storybook/core/types'; -import { createBrowserChannel } from '@storybook/core/channels'; -import { CHANNEL_CREATED } from '@storybook/core/core-events'; -import Provider from './provider'; + import { renderStorybookUI } from './index'; +import Provider from './provider'; class ReactProvider extends Provider { addons: AddonStore; diff --git a/code/core/src/manager/settings/About.tsx b/code/core/src/manager/settings/About.tsx index d6b3aae8aa6..4f9001fb7c3 100644 --- a/code/core/src/manager/settings/About.tsx +++ b/code/core/src/manager/settings/About.tsx @@ -1,9 +1,10 @@ import type { FC } from 'react'; import React from 'react'; -import { styled } from '@storybook/core/theming'; import { Button, Link, StorybookLogo } from '@storybook/core/components'; +import { styled } from '@storybook/core/theming'; import { DocumentIcon, GithubIcon } from '@storybook/icons'; + import { UpgradeBlock } from '../components/upgrade/UpgradeBlock'; const Container = styled.div({ diff --git a/code/core/src/manager/settings/SettingsFooter.stories.tsx b/code/core/src/manager/settings/SettingsFooter.stories.tsx index 5bd0bb8f3b8..fb138e96b68 100644 --- a/code/core/src/manager/settings/SettingsFooter.stories.tsx +++ b/code/core/src/manager/settings/SettingsFooter.stories.tsx @@ -1,6 +1,7 @@ import React from 'react'; import type { Decorator } from '@storybook/react'; + import SettingsFooter from './SettingsFooter'; export default { diff --git a/code/core/src/manager/settings/SettingsFooter.tsx b/code/core/src/manager/settings/SettingsFooter.tsx index 8bc273f8e95..308e9e2dd2f 100644 --- a/code/core/src/manager/settings/SettingsFooter.tsx +++ b/code/core/src/manager/settings/SettingsFooter.tsx @@ -1,8 +1,8 @@ import type { FC } from 'react'; import React from 'react'; -import { styled } from '@storybook/core/theming'; import { Link } from '@storybook/core/components'; +import { styled } from '@storybook/core/theming'; const Footer = styled.div(({ theme }) => ({ display: 'flex', diff --git a/code/core/src/manager/settings/about.stories.tsx b/code/core/src/manager/settings/about.stories.tsx index 45891544227..d63d246d447 100644 --- a/code/core/src/manager/settings/about.stories.tsx +++ b/code/core/src/manager/settings/about.stories.tsx @@ -1,9 +1,11 @@ -import type { Meta, StoryObj } from '@storybook/react'; import React from 'react'; -import { AboutScreen } from './About'; -import UpgradeBlockStoriesMeta from '../components/upgrade/UpgradeBlock.stories'; + +import type { Meta, StoryObj } from '@storybook/react'; import { fn } from '@storybook/test'; +import UpgradeBlockStoriesMeta from '../components/upgrade/UpgradeBlock.stories'; +import { AboutScreen } from './About'; + const meta = { component: AboutScreen, title: 'Settings/AboutScreen', diff --git a/code/core/src/manager/settings/index.tsx b/code/core/src/manager/settings/index.tsx index 0bd3c661f60..5ae202f65ea 100644 --- a/code/core/src/manager/settings/index.tsx +++ b/code/core/src/manager/settings/index.tsx @@ -1,17 +1,19 @@ -import { useStorybookApi, useStorybookState, types } from '@storybook/core/manager-api'; -import { IconButton, TabBar, TabButton, ScrollArea } from '@storybook/core/components'; -import { Location, Route } from '@storybook/core/router'; -import { styled } from '@storybook/core/theming'; -import { global } from '@storybook/global'; import type { FC, SyntheticEvent } from 'react'; import React, { Fragment } from 'react'; +import { IconButton, ScrollArea, TabBar, TabButton } from '@storybook/core/components'; +import { Location, Route } from '@storybook/core/router'; +import { styled } from '@storybook/core/theming'; import type { Addon_PageType } from '@storybook/core/types'; +import { global } from '@storybook/global'; import { CloseIcon } from '@storybook/icons'; + +import { types, useStorybookApi, useStorybookState } from '@storybook/core/manager-api'; + +import { matchesKeyCode, matchesModifiers } from '../keybinding'; import { AboutPage } from './AboutPage'; import { ShortcutsPage } from './ShortcutsPage'; import { WhatsNewPage } from './whats_new_page'; -import { matchesModifiers, matchesKeyCode } from '../keybinding'; const { document } = global; diff --git a/code/core/src/manager/settings/shortcuts.stories.tsx b/code/core/src/manager/settings/shortcuts.stories.tsx index 555f5b6b0b6..67f3b97a149 100644 --- a/code/core/src/manager/settings/shortcuts.stories.tsx +++ b/code/core/src/manager/settings/shortcuts.stories.tsx @@ -1,9 +1,11 @@ import React from 'react'; -import { actions as makeActions } from '@storybook/addon-actions'; import type { Decorator } from '@storybook/react'; -import { ShortcutsScreen } from './shortcuts'; + +import { actions as makeActions } from '@storybook/addon-actions'; + import { defaultShortcuts } from './defaultShortcuts'; +import { ShortcutsScreen } from './shortcuts'; const actions = makeActions( 'setShortcut', diff --git a/code/core/src/manager/settings/shortcuts.tsx b/code/core/src/manager/settings/shortcuts.tsx index 74d716faf4a..9befc68ea3a 100644 --- a/code/core/src/manager/settings/shortcuts.tsx +++ b/code/core/src/manager/settings/shortcuts.tsx @@ -1,15 +1,17 @@ import type { ComponentProps, FC } from 'react'; import React, { Component } from 'react'; -import { styled, keyframes } from '@storybook/core/theming'; + +import { Button, Form } from '@storybook/core/components'; +import { keyframes, styled } from '@storybook/core/theming'; +import { CheckIcon } from '@storybook/icons'; import { eventToShortcut, - shortcutToHumanString, shortcutMatchesShortcut, + shortcutToHumanString, } from '@storybook/core/manager-api'; -import { Button, Form } from '@storybook/core/components'; + import SettingsFooter from './SettingsFooter'; -import { CheckIcon } from '@storybook/icons'; const Header = styled.header(({ theme }) => ({ marginBottom: 20, diff --git a/code/core/src/manager/settings/whats_new.tsx b/code/core/src/manager/settings/whats_new.tsx index cbf00ce7817..aa483334e0c 100644 --- a/code/core/src/manager/settings/whats_new.tsx +++ b/code/core/src/manager/settings/whats_new.tsx @@ -1,10 +1,12 @@ import type { ComponentProps, FC } from 'react'; import React, { Fragment, useEffect, useState } from 'react'; -import { styled, useTheme } from '@storybook/core/theming'; + import { Button, Loader } from '@storybook/core/components'; -import { useStorybookApi, useStorybookState } from '@storybook/core/manager-api'; +import { styled, useTheme } from '@storybook/core/theming'; import { global } from '@storybook/global'; -import { EyeCloseIcon, EyeIcon, HeartIcon, AlertIcon as AlertIconSvg } from '@storybook/icons'; +import { AlertIcon as AlertIconSvg, EyeCloseIcon, EyeIcon, HeartIcon } from '@storybook/icons'; + +import { useStorybookApi, useStorybookState } from '@storybook/core/manager-api'; const Centered = styled.div({ top: '50%', diff --git a/code/core/src/manager/settings/whats_new_footer.stories.tsx b/code/core/src/manager/settings/whats_new_footer.stories.tsx index 8815eb0ec1c..9e0a88c0456 100644 --- a/code/core/src/manager/settings/whats_new_footer.stories.tsx +++ b/code/core/src/manager/settings/whats_new_footer.stories.tsx @@ -1,4 +1,5 @@ import type { Meta, StoryObj } from '@storybook/react'; + import { WhatsNewFooter } from './whats_new'; const meta = { diff --git a/code/core/src/manager/utils/prepareForTelemetry.ts b/code/core/src/manager/utils/prepareForTelemetry.ts index 959251c9260..ccbb8bf236b 100644 --- a/code/core/src/manager/utils/prepareForTelemetry.ts +++ b/code/core/src/manager/utils/prepareForTelemetry.ts @@ -1,6 +1,8 @@ /* eslint-disable local-rules/no-uncategorized-errors */ -import { UncaughtManagerError } from '@storybook/core/manager-errors'; import { global } from '@storybook/global'; + +import { UncaughtManagerError } from '@storybook/core/manager-errors'; + import type { BrowserInfo } from 'browser-dtector'; import BrowserDetector from 'browser-dtector'; diff --git a/code/core/src/manager/utils/status.test.ts b/code/core/src/manager/utils/status.test.ts index c45b14063db..5bedc3571e8 100644 --- a/code/core/src/manager/utils/status.test.ts +++ b/code/core/src/manager/utils/status.test.ts @@ -1,8 +1,8 @@ // @vitest-environment happy-dom +import { describe, expect, it } from 'vitest'; -import { describe, it, expect } from 'vitest'; -import { getHighestStatus, getGroupStatus } from './status'; import { mockDataset } from '../components/sidebar/mockdata'; +import { getGroupStatus, getHighestStatus } from './status'; describe('getHighestStatus', () => { it('default value', () => { diff --git a/code/core/src/manager/utils/status.tsx b/code/core/src/manager/utils/status.tsx index 05092844bdc..3474ba64b39 100644 --- a/code/core/src/manager/utils/status.tsx +++ b/code/core/src/manager/utils/status.tsx @@ -1,11 +1,11 @@ import React from 'react'; import type { ReactElement } from 'react'; -import type { API_HashEntry, API_StatusState, API_StatusValue } from '@storybook/core/types'; import { styled } from '@storybook/core/theming'; +import type { API_HashEntry, API_StatusState, API_StatusValue } from '@storybook/core/types'; +import { CircleIcon } from '@storybook/icons'; import { getDescendantIds } from './tree'; -import { CircleIcon } from '@storybook/icons'; const SmallIcons = styled(CircleIcon)({ // specificity hack diff --git a/code/core/src/manager/utils/tree.test.js b/code/core/src/manager/utils/tree.test.js index 57761f7c18a..061e7dbc8e2 100644 --- a/code/core/src/manager/utils/tree.test.js +++ b/code/core/src/manager/utils/tree.test.js @@ -1,8 +1,7 @@ // @vitest-environment happy-dom +import { describe, expect, it } from 'vitest'; -import { describe, it, expect } from 'vitest'; import { mockDataset, mockExpanded, mockSelected } from '../components/sidebar/mockdata'; - import * as utils from './tree'; const noRoot = { diff --git a/code/core/src/manager/utils/tree.ts b/code/core/src/manager/utils/tree.ts index 8b6190bd3e8..cb0bd8cb67c 100644 --- a/code/core/src/manager/utils/tree.ts +++ b/code/core/src/manager/utils/tree.ts @@ -1,10 +1,13 @@ -import memoize from 'memoizerific'; -import { global } from '@storybook/global'; import type { SyntheticEvent } from 'react'; + +import { global } from '@storybook/global'; + import type { HashEntry, IndexHash } from '@storybook/core/manager-api'; +import memoize from 'memoizerific'; + import { DEFAULT_REF_ID } from '../components/sidebar/Sidebar'; -import type { Item, RefType, Dataset, SearchItem } from '../components/sidebar/types'; +import type { Dataset, Item, RefType, SearchItem } from '../components/sidebar/types'; const { document, window: globalWindow } = global; diff --git a/code/core/src/node-logger/index.test.ts b/code/core/src/node-logger/index.test.ts index 50cce3a88b7..c7948363545 100644 --- a/code/core/src/node-logger/index.test.ts +++ b/code/core/src/node-logger/index.test.ts @@ -1,5 +1,7 @@ -import { describe, it, expect, vi } from 'vitest'; +import { describe, expect, it, vi } from 'vitest'; + import npmlog from 'npmlog'; + import { logger } from '.'; globalThis.console = { log: vi.fn() } as any; diff --git a/code/core/src/node-logger/index.ts b/code/core/src/node-logger/index.ts index 61234e4b8fc..38df1d3df5d 100644 --- a/code/core/src/node-logger/index.ts +++ b/code/core/src/node-logger/index.ts @@ -1,8 +1,7 @@ /// - +import chalk from 'chalk'; import npmLog from 'npmlog'; import prettyTime from 'pretty-hrtime'; -import chalk from 'chalk'; // The default is stderr, which can cause some tools (like rush.js) to think // there are issues with the build: https://github.com/storybookjs/storybook/issues/14621 diff --git a/code/core/src/preview-api/Errors.stories.tsx b/code/core/src/preview-api/Errors.stories.tsx index 231905e9bca..2782999de39 100644 --- a/code/core/src/preview-api/Errors.stories.tsx +++ b/code/core/src/preview-api/Errors.stories.tsx @@ -1,4 +1,5 @@ import React from 'react'; + import AnsiToHtml from 'ansi-to-html'; import { dedent } from 'ts-dedent'; diff --git a/code/core/src/preview-api/README-store.md b/code/core/src/preview-api/README-store.md index 8e261bf30e6..cea82a90564 100644 --- a/code/core/src/preview-api/README-store.md +++ b/code/core/src/preview-api/README-store.md @@ -78,7 +78,9 @@ Note that arg values are passed directly to a story -- you should only store the Both `@storybook/preview-api` and `@storybook/manager-api` export a `useArgs()` hook that you can use to access args in decorators or addon panels. The API is as follows: ```js -import { useArgs } from '@storybook/preview-api'; // or '@storybook/manager-api' +import { useArgs } from '@storybook/preview-api'; + +// or '@storybook/manager-api' // `args` is the args of the currently rendered story // `updateArgs` will update its args. You can pass a subset of the args; other args will not be changed. @@ -110,7 +112,9 @@ To set initial values of globals, `export const globals = {...}` from `preview.j Similar to args, globals are synchronized to the manager and can be accessed via the `useGlobals` hook. ```js -import { useGlobals } from '@storybook/preview-api'; // or '@storybook/manager-api' +import { useGlobals } from '@storybook/preview-api'; + +// or '@storybook/manager-api' const [globals, updateGlobals] = useGlobals(); ``` diff --git a/code/core/src/preview-api/modules/addons/hooks.test.js b/code/core/src/preview-api/modules/addons/hooks.test.js index 2fc21ff88b8..2e716d8b10b 100644 --- a/code/core/src/preview-api/modules/addons/hooks.test.js +++ b/code/core/src/preview-api/modules/addons/hooks.test.js @@ -1,4 +1,5 @@ -import { describe, beforeEach, afterEach, expect, it } from 'vitest'; +import { afterEach, beforeEach, describe, expect, it } from 'vitest'; + import { useParameter, useStoryContext } from './hooks'; describe('addons/hooks', () => { diff --git a/code/core/src/preview-api/modules/addons/hooks.ts b/code/core/src/preview-api/modules/addons/hooks.ts index 0c80bdd07dc..b956f45e9dc 100644 --- a/code/core/src/preview-api/modules/addons/hooks.ts +++ b/code/core/src/preview-api/modules/addons/hooks.ts @@ -1,13 +1,3 @@ -import { global } from '@storybook/global'; -import { logger } from '@storybook/core/client-logger'; -import { - FORCE_RE_RENDER, - STORY_RENDERED, - UPDATE_STORY_ARGS, - RESET_STORY_ARGS, - UPDATE_GLOBALS, -} from '@storybook/core/core-events'; -import { addons } from './main'; import type { Args, DecoratorApplicator, @@ -17,6 +7,18 @@ import type { StoryContext, StoryId, } from '@storybook/core/types'; +import { global } from '@storybook/global'; + +import { logger } from '@storybook/core/client-logger'; +import { + FORCE_RE_RENDER, + RESET_STORY_ARGS, + STORY_RENDERED, + UPDATE_GLOBALS, + UPDATE_STORY_ARGS, +} from '@storybook/core/core-events'; + +import { addons } from './main'; interface Hook { name: string; diff --git a/code/core/src/preview-api/modules/addons/main.ts b/code/core/src/preview-api/modules/addons/main.ts index bd4061b618a..f2012bab9f0 100644 --- a/code/core/src/preview-api/modules/addons/main.ts +++ b/code/core/src/preview-api/modules/addons/main.ts @@ -1,6 +1,6 @@ +import type { Channel } from '@storybook/core/channels'; import { global } from '@storybook/global'; -import type { Channel } from '@storybook/core/channels'; import { mockChannel } from './storybook-channel-mock'; export class AddonStore { diff --git a/code/core/src/preview-api/modules/addons/make-decorator.test.ts b/code/core/src/preview-api/modules/addons/make-decorator.test.ts index 316a5dc9d1a..d926c9f5da8 100644 --- a/code/core/src/preview-api/modules/addons/make-decorator.test.ts +++ b/code/core/src/preview-api/modules/addons/make-decorator.test.ts @@ -1,5 +1,7 @@ -import { describe, it, expect, vi } from 'vitest'; +import { describe, expect, it, vi } from 'vitest'; + import type { Addon_StoryContext } from '@storybook/core/types'; + import { makeDecorator } from './make-decorator'; // Copy & paste from internal api: client-api/src/client_api diff --git a/code/core/src/preview-api/modules/preview-web/Preview.tsx b/code/core/src/preview-api/modules/preview-web/Preview.tsx index 681d0c47c93..8f03cad2b04 100644 --- a/code/core/src/preview-api/modules/preview-web/Preview.tsx +++ b/code/core/src/preview-api/modules/preview-web/Preview.tsx @@ -1,4 +1,22 @@ +import type { Channel } from '@storybook/core/channels'; +import type { + Args, + Globals, + GlobalsUpdatedPayload, + ModuleImportFn, + PreparedStory, + ProjectAnnotations, + RenderContextCallbacks, + RenderToCanvas, + Renderer, + SetGlobalsPayload, + StoryId, + StoryIndex, + StoryRenderOptions, +} from '@storybook/core/types'; +import type { CleanupCallback } from '@storybook/csf'; import { global } from '@storybook/global'; + import { deprecate, logger } from '@storybook/core/client-logger'; import type { ArgTypesRequestPayload, @@ -20,35 +38,18 @@ import { UPDATE_GLOBALS, UPDATE_STORY_ARGS, } from '@storybook/core/core-events'; -import type { CleanupCallback } from '@storybook/csf'; -import type { Channel } from '@storybook/core/channels'; -import type { - Renderer, - Args, - Globals, - ModuleImportFn, - RenderContextCallbacks, - RenderToCanvas, - PreparedStory, - StoryIndex, - ProjectAnnotations, - StoryId, - StoryRenderOptions, - SetGlobalsPayload, - GlobalsUpdatedPayload, -} from '@storybook/core/types'; import { CalledPreviewMethodBeforeInitializationError, MissingRenderToCanvasError, StoryIndexFetchError, StoryStoreAccessedBeforeInitializationError, } from '@storybook/core/preview-errors'; -import { addons } from '../addons'; -import { StoryStore } from '../../store'; -import { StoryRender } from './render/StoryRender'; +import { StoryStore } from '../../store'; +import { addons } from '../addons'; import type { CsfDocsRender } from './render/CsfDocsRender'; import type { MdxDocsRender } from './render/MdxDocsRender'; +import { StoryRender } from './render/StoryRender'; const { fetch } = global; diff --git a/code/core/src/preview-api/modules/preview-web/PreviewWeb.integration.test.ts b/code/core/src/preview-api/modules/preview-web/PreviewWeb.integration.test.ts index d4818c162a3..6c86c2d8638 100644 --- a/code/core/src/preview-api/modules/preview-web/PreviewWeb.integration.test.ts +++ b/code/core/src/preview-api/modules/preview-web/PreviewWeb.integration.test.ts @@ -1,23 +1,24 @@ // @vitest-environment happy-dom -import { describe, beforeEach, it, expect, vi } from 'vitest'; +import { beforeEach, describe, expect, it, vi } from 'vitest'; import React from 'react'; -import { global } from '@storybook/global'; + import type { RenderContext } from '@storybook/core/types'; -import { addons } from '../addons'; +import { global } from '@storybook/global'; +import { addons } from '../addons'; import { PreviewWeb } from './PreviewWeb'; -import { WebView } from './WebView'; import { componentOneExports, - importFn, - projectAnnotations, - getProjectAnnotations, emitter, + getProjectAnnotations, + importFn, mockChannel, - waitForRender, storyIndex as mockStoryIndex, + projectAnnotations, + waitForRender, } from './PreviewWeb.mockdata'; +import { WebView } from './WebView'; // PreviewWeb.test mocks out all rendering // - ie. from`renderToCanvas()` (stories) or`ReactDOM.render()` (docs) in. diff --git a/code/core/src/preview-api/modules/preview-web/PreviewWeb.mockdata.ts b/code/core/src/preview-api/modules/preview-web/PreviewWeb.mockdata.ts index 64b083d1b7b..30abd5df7d1 100644 --- a/code/core/src/preview-api/modules/preview-web/PreviewWeb.mockdata.ts +++ b/code/core/src/preview-api/modules/preview-web/PreviewWeb.mockdata.ts @@ -1,7 +1,14 @@ import type { Mock, Mocked } from 'vitest'; import { vi } from 'vitest'; -import { EventEmitter } from 'events'; +import type { + ModuleImportFn, + ProjectAnnotations, + Renderer, + StoryIndex, + TeardownRenderToCanvas, +} from '@storybook/core/types'; + import { DOCS_RENDERED, STORY_ERRORED, @@ -11,15 +18,10 @@ import { STORY_THREW_EXCEPTION, } from '@storybook/core/core-events'; -import type { - ModuleImportFn, - ProjectAnnotations, - Renderer, - StoryIndex, - TeardownRenderToCanvas, -} from '@storybook/core/types'; -import type { RenderPhase } from './render/StoryRender'; +import { EventEmitter } from 'events'; + import { composeConfigs } from '../store'; +import type { RenderPhase } from './render/StoryRender'; export const componentOneExports = { default: { diff --git a/code/core/src/preview-api/modules/preview-web/PreviewWeb.test.ts b/code/core/src/preview-api/modules/preview-web/PreviewWeb.test.ts index ae11cb3f722..7994173c2d0 100644 --- a/code/core/src/preview-api/modules/preview-web/PreviewWeb.test.ts +++ b/code/core/src/preview-api/modules/preview-web/PreviewWeb.test.ts @@ -1,15 +1,19 @@ // @vitest-environment happy-dom -import { describe, beforeEach, afterEach, it, expect, vi } from 'vitest'; +import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'; +import type { ModuleImportFn, ProjectAnnotations, Renderer } from '@storybook/core/types'; import { global } from '@storybook/global'; -import merge from 'lodash/merge.js'; + +import { logger } from '@storybook/core/client-logger'; import { CONFIG_ERROR, CURRENT_STORY_WAS_SET, + DOCS_PREPARED, DOCS_RENDERED, FORCE_REMOUNT, FORCE_RE_RENDER, GLOBALS_UPDATED, + PLAY_FUNCTION_THREW_EXCEPTION, PREVIEW_KEYDOWN, RESET_STORY_ARGS, SET_CURRENT_STORY, @@ -22,36 +26,34 @@ import { STORY_RENDERED, STORY_SPECIFIED, STORY_THREW_EXCEPTION, - PLAY_FUNCTION_THREW_EXCEPTION, STORY_UNCHANGED, UPDATE_GLOBALS, UPDATE_STORY_ARGS, - DOCS_PREPARED, } from '@storybook/core/core-events'; -import { logger } from '@storybook/core/client-logger'; -import type { Renderer, ModuleImportFn, ProjectAnnotations } from '@storybook/core/types'; -import { addons } from '../addons'; +import merge from 'lodash/merge.js'; + +import { addons } from '../addons'; +import type { StoryStore } from '../store'; import { PreviewWeb } from './PreviewWeb'; import { componentOneExports, componentTwoExports, + docsRenderer, + emitter, + getProjectAnnotations, importFn, + mockChannel, projectAnnotations, - getProjectAnnotations, storyIndex, - emitter, - mockChannel, + teardownrenderToCanvas, + unattachedDocsExports, waitForEvents, - waitForRender, waitForQuiescence, + waitForRender, waitForRenderPhase, - docsRenderer, - unattachedDocsExports, - teardownrenderToCanvas, } from './PreviewWeb.mockdata'; import { WebView } from './WebView'; -import type { StoryStore } from '../store'; const { history, document } = global; diff --git a/code/core/src/preview-api/modules/preview-web/PreviewWeb.tsx b/code/core/src/preview-api/modules/preview-web/PreviewWeb.tsx index 0ee61fac402..cb2931350b9 100644 --- a/code/core/src/preview-api/modules/preview-web/PreviewWeb.tsx +++ b/code/core/src/preview-api/modules/preview-web/PreviewWeb.tsx @@ -1,12 +1,12 @@ /* eslint-disable no-underscore-dangle */ +import type { Renderer } from '@storybook/core/types'; +import type { ModuleImportFn, ProjectAnnotations } from '@storybook/core/types'; import { global } from '@storybook/global'; +import type { MaybePromise } from './Preview'; import { PreviewWithSelection } from './PreviewWithSelection'; import { UrlStore } from './UrlStore'; import { WebView } from './WebView'; -import type { MaybePromise } from './Preview'; -import type { Renderer } from '@storybook/core/types'; -import type { ModuleImportFn, ProjectAnnotations } from '@storybook/core/types'; export class PreviewWeb extends PreviewWithSelection { constructor( diff --git a/code/core/src/preview-api/modules/preview-web/PreviewWithSelection.tsx b/code/core/src/preview-api/modules/preview-web/PreviewWithSelection.tsx index 9bed42b07ea..711e3ac0f18 100644 --- a/code/core/src/preview-api/modules/preview-web/PreviewWithSelection.tsx +++ b/code/core/src/preview-api/modules/preview-web/PreviewWithSelection.tsx @@ -1,4 +1,8 @@ -import invariant from 'tiny-invariant'; +import type { DocsIndexEntry, StoryIndex } from '@storybook/core/types'; +import type { Args, Globals, Renderer, StoryId, ViewMode } from '@storybook/core/types'; +import type { ModuleImportFn, ProjectAnnotations } from '@storybook/core/types'; + +import { logger } from '@storybook/core/client-logger'; import { CURRENT_STORY_WAS_SET, DOCS_PREPARED, @@ -16,27 +20,24 @@ import { STORY_UNCHANGED, UPDATE_QUERY_PARAMS, } from '@storybook/core/core-events'; -import { logger } from '@storybook/core/client-logger'; - import { CalledPreviewMethodBeforeInitializationError, EmptyIndexError, MdxFileWithNoCsfReferencesError, NoStoryMatchError, } from '@storybook/core/preview-errors'; + +import invariant from 'tiny-invariant'; + +import type { StorySpecifier } from '../store/StoryIndexStore'; import type { MaybePromise } from './Preview'; import { Preview } from './Preview'; - -import { PREPARE_ABORTED } from './render/Render'; -import { StoryRender } from './render/StoryRender'; -import { CsfDocsRender } from './render/CsfDocsRender'; -import { MdxDocsRender } from './render/MdxDocsRender'; import type { Selection, SelectionStore } from './SelectionStore'; import type { View } from './View'; -import type { StorySpecifier } from '../store/StoryIndexStore'; -import type { DocsIndexEntry, StoryIndex } from '@storybook/core/types'; -import type { Args, Globals, Renderer, StoryId, ViewMode } from '@storybook/core/types'; -import type { ModuleImportFn, ProjectAnnotations } from '@storybook/core/types'; +import { CsfDocsRender } from './render/CsfDocsRender'; +import { MdxDocsRender } from './render/MdxDocsRender'; +import { PREPARE_ABORTED } from './render/Render'; +import { StoryRender } from './render/StoryRender'; const globalWindow = globalThis; diff --git a/code/core/src/preview-api/modules/preview-web/SelectionStore.ts b/code/core/src/preview-api/modules/preview-web/SelectionStore.ts index fe75097ef32..439fb7a219b 100644 --- a/code/core/src/preview-api/modules/preview-web/SelectionStore.ts +++ b/code/core/src/preview-api/modules/preview-web/SelectionStore.ts @@ -1,4 +1,5 @@ import type { Args, StoryId, ViewMode } from '@storybook/core/types'; + import type { StorySpecifier } from '../store/StoryIndexStore'; export interface SelectionSpecifier { diff --git a/code/core/src/preview-api/modules/preview-web/UrlStore.test.ts b/code/core/src/preview-api/modules/preview-web/UrlStore.test.ts index cc6e5717196..09c6e892574 100644 --- a/code/core/src/preview-api/modules/preview-web/UrlStore.test.ts +++ b/code/core/src/preview-api/modules/preview-web/UrlStore.test.ts @@ -1,7 +1,8 @@ -import { describe, it, expect, vi } from 'vitest'; +import { describe, expect, it, vi } from 'vitest'; + import { global } from '@storybook/global'; -import { pathToId, setPath, getSelectionSpecifierFromPath } from './UrlStore'; +import { getSelectionSpecifierFromPath, pathToId, setPath } from './UrlStore'; const { history, document } = global; diff --git a/code/core/src/preview-api/modules/preview-web/UrlStore.ts b/code/core/src/preview-api/modules/preview-web/UrlStore.ts index 3bd6de1a4a4..85b0c79279c 100644 --- a/code/core/src/preview-api/modules/preview-web/UrlStore.ts +++ b/code/core/src/preview-api/modules/preview-web/UrlStore.ts @@ -1,9 +1,10 @@ +import type { ViewMode } from '@storybook/core/types'; import { global } from '@storybook/global'; + import qs from 'qs'; +import type { Selection, SelectionSpecifier, SelectionStore } from './SelectionStore'; import { parseArgsParam } from './parseArgsParam'; -import type { SelectionSpecifier, SelectionStore, Selection } from './SelectionStore'; -import type { ViewMode } from '@storybook/core/types'; const { history, document } = global; diff --git a/code/core/src/preview-api/modules/preview-web/WebView.ts b/code/core/src/preview-api/modules/preview-web/WebView.ts index e36a9f6494d..1e7ae240b9a 100644 --- a/code/core/src/preview-api/modules/preview-web/WebView.ts +++ b/code/core/src/preview-api/modules/preview-web/WebView.ts @@ -1,11 +1,13 @@ +import type { PreparedStory } from '@storybook/core/types'; import { global } from '@storybook/global'; + import { logger } from '@storybook/core/client-logger'; + import AnsiToHtml from 'ansi-to-html'; -import { dedent } from 'ts-dedent'; import qs from 'qs'; +import { dedent } from 'ts-dedent'; import type { View } from './View'; -import type { PreparedStory } from '@storybook/core/types'; const { document } = global; diff --git a/code/core/src/preview-api/modules/preview-web/docs-context/DocsContext.test.ts b/code/core/src/preview-api/modules/preview-web/docs-context/DocsContext.test.ts index d1b2595ce7c..f79da3152f0 100644 --- a/code/core/src/preview-api/modules/preview-web/docs-context/DocsContext.test.ts +++ b/code/core/src/preview-api/modules/preview-web/docs-context/DocsContext.test.ts @@ -1,8 +1,9 @@ -import { describe, it, expect, vi } from 'vitest'; +import { describe, expect, it, vi } from 'vitest'; + import { Channel } from '@storybook/core/channels'; import type { CSFFile, Renderer } from '@storybook/core/types'; -import type { StoryStore } from '../../store'; +import type { StoryStore } from '../../store'; import { DocsContext } from './DocsContext'; import { csfFileParts } from './test-utils'; diff --git a/code/core/src/preview-api/modules/preview-web/docs-context/DocsContext.ts b/code/core/src/preview-api/modules/preview-web/docs-context/DocsContext.ts index ec74033b4b0..f53e08083d3 100644 --- a/code/core/src/preview-api/modules/preview-web/docs-context/DocsContext.ts +++ b/code/core/src/preview-api/modules/preview-web/docs-context/DocsContext.ts @@ -1,8 +1,4 @@ import type { Channel } from '@storybook/core/channels'; - -import { dedent } from 'ts-dedent'; -import type { StoryStore } from '../../store'; -import type { DocsContextProps } from './DocsContextProps'; import type { CSFFile, ModuleExport, @@ -15,6 +11,11 @@ import type { StoryName, } from '@storybook/core/types'; +import { dedent } from 'ts-dedent'; + +import type { StoryStore } from '../../store'; +import type { DocsContextProps } from './DocsContextProps'; + export class DocsContext implements DocsContextProps { private componentStoriesValue: PreparedStory[]; diff --git a/code/core/src/preview-api/modules/preview-web/parseArgsParam.test.ts b/code/core/src/preview-api/modules/preview-web/parseArgsParam.test.ts index f72df087ddc..28879b3464d 100644 --- a/code/core/src/preview-api/modules/preview-web/parseArgsParam.test.ts +++ b/code/core/src/preview-api/modules/preview-web/parseArgsParam.test.ts @@ -1,4 +1,5 @@ -import { describe, it, expect, vi } from 'vitest'; +import { describe, expect, it, vi } from 'vitest'; + import { parseArgsParam } from './parseArgsParam'; vi.mock('@storybook/core/client-logger', () => ({ diff --git a/code/core/src/preview-api/modules/preview-web/parseArgsParam.ts b/code/core/src/preview-api/modules/preview-web/parseArgsParam.ts index a2cd2eb3080..89ec237c0a1 100644 --- a/code/core/src/preview-api/modules/preview-web/parseArgsParam.ts +++ b/code/core/src/preview-api/modules/preview-web/parseArgsParam.ts @@ -1,8 +1,10 @@ -import qs from 'qs'; -import { dedent } from 'ts-dedent'; +import type { Args } from '@storybook/core/types'; + import { once } from '@storybook/core/client-logger'; + import isPlainObject from 'lodash/isPlainObject.js'; -import type { Args } from '@storybook/core/types'; +import qs from 'qs'; +import { dedent } from 'ts-dedent'; // Keep this in sync with validateArgs in router/src/utils.ts const VALIDATION_REGEXP = /^[a-zA-Z0-9 _-]*$/; diff --git a/code/core/src/preview-api/modules/preview-web/render/CsfDocsRender.test.ts b/code/core/src/preview-api/modules/preview-web/render/CsfDocsRender.test.ts index 03f04b3bf63..aa428572219 100644 --- a/code/core/src/preview-api/modules/preview-web/render/CsfDocsRender.test.ts +++ b/code/core/src/preview-api/modules/preview-web/render/CsfDocsRender.test.ts @@ -1,11 +1,12 @@ -import { it, expect, vi } from 'vitest'; +import { expect, it, vi } from 'vitest'; + import { Channel } from '@storybook/core/channels'; -import type { Renderer, DocsIndexEntry, RenderContextCallbacks } from '@storybook/core/types'; -import type { StoryStore } from '../../store'; -import { PREPARE_ABORTED } from './Render'; +import type { DocsIndexEntry, RenderContextCallbacks, Renderer } from '@storybook/core/types'; -import { CsfDocsRender } from './CsfDocsRender'; +import type { StoryStore } from '../../store'; import { csfFileParts } from '../docs-context/test-utils'; +import { CsfDocsRender } from './CsfDocsRender'; +import { PREPARE_ABORTED } from './Render'; const entry = { type: 'docs', diff --git a/code/core/src/preview-api/modules/preview-web/render/CsfDocsRender.ts b/code/core/src/preview-api/modules/preview-web/render/CsfDocsRender.ts index 048c5a367ca..6a95017605e 100644 --- a/code/core/src/preview-api/modules/preview-web/render/CsfDocsRender.ts +++ b/code/core/src/preview-api/modules/preview-web/render/CsfDocsRender.ts @@ -1,17 +1,18 @@ import type { Channel } from '@storybook/core/channels'; -import { DOCS_RENDERED } from '@storybook/core/core-events'; -import type { StoryStore } from '../../../store'; - -import type { Render, RenderType } from './Render'; -import { PREPARE_ABORTED } from './Render'; -import type { DocsContextProps } from '../docs-context/DocsContextProps'; -import type { DocsRenderFunction } from '../docs-context/DocsRenderFunction'; -import { DocsContext } from '../docs-context/DocsContext'; import type { Renderer, StoryId } from '@storybook/core/types'; import type { CSFFile, PreparedStory } from '@storybook/core/types'; import type { IndexEntry } from '@storybook/core/types'; import type { RenderContextCallbacks } from '@storybook/core/types'; +import { DOCS_RENDERED } from '@storybook/core/core-events'; + +import type { StoryStore } from '../../../store'; +import { DocsContext } from '../docs-context/DocsContext'; +import type { DocsContextProps } from '../docs-context/DocsContextProps'; +import type { DocsRenderFunction } from '../docs-context/DocsRenderFunction'; +import type { Render, RenderType } from './Render'; +import { PREPARE_ABORTED } from './Render'; + /** * A CsfDocsRender is a render of a docs entry that is rendered based on a CSF file. * diff --git a/code/core/src/preview-api/modules/preview-web/render/MdxDocsRender.test.ts b/code/core/src/preview-api/modules/preview-web/render/MdxDocsRender.test.ts index 58aff6acf9d..86a172013e9 100644 --- a/code/core/src/preview-api/modules/preview-web/render/MdxDocsRender.test.ts +++ b/code/core/src/preview-api/modules/preview-web/render/MdxDocsRender.test.ts @@ -1,11 +1,12 @@ -import { describe, it, expect, vi } from 'vitest'; +import { describe, expect, it, vi } from 'vitest'; + import { Channel } from '@storybook/core/channels'; -import type { Renderer, DocsIndexEntry, RenderContextCallbacks } from '@storybook/core/types'; -import type { StoryStore } from '../../store'; -import { PREPARE_ABORTED } from './Render'; +import type { DocsIndexEntry, RenderContextCallbacks, Renderer } from '@storybook/core/types'; -import { MdxDocsRender } from './MdxDocsRender'; +import type { StoryStore } from '../../store'; import { csfFileParts } from '../docs-context/test-utils'; +import { MdxDocsRender } from './MdxDocsRender'; +import { PREPARE_ABORTED } from './Render'; const entry = { type: 'docs', diff --git a/code/core/src/preview-api/modules/preview-web/render/MdxDocsRender.ts b/code/core/src/preview-api/modules/preview-web/render/MdxDocsRender.ts index b7751e69df1..596900c3f4e 100644 --- a/code/core/src/preview-api/modules/preview-web/render/MdxDocsRender.ts +++ b/code/core/src/preview-api/modules/preview-web/render/MdxDocsRender.ts @@ -1,17 +1,18 @@ import type { Channel } from '@storybook/core/channels'; -import { DOCS_RENDERED } from '@storybook/core/core-events'; -import type { StoryStore } from '../../store'; - -import type { Render, RenderType } from './Render'; -import { PREPARE_ABORTED } from './Render'; -import type { DocsContextProps } from '../docs-context/DocsContextProps'; -import type { DocsRenderFunction } from '../docs-context/DocsRenderFunction'; -import { DocsContext } from '../docs-context/DocsContext'; import type { Renderer, StoryId } from '@storybook/core/types'; import type { CSFFile, ModuleExports } from '@storybook/core/types'; import type { IndexEntry } from '@storybook/core/types'; import type { RenderContextCallbacks } from '@storybook/core/types'; +import { DOCS_RENDERED } from '@storybook/core/core-events'; + +import type { StoryStore } from '../../store'; +import { DocsContext } from '../docs-context/DocsContext'; +import type { DocsContextProps } from '../docs-context/DocsContextProps'; +import type { DocsRenderFunction } from '../docs-context/DocsRenderFunction'; +import type { Render, RenderType } from './Render'; +import { PREPARE_ABORTED } from './Render'; + /** * A MdxDocsRender is a render of a docs entry that comes from a true MDX file, * that is a `.mdx` file that doesn't get compiled to a CSF file. diff --git a/code/core/src/preview-api/modules/preview-web/render/StoryRender.test.ts b/code/core/src/preview-api/modules/preview-web/render/StoryRender.test.ts index 0b84b76c286..2bd3a9ca383 100644 --- a/code/core/src/preview-api/modules/preview-web/render/StoryRender.test.ts +++ b/code/core/src/preview-api/modules/preview-web/render/StoryRender.test.ts @@ -1,10 +1,11 @@ // @vitest-environment happy-dom -import { describe, it, expect, vi, beforeEach } from 'vitest'; +import { beforeEach, describe, expect, it, vi } from 'vitest'; + import { Channel } from '@storybook/core/channels'; import type { PreparedStory, Renderer, StoryContext, StoryIndexEntry } from '@storybook/core/types'; + import type { StoryStore } from '../../store'; import { PREPARE_ABORTED } from './Render'; - import { StoryRender } from './StoryRender'; const entry = { diff --git a/code/core/src/preview-api/modules/preview-web/render/StoryRender.ts b/code/core/src/preview-api/modules/preview-web/render/StoryRender.ts index 5f4503877fc..cd12e2dc3b6 100644 --- a/code/core/src/preview-api/modules/preview-web/render/StoryRender.ts +++ b/code/core/src/preview-api/modules/preview-web/render/StoryRender.ts @@ -1,28 +1,29 @@ import type { Channel } from '@storybook/core/channels'; -import { - STORY_RENDER_PHASE_CHANGED, - STORY_RENDERED, - PLAY_FUNCTION_THREW_EXCEPTION, - UNHANDLED_ERRORS_WHILE_PLAYING, -} from '@storybook/core/core-events'; -import type { StoryStore } from '../../store'; -import type { Render, RenderType } from './Render'; -import { PREPARE_ABORTED } from './Render'; -import { MountMustBeDestructuredError, NoStoryMountedError } from '@storybook/core/preview-errors'; - import type { Canvas, PreparedStory, RenderContext, RenderContextCallbacks, - Renderer, RenderToCanvas, + Renderer, StoryContext, StoryId, StoryRenderOptions, TeardownRenderToCanvas, } from '@storybook/core/types'; +import { + PLAY_FUNCTION_THREW_EXCEPTION, + STORY_RENDERED, + STORY_RENDER_PHASE_CHANGED, + UNHANDLED_ERRORS_WHILE_PLAYING, +} from '@storybook/core/core-events'; +import { MountMustBeDestructuredError, NoStoryMountedError } from '@storybook/core/preview-errors'; + +import type { StoryStore } from '../../store'; +import type { Render, RenderType } from './Render'; +import { PREPARE_ABORTED } from './Render'; + const { AbortController } = globalThis; export type RenderPhase = diff --git a/code/core/src/preview-api/modules/preview-web/render/mount-utils.test.ts b/code/core/src/preview-api/modules/preview-web/render/mount-utils.test.ts index 4fe7b4ac883..80c1a56211b 100644 --- a/code/core/src/preview-api/modules/preview-web/render/mount-utils.test.ts +++ b/code/core/src/preview-api/modules/preview-web/render/mount-utils.test.ts @@ -1,4 +1,5 @@ import { expect, test } from 'vitest'; + import { getUsedProps } from './mount-utils'; const StoryWithContext = { diff --git a/code/core/src/preview-api/modules/preview-web/simulate-pageload.test.ts b/code/core/src/preview-api/modules/preview-web/simulate-pageload.test.ts index 0f43ae04c54..c15e8613034 100644 --- a/code/core/src/preview-api/modules/preview-web/simulate-pageload.test.ts +++ b/code/core/src/preview-api/modules/preview-web/simulate-pageload.test.ts @@ -1,7 +1,8 @@ // @vitest-environment happy-dom -import { describe, it, expect } from 'vitest'; +import { describe, expect, it } from 'vitest'; import { global } from '@storybook/global'; + import { simulatePageLoad } from './simulate-pageload'; const { document } = global; diff --git a/code/core/src/preview-api/modules/store/ArgsStore.test.ts b/code/core/src/preview-api/modules/store/ArgsStore.test.ts index d730aed9ece..ad3d20c7664 100644 --- a/code/core/src/preview-api/modules/store/ArgsStore.test.ts +++ b/code/core/src/preview-api/modules/store/ArgsStore.test.ts @@ -1,4 +1,4 @@ -import { describe, it, expect, vi } from 'vitest'; +import { describe, expect, it, vi } from 'vitest'; import { ArgsStore } from './ArgsStore'; diff --git a/code/core/src/preview-api/modules/store/ArgsStore.ts b/code/core/src/preview-api/modules/store/ArgsStore.ts index 5c9f941b0eb..da613e76dc8 100644 --- a/code/core/src/preview-api/modules/store/ArgsStore.ts +++ b/code/core/src/preview-api/modules/store/ArgsStore.ts @@ -1,7 +1,8 @@ import type { Args, StoryId } from '@storybook/core/types'; -import { combineArgs, mapArgsToTypes, validateOptions, deepDiff, DEEPLY_EQUAL } from './args'; import type { PreparedStory } from '@storybook/core/types'; +import { DEEPLY_EQUAL, combineArgs, deepDiff, mapArgsToTypes, validateOptions } from './args'; + function deleteUndefined(obj: Record) { Object.keys(obj).forEach((key) => obj[key] === undefined && delete obj[key]); return obj; diff --git a/code/core/src/preview-api/modules/store/GlobalsStore.test.ts b/code/core/src/preview-api/modules/store/GlobalsStore.test.ts index 85f99d5be0d..eda822e40c6 100644 --- a/code/core/src/preview-api/modules/store/GlobalsStore.test.ts +++ b/code/core/src/preview-api/modules/store/GlobalsStore.test.ts @@ -1,4 +1,5 @@ -import { describe, it, expect, vi } from 'vitest'; +import { describe, expect, it, vi } from 'vitest'; + import { GlobalsStore } from './GlobalsStore'; vi.mock('@storybook/core/client-logger', () => ({ diff --git a/code/core/src/preview-api/modules/store/GlobalsStore.ts b/code/core/src/preview-api/modules/store/GlobalsStore.ts index 0ec64390b51..dd15417d914 100644 --- a/code/core/src/preview-api/modules/store/GlobalsStore.ts +++ b/code/core/src/preview-api/modules/store/GlobalsStore.ts @@ -1,8 +1,9 @@ +import type { GlobalTypes, Globals } from '@storybook/core/types'; + import { logger } from '@storybook/core/client-logger'; -import { deepDiff, DEEPLY_EQUAL } from './args'; +import { DEEPLY_EQUAL, deepDiff } from './args'; import { getValuesFromArgTypes } from './csf/getValuesFromArgTypes'; -import type { Globals, GlobalTypes } from '@storybook/core/types'; export class GlobalsStore { // We use ! here because TS doesn't analyse the .set() function to see if it actually get set diff --git a/code/core/src/preview-api/modules/store/StoryIndexStore.test.ts b/code/core/src/preview-api/modules/store/StoryIndexStore.test.ts index 11da6962313..1cfdd553ea3 100644 --- a/code/core/src/preview-api/modules/store/StoryIndexStore.test.ts +++ b/code/core/src/preview-api/modules/store/StoryIndexStore.test.ts @@ -1,6 +1,7 @@ -import { describe, it, expect, vi } from 'vitest'; +import { describe, expect, it, vi } from 'vitest'; import type { StoryIndex } from '@storybook/core/types'; + import { StoryIndexStore } from './StoryIndexStore'; vi.mock('@storybook/channel-websocket', () => () => ({ on: vi.fn() })); diff --git a/code/core/src/preview-api/modules/store/StoryIndexStore.ts b/code/core/src/preview-api/modules/store/StoryIndexStore.ts index f608932b612..d6812e736f5 100644 --- a/code/core/src/preview-api/modules/store/StoryIndexStore.ts +++ b/code/core/src/preview-api/modules/store/StoryIndexStore.ts @@ -1,8 +1,10 @@ -import memoize from 'memoizerific'; -import { MissingStoryAfterHmrError } from '@storybook/core/preview-errors'; import type { ComponentTitle, Path, StoryId, StoryName } from '@storybook/core/types'; import type { IndexEntry, StoryIndex } from '@storybook/core/types'; +import { MissingStoryAfterHmrError } from '@storybook/core/preview-errors'; + +import memoize from 'memoizerific'; + export type StorySpecifier = StoryId | { name: StoryName; title: ComponentTitle } | '*'; const getImportPathMap = memoize(1)((entries: StoryIndex['entries']) => diff --git a/code/core/src/preview-api/modules/store/StoryStore.test.ts b/code/core/src/preview-api/modules/store/StoryStore.test.ts index abb6c158c76..4cc27210c5a 100644 --- a/code/core/src/preview-api/modules/store/StoryStore.test.ts +++ b/code/core/src/preview-api/modules/store/StoryStore.test.ts @@ -1,11 +1,12 @@ -import { describe, it, expect, vi } from 'vitest'; -import type { Renderer, ProjectAnnotations, StoryIndex } from '@storybook/core/types'; +import { describe, expect, it, vi } from 'vitest'; +import type { ProjectAnnotations, Renderer, StoryIndex } from '@storybook/core/types'; + +import { StoryStore } from './StoryStore'; +import { composeConfigs } from './csf/composeConfigs'; import { prepareStory } from './csf/prepareStory'; import { processCSFFile } from './csf/processCSFFile'; -import { StoryStore } from './StoryStore'; import type { HooksContext } from './hooks'; -import { composeConfigs } from './csf/composeConfigs'; // Spy on prepareStory/processCSFFile vi.mock('./csf/prepareStory', async (importOriginal) => { diff --git a/code/core/src/preview-api/modules/store/StoryStore.ts b/code/core/src/preview-api/modules/store/StoryStore.ts index c5414d7956c..99d6efd5f8b 100644 --- a/code/core/src/preview-api/modules/store/StoryStore.ts +++ b/code/core/src/preview-api/modules/store/StoryStore.ts @@ -1,33 +1,12 @@ -import memoize from 'memoizerific'; import type { - Renderer, ComponentTitle, Parameters, Path, + Renderer, StoryContext, StoryContextForEnhancers, StoryId, } from '@storybook/core/types'; -import mapValues from 'lodash/mapValues.js'; -import pick from 'lodash/pick.js'; - -import { - CalledExtractOnStoreError, - MissingStoryFromCsfFileError, -} from '@storybook/core/preview-errors'; -import { deprecate } from '@storybook/core/client-logger'; -import { HooksContext } from '../addons'; -import { StoryIndexStore } from './StoryIndexStore'; -import { ArgsStore } from './ArgsStore'; -import { GlobalsStore } from './GlobalsStore'; -import { - processCSFFile, - prepareStory, - prepareMeta, - normalizeProjectAnnotations, - prepareContext, -} from './csf'; -import type { Canvas, CleanupCallback } from '@storybook/csf'; import type { BoundStory, CSFFile, @@ -44,6 +23,29 @@ import type { StoryIndexV3, V3CompatIndexEntry, } from '@storybook/core/types'; +import type { Canvas, CleanupCallback } from '@storybook/csf'; + +import { deprecate } from '@storybook/core/client-logger'; +import { + CalledExtractOnStoreError, + MissingStoryFromCsfFileError, +} from '@storybook/core/preview-errors'; + +import mapValues from 'lodash/mapValues.js'; +import pick from 'lodash/pick.js'; +import memoize from 'memoizerific'; + +import { HooksContext } from '../addons'; +import { ArgsStore } from './ArgsStore'; +import { GlobalsStore } from './GlobalsStore'; +import { StoryIndexStore } from './StoryIndexStore'; +import { + normalizeProjectAnnotations, + prepareContext, + prepareMeta, + prepareStory, + processCSFFile, +} from './csf'; // TODO -- what are reasonable values for these? const CSF_CACHE_SIZE = 1000; diff --git a/code/core/src/preview-api/modules/store/args.test.ts b/code/core/src/preview-api/modules/store/args.test.ts index 3d6e82c5331..d40d989cebc 100644 --- a/code/core/src/preview-api/modules/store/args.test.ts +++ b/code/core/src/preview-api/modules/store/args.test.ts @@ -1,12 +1,14 @@ -import { describe, it, expect, vi } from 'vitest'; -import { once } from '@storybook/core/client-logger'; +import { describe, expect, it, vi } from 'vitest'; + import type { SBType } from '@storybook/core/types'; +import { once } from '@storybook/core/client-logger'; + import { + UNTARGETED, combineArgs, groupArgsByTarget, mapArgsToTypes, - UNTARGETED, validateOptions, } from './args'; diff --git a/code/core/src/preview-api/modules/store/args.ts b/code/core/src/preview-api/modules/store/args.ts index 213de81df96..ca856dd6bc1 100644 --- a/code/core/src/preview-api/modules/store/args.ts +++ b/code/core/src/preview-api/modules/store/args.ts @@ -1,7 +1,3 @@ -import { dequal as deepEqual } from 'dequal'; -import { once } from '@storybook/core/client-logger'; -import isPlainObject from 'lodash/isPlainObject.js'; -import { dedent } from 'ts-dedent'; import type { ArgTypes, Args, @@ -11,6 +7,12 @@ import type { StoryContext, } from '@storybook/core/types'; +import { once } from '@storybook/core/client-logger'; + +import { dequal as deepEqual } from 'dequal'; +import isPlainObject from 'lodash/isPlainObject.js'; +import { dedent } from 'ts-dedent'; + const INCOMPATIBLE = Symbol('incompatible'); const map = (arg: unknown, argType: InputType): any => { const type = argType.type as SBType; diff --git a/code/core/src/preview-api/modules/store/autoTitle.test.ts b/code/core/src/preview-api/modules/store/autoTitle.test.ts index e45c0a03565..3289261dd8b 100644 --- a/code/core/src/preview-api/modules/store/autoTitle.test.ts +++ b/code/core/src/preview-api/modules/store/autoTitle.test.ts @@ -1,4 +1,5 @@ -import { describe, it, expect } from 'vitest'; +import { describe, expect, it } from 'vitest'; + import { normalizeStoriesEntry } from '@storybook/core/common'; import { userOrAutoTitleFromSpecifier as userOrAuto } from './autoTitle'; diff --git a/code/core/src/preview-api/modules/store/autoTitle.ts b/code/core/src/preview-api/modules/store/autoTitle.ts index 8c8064208b0..175f6c107ae 100644 --- a/code/core/src/preview-api/modules/store/autoTitle.ts +++ b/code/core/src/preview-api/modules/store/autoTitle.ts @@ -1,7 +1,9 @@ +import type { NormalizedStoriesSpecifier } from '@storybook/core/types'; + +import { once } from '@storybook/core/client-logger'; + import slash from 'slash'; import { dedent } from 'ts-dedent'; -import { once } from '@storybook/core/client-logger'; -import type { NormalizedStoriesSpecifier } from '@storybook/core/types'; // FIXME: types duplicated type from `core-common', to be // removed when we remove v6 back-compat. diff --git a/code/core/src/preview-api/modules/store/csf/beforeAll.test.ts b/code/core/src/preview-api/modules/store/csf/beforeAll.test.ts index e3f0200dd19..30f066e8ac0 100644 --- a/code/core/src/preview-api/modules/store/csf/beforeAll.test.ts +++ b/code/core/src/preview-api/modules/store/csf/beforeAll.test.ts @@ -1,4 +1,5 @@ import { beforeEach, describe, expect, it } from 'vitest'; + import { composeBeforeAllHooks } from './beforeAll'; const calls: string[] = []; diff --git a/code/core/src/preview-api/modules/store/csf/composeConfigs.test.ts b/code/core/src/preview-api/modules/store/csf/composeConfigs.test.ts index 0d8f0e2912b..035aa60e7e1 100644 --- a/code/core/src/preview-api/modules/store/csf/composeConfigs.test.ts +++ b/code/core/src/preview-api/modules/store/csf/composeConfigs.test.ts @@ -1,4 +1,5 @@ -import { describe, beforeEach, afterEach, it, expect, vi } from 'vitest'; +import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'; + import { global } from '@storybook/global'; import { composeConfigs } from './composeConfigs'; diff --git a/code/core/src/preview-api/modules/store/csf/composeConfigs.ts b/code/core/src/preview-api/modules/store/csf/composeConfigs.ts index 29eb8ec56c3..7ccec568565 100644 --- a/code/core/src/preview-api/modules/store/csf/composeConfigs.ts +++ b/code/core/src/preview-api/modules/store/csf/composeConfigs.ts @@ -3,9 +3,9 @@ import type { Renderer } from '@storybook/core/types'; import { global } from '@storybook/global'; import { combineParameters } from '../parameters'; -import { composeStepRunners } from './stepRunners'; -import { normalizeArrays } from './normalizeArrays'; import { composeBeforeAllHooks } from './beforeAll'; +import { normalizeArrays } from './normalizeArrays'; +import { composeStepRunners } from './stepRunners'; export function getField( moduleExportList: ModuleExports[], diff --git a/code/core/src/preview-api/modules/store/csf/normalizeComponentAnnotations.ts b/code/core/src/preview-api/modules/store/csf/normalizeComponentAnnotations.ts index d9da3d5ed8e..b314a89d31b 100644 --- a/code/core/src/preview-api/modules/store/csf/normalizeComponentAnnotations.ts +++ b/code/core/src/preview-api/modules/store/csf/normalizeComponentAnnotations.ts @@ -1,8 +1,8 @@ +import type { ModuleExports, NormalizedComponentAnnotations } from '@storybook/core/types'; +import type { Renderer } from '@storybook/core/types'; import { sanitize } from '@storybook/csf'; import { normalizeInputTypes } from './normalizeInputTypes'; -import type { ModuleExports, NormalizedComponentAnnotations } from '@storybook/core/types'; -import type { Renderer } from '@storybook/core/types'; export function normalizeComponentAnnotations( defaultExport: ModuleExports['default'], diff --git a/code/core/src/preview-api/modules/store/csf/normalizeInputTypes.test.ts b/code/core/src/preview-api/modules/store/csf/normalizeInputTypes.test.ts index 58f38ea7932..33b8f26e962 100644 --- a/code/core/src/preview-api/modules/store/csf/normalizeInputTypes.test.ts +++ b/code/core/src/preview-api/modules/store/csf/normalizeInputTypes.test.ts @@ -1,4 +1,4 @@ -import { describe, it, expect } from 'vitest'; +import { describe, expect, it } from 'vitest'; import { normalizeInputType, normalizeInputTypes } from './normalizeInputTypes'; diff --git a/code/core/src/preview-api/modules/store/csf/normalizeInputTypes.ts b/code/core/src/preview-api/modules/store/csf/normalizeInputTypes.ts index a34c0aaaaaa..0b9b0dc2c31 100644 --- a/code/core/src/preview-api/modules/store/csf/normalizeInputTypes.ts +++ b/code/core/src/preview-api/modules/store/csf/normalizeInputTypes.ts @@ -6,6 +6,7 @@ import type { StrictGlobalTypes, StrictInputType, } from '@storybook/core/types'; + import mapValues from 'lodash/mapValues.js'; const normalizeType = (type: InputType['type']): StrictInputType['type'] => { diff --git a/code/core/src/preview-api/modules/store/csf/normalizeProjectAnnotations.test.ts b/code/core/src/preview-api/modules/store/csf/normalizeProjectAnnotations.test.ts index a6aa1a2f7a8..bfb2a4c067b 100644 --- a/code/core/src/preview-api/modules/store/csf/normalizeProjectAnnotations.test.ts +++ b/code/core/src/preview-api/modules/store/csf/normalizeProjectAnnotations.test.ts @@ -1,4 +1,4 @@ -import { describe, it, expect, vi, beforeEach } from 'vitest'; +import { beforeEach, describe, expect, it, vi } from 'vitest'; import { normalizeProjectAnnotations } from './normalizeProjectAnnotations'; diff --git a/code/core/src/preview-api/modules/store/csf/normalizeProjectAnnotations.ts b/code/core/src/preview-api/modules/store/csf/normalizeProjectAnnotations.ts index adc3282d993..26711a13010 100644 --- a/code/core/src/preview-api/modules/store/csf/normalizeProjectAnnotations.ts +++ b/code/core/src/preview-api/modules/store/csf/normalizeProjectAnnotations.ts @@ -1,17 +1,19 @@ import type { - Renderer, ArgTypes, - ProjectAnnotations, NormalizedProjectAnnotations, + ProjectAnnotations, + Renderer, } from '@storybook/core/types'; + import { deprecate } from '@storybook/core/client-logger'; + import { dedent } from 'ts-dedent'; import { inferArgTypes } from '../inferArgTypes'; import { inferControls } from '../inferControls'; -import { normalizeInputTypes } from './normalizeInputTypes'; -import { normalizeArrays } from './normalizeArrays'; import { combineParameters } from '../parameters'; +import { normalizeArrays } from './normalizeArrays'; +import { normalizeInputTypes } from './normalizeInputTypes'; // TODO(kasperpeulen) Consolidate this function with composeConfigs // As composeConfigs is the real normalizer, and always run before normalizeProjectAnnotations diff --git a/code/core/src/preview-api/modules/store/csf/normalizeStory.test.ts b/code/core/src/preview-api/modules/store/csf/normalizeStory.test.ts index a8dc553cf0e..ddacda23051 100644 --- a/code/core/src/preview-api/modules/store/csf/normalizeStory.test.ts +++ b/code/core/src/preview-api/modules/store/csf/normalizeStory.test.ts @@ -1,4 +1,5 @@ -import { describe, it, expect, vi } from 'vitest'; +import { describe, expect, it, vi } from 'vitest'; + import type { Renderer, StoryAnnotationsOrFn } from '@storybook/core/types'; import { normalizeStory } from './normalizeStory'; diff --git a/code/core/src/preview-api/modules/store/csf/normalizeStory.ts b/code/core/src/preview-api/modules/store/csf/normalizeStory.ts index d4c710b2eb0..2dd2ae95739 100644 --- a/code/core/src/preview-api/modules/store/csf/normalizeStory.ts +++ b/code/core/src/preview-api/modules/store/csf/normalizeStory.ts @@ -1,20 +1,23 @@ import type { - Renderer, ArgTypes, LegacyStoryAnnotationsOrFn, + Renderer, StoryAnnotations, StoryFn, StoryId, } from '@storybook/core/types'; -import { storyNameFromExport, toId } from '@storybook/csf'; -import { dedent } from 'ts-dedent'; -import { logger, deprecate } from '@storybook/core/client-logger'; -import { normalizeInputTypes } from './normalizeInputTypes'; -import { normalizeArrays } from './normalizeArrays'; import type { NormalizedComponentAnnotations, NormalizedStoryAnnotations, } from '@storybook/core/types'; +import { storyNameFromExport, toId } from '@storybook/csf'; + +import { deprecate, logger } from '@storybook/core/client-logger'; + +import { dedent } from 'ts-dedent'; + +import { normalizeArrays } from './normalizeArrays'; +import { normalizeInputTypes } from './normalizeInputTypes'; const deprecatedStoryAnnotation = dedent` CSF .story annotations deprecated; annotate story functions directly: diff --git a/code/core/src/preview-api/modules/store/csf/portable-stories.test.ts b/code/core/src/preview-api/modules/store/csf/portable-stories.test.ts index c13f9c93148..6c85760cbd4 100644 --- a/code/core/src/preview-api/modules/store/csf/portable-stories.test.ts +++ b/code/core/src/preview-api/modules/store/csf/portable-stories.test.ts @@ -1,15 +1,16 @@ // @vitest-environment node -import { describe, expect, vi, it } from 'vitest'; +import { describe, expect, it, vi } from 'vitest'; + import type { ComponentAnnotations as Meta, - StoryAnnotationsOrFn as Story, Store_CSFExports, + StoryAnnotationsOrFn as Story, } from '@storybook/core/types'; +import type { ProjectAnnotations } from '@storybook/csf'; -import { composeStory, composeStories, setProjectAnnotations } from './portable-stories'; import * as defaultExportAnnotations from './__mocks__/defaultExportAnnotations.mockfile'; import * as namedExportAnnotations from './__mocks__/namedExportAnnotations.mockfile'; -import type { ProjectAnnotations } from '@storybook/csf'; +import { composeStories, composeStory, setProjectAnnotations } from './portable-stories'; type StoriesModule = Store_CSFExports & Record; diff --git a/code/core/src/preview-api/modules/store/csf/portable-stories.ts b/code/core/src/preview-api/modules/store/csf/portable-stories.ts index bd18285d456..877901fecea 100644 --- a/code/core/src/preview-api/modules/store/csf/portable-stories.ts +++ b/code/core/src/preview-api/modules/store/csf/portable-stories.ts @@ -1,13 +1,12 @@ /* eslint-disable no-underscore-dangle */ + /* eslint-disable @typescript-eslint/naming-convention */ -import { type CleanupCallback, isExportStory } from '@storybook/csf'; -import { dedent } from 'ts-dedent'; import type { Args, Canvas, ComponentAnnotations, - ComposedStoryFn, ComposeStoryFn, + ComposedStoryFn, LegacyStoryAnnotationsOrFn, NamedOrDefaultProjectAnnotations, Parameters, @@ -19,15 +18,19 @@ import type { StoryContext, StrictArgTypes, } from '@storybook/core/types'; +import { type CleanupCallback, isExportStory } from '@storybook/csf'; + +import { MountMustBeDestructuredError } from '@storybook/core/preview-errors'; + +import { dedent } from 'ts-dedent'; import { HooksContext } from '../../../addons'; import { composeConfigs } from './composeConfigs'; -import { prepareContext, prepareStory } from './prepareStory'; -import { normalizeStory } from './normalizeStory'; -import { normalizeComponentAnnotations } from './normalizeComponentAnnotations'; import { getValuesFromArgTypes } from './getValuesFromArgTypes'; +import { normalizeComponentAnnotations } from './normalizeComponentAnnotations'; import { normalizeProjectAnnotations } from './normalizeProjectAnnotations'; -import { MountMustBeDestructuredError } from '@storybook/core/preview-errors'; +import { normalizeStory } from './normalizeStory'; +import { prepareContext, prepareStory } from './prepareStory'; let globalProjectAnnotations: ProjectAnnotations = {}; diff --git a/code/core/src/preview-api/modules/store/csf/prepareStory.test.ts b/code/core/src/preview-api/modules/store/csf/prepareStory.test.ts index e9fd7f3228b..e91a6fcfea0 100644 --- a/code/core/src/preview-api/modules/store/csf/prepareStory.test.ts +++ b/code/core/src/preview-api/modules/store/csf/prepareStory.test.ts @@ -1,5 +1,5 @@ import { beforeEach, describe, expect, it, vi } from 'vitest'; -import { global } from '@storybook/global'; + import type { ArgsEnhancer, NormalizedComponentAnnotations, @@ -10,12 +10,13 @@ import type { SBScalarType, StoryContext, } from '@storybook/core/types'; -import { addons, HooksContext } from '../../addons'; +import { global } from '@storybook/global'; +import { HooksContext, addons } from '../../addons'; import { UNTARGETED } from '../args'; -import { prepareMeta, prepareStory as realPrepareStory, prepareContext } from './prepareStory'; import { composeConfigs } from './composeConfigs'; import { normalizeProjectAnnotations } from './normalizeProjectAnnotations'; +import { prepareContext, prepareMeta, prepareStory as realPrepareStory } from './prepareStory'; vi.mock('@storybook/global', async (importOriginal) => ({ global: { diff --git a/code/core/src/preview-api/modules/store/csf/prepareStory.ts b/code/core/src/preview-api/modules/store/csf/prepareStory.ts index 77bbb4f2675..80f4fbd82f7 100644 --- a/code/core/src/preview-api/modules/store/csf/prepareStory.ts +++ b/code/core/src/preview-api/modules/store/csf/prepareStory.ts @@ -1,5 +1,4 @@ /* eslint-disable no-underscore-dangle */ -import { global } from '@storybook/global'; import type { Args, ArgsStoryFn, @@ -13,23 +12,25 @@ import type { StoryContextForLoaders, StrictArgTypes, } from '@storybook/core/types'; -import { type CleanupCallback, includeConditionalArg, combineTags } from '@storybook/csf'; -import { global as globalThis } from '@storybook/global'; - -import { applyHooks } from '../../addons'; -import { combineParameters } from '../parameters'; -import { defaultDecorateStory } from '../decorators'; -import { groupArgsByTarget, UNTARGETED } from '../args'; -import { normalizeArrays } from './normalizeArrays'; import type { ModuleExport, NormalizedComponentAnnotations, NormalizedProjectAnnotations, NormalizedStoryAnnotations, } from '@storybook/core/types'; -import { mountDestructured } from '../../preview-web/render/mount-utils'; +import { type CleanupCallback, combineTags, includeConditionalArg } from '@storybook/csf'; +import { global } from '@storybook/global'; +import { global as globalThis } from '@storybook/global'; + import { NoRenderFunctionError } from '@storybook/core/preview-errors'; +import { applyHooks } from '../../addons'; +import { mountDestructured } from '../../preview-web/render/mount-utils'; +import { UNTARGETED, groupArgsByTarget } from '../args'; +import { defaultDecorateStory } from '../decorators'; +import { combineParameters } from '../parameters'; +import { normalizeArrays } from './normalizeArrays'; + // Combine all the metadata about a story (both direct and inherited from the component/global scope) // into a "render-able" story function, with all decorators applied, parameters passed as context etc // diff --git a/code/core/src/preview-api/modules/store/csf/processCSFFile.test.ts b/code/core/src/preview-api/modules/store/csf/processCSFFile.test.ts index 8ff880caed3..a8382e66098 100644 --- a/code/core/src/preview-api/modules/store/csf/processCSFFile.test.ts +++ b/code/core/src/preview-api/modules/store/csf/processCSFFile.test.ts @@ -1,4 +1,4 @@ -import { describe, it, expect } from 'vitest'; +import { describe, expect, it } from 'vitest'; import { processCSFFile } from './processCSFFile'; diff --git a/code/core/src/preview-api/modules/store/csf/processCSFFile.ts b/code/core/src/preview-api/modules/store/csf/processCSFFile.ts index 3f5b9ebacd0..fa1e3aecb50 100644 --- a/code/core/src/preview-api/modules/store/csf/processCSFFile.ts +++ b/code/core/src/preview-api/modules/store/csf/processCSFFile.ts @@ -1,10 +1,11 @@ -import type { Renderer, ComponentTitle, Parameters, Path } from '@storybook/core/types'; +import type { ComponentTitle, Parameters, Path, Renderer } from '@storybook/core/types'; +import type { CSFFile, ModuleExports, NormalizedComponentAnnotations } from '@storybook/core/types'; import { isExportStory } from '@storybook/csf'; + import { logger } from '@storybook/core/client-logger'; -import { normalizeStory } from './normalizeStory'; import { normalizeComponentAnnotations } from './normalizeComponentAnnotations'; -import type { CSFFile, ModuleExports, NormalizedComponentAnnotations } from '@storybook/core/types'; +import { normalizeStory } from './normalizeStory'; const checkGlobals = (parameters: Parameters) => { const { globals, globalTypes } = parameters; diff --git a/code/core/src/preview-api/modules/store/csf/stepRunners.test.ts b/code/core/src/preview-api/modules/store/csf/stepRunners.test.ts index d67055c05d6..aacfa0d4dd5 100644 --- a/code/core/src/preview-api/modules/store/csf/stepRunners.test.ts +++ b/code/core/src/preview-api/modules/store/csf/stepRunners.test.ts @@ -1,5 +1,7 @@ -import { describe, it, expect, vi } from 'vitest'; -import type { StoryContext, StepRunner } from '@storybook/core/types'; +import { describe, expect, it, vi } from 'vitest'; + +import type { StepRunner, StoryContext } from '@storybook/core/types'; + import { composeStepRunners } from './stepRunners'; describe('stepRunners', () => { diff --git a/code/core/src/preview-api/modules/store/decorators.test.ts b/code/core/src/preview-api/modules/store/decorators.test.ts index c61415afb79..ae3cd2bb8c3 100644 --- a/code/core/src/preview-api/modules/store/decorators.test.ts +++ b/code/core/src/preview-api/modules/store/decorators.test.ts @@ -1,4 +1,5 @@ -import { describe, it, expect } from 'vitest'; +import { describe, expect, it } from 'vitest'; + import type { Renderer, StoryContext } from '@storybook/core/types'; import { defaultDecorateStory } from './decorators'; diff --git a/code/core/src/preview-api/modules/store/filterArgTypes.ts b/code/core/src/preview-api/modules/store/filterArgTypes.ts index b77cc79d20e..274489a67cf 100644 --- a/code/core/src/preview-api/modules/store/filterArgTypes.ts +++ b/code/core/src/preview-api/modules/store/filterArgTypes.ts @@ -1,4 +1,5 @@ import type { StrictArgTypes } from '@storybook/core/types'; + import pickBy from 'lodash/pickBy.js'; export type PropDescriptor = string[] | RegExp; diff --git a/code/core/src/preview-api/modules/store/hooks.test.ts b/code/core/src/preview-api/modules/store/hooks.test.ts index 898367d24ba..cac2600ac72 100644 --- a/code/core/src/preview-api/modules/store/hooks.test.ts +++ b/code/core/src/preview-api/modules/store/hooks.test.ts @@ -1,29 +1,31 @@ -import { describe, beforeEach, it, expect, vi } from 'vitest'; +import { beforeEach, describe, expect, it, vi } from 'vitest'; + +import type { DecoratorFunction, StoryContext } from '@storybook/core/types'; + import { FORCE_RE_RENDER, - STORY_RENDERED, - UPDATE_STORY_ARGS, RESET_STORY_ARGS, + STORY_RENDERED, UPDATE_GLOBALS, + UPDATE_STORY_ARGS, } from '@storybook/core/core-events'; -import type { DecoratorFunction, StoryContext } from '@storybook/core/types'; + import { + HooksContext, addons, applyHooks, + useArgs, + useCallback, + useChannel, useEffect, + useGlobals, useMemo, - useCallback, + useParameter, + useReducer, useRef, useState, - useReducer, - useChannel, - useParameter, useStoryContext, - HooksContext, - useArgs, - useGlobals, } from '../addons'; - import { defaultDecorateStory } from './decorators'; vi.mock('@storybook/core/client-logger', () => ({ diff --git a/code/core/src/preview-api/modules/store/hooks.ts b/code/core/src/preview-api/modules/store/hooks.ts index 857845c9b3d..690e091775b 100644 --- a/code/core/src/preview-api/modules/store/hooks.ts +++ b/code/core/src/preview-api/modules/store/hooks.ts @@ -1,17 +1,17 @@ import { HooksContext, applyHooks, - useMemo, + useArgs, useCallback, + useChannel, + useEffect, + useGlobals, + useMemo, + useParameter, + useReducer, useRef, useState, - useReducer, - useEffect, - useChannel, useStoryContext, - useParameter, - useArgs, - useGlobals, } from '../addons'; export { diff --git a/code/core/src/preview-api/modules/store/inferArgTypes.test.ts b/code/core/src/preview-api/modules/store/inferArgTypes.test.ts index db7d168301b..fa374441a4e 100644 --- a/code/core/src/preview-api/modules/store/inferArgTypes.test.ts +++ b/code/core/src/preview-api/modules/store/inferArgTypes.test.ts @@ -1,4 +1,5 @@ -import { describe, it, expect, vi } from 'vitest'; +import { describe, expect, it, vi } from 'vitest'; + import { logger } from '@storybook/core/client-logger'; import { inferArgTypes } from './inferArgTypes'; diff --git a/code/core/src/preview-api/modules/store/inferArgTypes.ts b/code/core/src/preview-api/modules/store/inferArgTypes.ts index 79a74de659f..ea8b45b7560 100644 --- a/code/core/src/preview-api/modules/store/inferArgTypes.ts +++ b/code/core/src/preview-api/modules/store/inferArgTypes.ts @@ -1,8 +1,11 @@ +import type { ArgTypesEnhancer, Renderer, SBType } from '@storybook/core/types'; + +import { logger } from '@storybook/core/client-logger'; + import mapValues from 'lodash/mapValues.js'; import { dedent } from 'ts-dedent'; -import { logger } from '@storybook/core/client-logger'; + import { combineParameters } from './parameters'; -import type { ArgTypesEnhancer, Renderer, SBType } from '@storybook/core/types'; const inferType = (value: any, name: string, visited: Set): SBType => { const type = typeof value; diff --git a/code/core/src/preview-api/modules/store/inferControls.test.ts b/code/core/src/preview-api/modules/store/inferControls.test.ts index 13517843901..abe91702ec3 100644 --- a/code/core/src/preview-api/modules/store/inferControls.test.ts +++ b/code/core/src/preview-api/modules/store/inferControls.test.ts @@ -1,8 +1,10 @@ import type { MockInstance } from 'vitest'; -import { describe, beforeEach, afterEach, it, expect, vi } from 'vitest'; -import { logger } from '@storybook/core/client-logger'; +import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'; + import type { StoryContextForEnhancers } from '@storybook/core/types'; +import { logger } from '@storybook/core/client-logger'; + import { argTypesEnhancers } from './inferControls'; const getStoryContext = (overrides: any = {}): StoryContextForEnhancers => ({ diff --git a/code/core/src/preview-api/modules/store/inferControls.ts b/code/core/src/preview-api/modules/store/inferControls.ts index 2c0e2b93a9a..c823eb24fc9 100644 --- a/code/core/src/preview-api/modules/store/inferControls.ts +++ b/code/core/src/preview-api/modules/store/inferControls.ts @@ -1,7 +1,3 @@ -import mapValues from 'lodash/mapValues.js'; -import { logger } from '@storybook/core/client-logger'; -import { filterArgTypes } from './filterArgTypes'; -import { combineParameters } from './parameters'; import type { ArgTypesEnhancer, Renderer, @@ -9,6 +5,13 @@ import type { StrictInputType, } from '@storybook/core/types'; +import { logger } from '@storybook/core/client-logger'; + +import mapValues from 'lodash/mapValues.js'; + +import { filterArgTypes } from './filterArgTypes'; +import { combineParameters } from './parameters'; + export type ControlsMatchers = { date: RegExp; color: RegExp; diff --git a/code/core/src/preview-api/modules/store/parameters.test.ts b/code/core/src/preview-api/modules/store/parameters.test.ts index d408f641a0a..09905a6a1b6 100644 --- a/code/core/src/preview-api/modules/store/parameters.test.ts +++ b/code/core/src/preview-api/modules/store/parameters.test.ts @@ -1,4 +1,5 @@ -import { describe, it, expect } from 'vitest'; +import { describe, expect, it } from 'vitest'; + import { combineParameters } from './parameters'; describe('client-api.parameters', () => { diff --git a/code/core/src/preview-api/modules/store/parameters.ts b/code/core/src/preview-api/modules/store/parameters.ts index dc7b7045fe7..271ab5eb832 100644 --- a/code/core/src/preview-api/modules/store/parameters.ts +++ b/code/core/src/preview-api/modules/store/parameters.ts @@ -1,5 +1,6 @@ // Utilities for handling parameters import type { Parameters } from '@storybook/core/types'; + import isPlainObject from 'lodash/isPlainObject.js'; /** diff --git a/code/core/src/preview-api/modules/store/sortStories.ts b/code/core/src/preview-api/modules/store/sortStories.ts index e1a5db96a16..39cb86efcc2 100644 --- a/code/core/src/preview-api/modules/store/sortStories.ts +++ b/code/core/src/preview-api/modules/store/sortStories.ts @@ -1,5 +1,3 @@ -import { dedent } from 'ts-dedent'; -import { storySort } from './storySort'; import type { IndexEntry, StoryIndexEntry } from '@storybook/core/types'; import type { Addon_Comparator, @@ -7,9 +5,13 @@ import type { Addon_StorySortParameterV7, IndexEntryLegacy, } from '@storybook/core/types'; -import type { Path, Renderer, Parameters } from '@storybook/core/types'; +import type { Parameters, Path, Renderer } from '@storybook/core/types'; import type { PreparedStory } from '@storybook/core/types'; +import { dedent } from 'ts-dedent'; + +import { storySort } from './storySort'; + const sortStoriesCommon = ( stories: IndexEntry[], storySortParameter: Addon_StorySortParameterV7, diff --git a/code/core/src/preview-api/modules/store/storySort.test.ts b/code/core/src/preview-api/modules/store/storySort.test.ts index f41175aa156..104ad3bb1c8 100644 --- a/code/core/src/preview-api/modules/store/storySort.test.ts +++ b/code/core/src/preview-api/modules/store/storySort.test.ts @@ -1,4 +1,5 @@ -import { expect, describe, it } from 'vitest'; +import { describe, expect, it } from 'vitest'; + import type { StoryId, StoryIndexEntry } from '@storybook/core/types'; import { storySort } from './storySort'; diff --git a/code/core/src/preview-errors.ts b/code/core/src/preview-errors.ts index c1d070f7c10..a50183f79ac 100644 --- a/code/core/src/preview-errors.ts +++ b/code/core/src/preview-errors.ts @@ -1,4 +1,5 @@ import { dedent } from 'ts-dedent'; + import { StorybookError } from './storybook-error'; /** diff --git a/code/core/src/preview/globals/runtime.ts b/code/core/src/preview/globals/runtime.ts index a766e5cbac0..48418bc6de7 100644 --- a/code/core/src/preview/globals/runtime.ts +++ b/code/core/src/preview/globals/runtime.ts @@ -1,11 +1,11 @@ +import * as CHANNELS from '@storybook/core/channels'; +import * as TYPES from '@storybook/core/types'; import * as GLOBAL from '@storybook/global'; -import * as CHANNELS from '@storybook/core/channels'; import * as CLIENT_LOGGER from '@storybook/core/client-logger'; import * as CORE_EVENTS from '@storybook/core/core-events'; -import * as CORE_EVENTS_PREVIEW_ERRORS from '@storybook/core/preview-errors'; import * as PREVIEW_API from '@storybook/core/preview-api'; -import * as TYPES from '@storybook/core/types'; +import * as CORE_EVENTS_PREVIEW_ERRORS from '@storybook/core/preview-errors'; import type { globalsNameReferenceMap } from './globals'; diff --git a/code/core/src/preview/runtime.ts b/code/core/src/preview/runtime.ts index 67accbf9797..45ca3083ae6 100644 --- a/code/core/src/preview/runtime.ts +++ b/code/core/src/preview/runtime.ts @@ -1,8 +1,9 @@ -import { TELEMETRY_ERROR } from '@storybook/core/core-events'; import { global } from '@storybook/global'; + +import { TELEMETRY_ERROR } from '@storybook/core/core-events'; + import { globalPackages, globalsNameReferenceMap } from './globals/globals'; import { globalsNameValueMap } from './globals/runtime'; - import { prepareForTelemetry } from './utils'; // Apply all the globals diff --git a/code/core/src/preview/utils.ts b/code/core/src/preview/utils.ts index b3f77adc4e0..0b5e46ad91c 100644 --- a/code/core/src/preview/utils.ts +++ b/code/core/src/preview/utils.ts @@ -1,4 +1,5 @@ import { global } from '@storybook/global'; + import type { BrowserInfo } from 'browser-dtector'; import BrowserDetector from 'browser-dtector'; diff --git a/code/core/src/router/router.tsx b/code/core/src/router/router.tsx index f2e44437b00..00834debee3 100644 --- a/code/core/src/router/router.tsx +++ b/code/core/src/router/router.tsx @@ -1,10 +1,12 @@ -import { global } from '@storybook/global'; import React, { useCallback } from 'react'; -import type { ReactNode, ReactElement, ComponentProps } from 'react'; +import type { ComponentProps, ReactElement, ReactNode } from 'react'; + +import { global } from '@storybook/global'; import * as R from 'react-router-dom'; -import { queryFromString, parsePath, getMatch } from './utils'; + import type { LinkProps, NavigateOptions, RenderData } from './types'; +import { getMatch, parsePath, queryFromString } from './utils'; const { document } = global; diff --git a/code/core/src/router/types.ts b/code/core/src/router/types.ts index c601e68c290..a181dafcbec 100644 --- a/code/core/src/router/types.ts +++ b/code/core/src/router/types.ts @@ -1,5 +1,7 @@ -import type * as R from 'react-router-dom'; import type { ReactNode } from 'react'; + +import type * as R from 'react-router-dom'; + import type { StoryData } from './utils'; export interface Other extends StoryData { diff --git a/code/core/src/router/utils.test.ts b/code/core/src/router/utils.test.ts index 00df97fc4ca..784fc204d6d 100644 --- a/code/core/src/router/utils.test.ts +++ b/code/core/src/router/utils.test.ts @@ -1,5 +1,6 @@ -import { describe, it, expect, vi } from 'vitest'; -import { buildArgsParam, deepDiff, DEEPLY_EQUAL, getMatch, parsePath } from './utils'; +import { describe, expect, it, vi } from 'vitest'; + +import { DEEPLY_EQUAL, buildArgsParam, deepDiff, getMatch, parsePath } from './utils'; vi.mock('@storybook/core/client-logger', () => ({ once: { warn: vi.fn() }, diff --git a/code/core/src/router/utils.ts b/code/core/src/router/utils.ts index 57f3b3389b7..fac4ecee479 100644 --- a/code/core/src/router/utils.ts +++ b/code/core/src/router/utils.ts @@ -1,4 +1,5 @@ import { once } from '@storybook/core/client-logger'; + import { dequal as deepEqual } from 'dequal'; import isPlainObject from 'lodash/isPlainObject.js'; import memoize from 'memoizerific'; diff --git a/code/core/src/server-errors.ts b/code/core/src/server-errors.ts index 54cc3d3e0b0..23e203f27dd 100644 --- a/code/core/src/server-errors.ts +++ b/code/core/src/server-errors.ts @@ -1,5 +1,6 @@ import chalk from 'chalk'; import { dedent } from 'ts-dedent'; + import { StorybookError } from './storybook-error'; /** diff --git a/code/core/src/telemetry/anonymous-id.test.ts b/code/core/src/telemetry/anonymous-id.test.ts index 01caff1cd1f..6606f43cabc 100644 --- a/code/core/src/telemetry/anonymous-id.test.ts +++ b/code/core/src/telemetry/anonymous-id.test.ts @@ -1,4 +1,5 @@ -import { describe, it, expect } from 'vitest'; +import { describe, expect, it } from 'vitest'; + import { normalizeGitUrl } from './anonymous-id'; describe('normalizeGitUrl', () => { diff --git a/code/core/src/telemetry/anonymous-id.ts b/code/core/src/telemetry/anonymous-id.ts index 7af263c2f56..2748a2fd2a8 100644 --- a/code/core/src/telemetry/anonymous-id.ts +++ b/code/core/src/telemetry/anonymous-id.ts @@ -1,7 +1,9 @@ import path from 'node:path'; -import { execSync } from 'child_process'; + import { getProjectRoot } from '@storybook/core/common'; +import { execSync } from 'child_process'; + import { oneWayHash } from './one-way-hash'; export function normalizeGitUrl(rawUrl: string) { diff --git a/code/core/src/telemetry/event-cache.test.ts b/code/core/src/telemetry/event-cache.test.ts index 788fb5270c6..d7ffb38d0c5 100644 --- a/code/core/src/telemetry/event-cache.test.ts +++ b/code/core/src/telemetry/event-cache.test.ts @@ -1,4 +1,5 @@ -import { describe, it, expect } from 'vitest'; +import { describe, expect, it } from 'vitest'; + import { getPrecedingUpgrade } from './event-cache'; expect.addSnapshotSerializer({ diff --git a/code/core/src/telemetry/event-cache.ts b/code/core/src/telemetry/event-cache.ts index 144a083dff9..d6a0d688e62 100644 --- a/code/core/src/telemetry/event-cache.ts +++ b/code/core/src/telemetry/event-cache.ts @@ -1,4 +1,5 @@ import { cache } from '@storybook/core/common'; + import type { EventType } from './types'; interface UpgradeSummary { diff --git a/code/core/src/telemetry/get-chromatic-version.test.ts b/code/core/src/telemetry/get-chromatic-version.test.ts index 85627012c79..b99d48bc32c 100644 --- a/code/core/src/telemetry/get-chromatic-version.test.ts +++ b/code/core/src/telemetry/get-chromatic-version.test.ts @@ -1,4 +1,5 @@ -import { it, expect } from 'vitest'; +import { expect, it } from 'vitest'; + import { getChromaticVersionSpecifier } from './get-chromatic-version'; it('works for dependencies', () => { diff --git a/code/core/src/telemetry/get-framework-info.test.ts b/code/core/src/telemetry/get-framework-info.test.ts index 4bcd80f5c6b..6987c32ccc9 100644 --- a/code/core/src/telemetry/get-framework-info.test.ts +++ b/code/core/src/telemetry/get-framework-info.test.ts @@ -1,6 +1,9 @@ -import { describe, it, expect, vi } from 'vitest'; -import type { StorybookConfig } from '@storybook/core/types'; import path from 'node:path'; + +import { describe, expect, it, vi } from 'vitest'; + +import type { StorybookConfig } from '@storybook/core/types'; + import { getFrameworkInfo } from './get-framework-info'; import { getActualPackageJson } from './package-json'; diff --git a/code/core/src/telemetry/get-framework-info.ts b/code/core/src/telemetry/get-framework-info.ts index 162a9cad63f..995777e1b79 100644 --- a/code/core/src/telemetry/get-framework-info.ts +++ b/code/core/src/telemetry/get-framework-info.ts @@ -1,8 +1,10 @@ -import type { PackageJson, StorybookConfig } from '@storybook/core/types'; import path from 'node:path'; + import { frameworkPackages } from '@storybook/core/common'; -import { cleanPaths } from './sanitize'; +import type { PackageJson, StorybookConfig } from '@storybook/core/types'; + import { getActualPackageJson } from './package-json'; +import { cleanPaths } from './sanitize'; const knownRenderers = [ 'html', diff --git a/code/core/src/telemetry/get-monorepo-type.test.ts b/code/core/src/telemetry/get-monorepo-type.test.ts index 1a717d4b4fc..6c5366b8c1a 100644 --- a/code/core/src/telemetry/get-monorepo-type.test.ts +++ b/code/core/src/telemetry/get-monorepo-type.test.ts @@ -1,8 +1,10 @@ /* eslint-disable no-underscore-dangle */ -import { describe, it, expect, vi } from 'vitest'; -import * as fsExtra from 'fs-extra'; import path from 'node:path'; +import { describe, expect, it, vi } from 'vitest'; + +import * as fsExtra from 'fs-extra'; + import { getMonorepoType, monorepoConfigs } from './get-monorepo-type'; vi.mock('fs-extra', async () => import('../../../__mocks__/fs-extra')); diff --git a/code/core/src/telemetry/get-monorepo-type.ts b/code/core/src/telemetry/get-monorepo-type.ts index 33dfc9eea1a..0427da90247 100644 --- a/code/core/src/telemetry/get-monorepo-type.ts +++ b/code/core/src/telemetry/get-monorepo-type.ts @@ -1,7 +1,9 @@ -import { existsSync, readJsonSync } from 'fs-extra'; import path from 'node:path'; -import type { PackageJson } from '@storybook/core/types'; + import { getProjectRoot } from '@storybook/core/common'; +import type { PackageJson } from '@storybook/core/types'; + +import { existsSync, readJsonSync } from 'fs-extra'; export const monorepoConfigs = { Nx: 'nx.json', diff --git a/code/core/src/telemetry/get-portable-stories-usage.test.ts b/code/core/src/telemetry/get-portable-stories-usage.test.ts index b07eaec0a2e..1711e5d03d2 100644 --- a/code/core/src/telemetry/get-portable-stories-usage.test.ts +++ b/code/core/src/telemetry/get-portable-stories-usage.test.ts @@ -1,4 +1,4 @@ -import { describe, it, expect } from 'vitest'; +import { describe, expect, it } from 'vitest'; import { getPortableStoriesFileCountUncached } from './get-portable-stories-usage'; diff --git a/code/core/src/telemetry/index.ts b/code/core/src/telemetry/index.ts index d8286d0b753..82d3c0c1dac 100644 --- a/code/core/src/telemetry/index.ts +++ b/code/core/src/telemetry/index.ts @@ -1,9 +1,10 @@ import { logger } from '@storybook/core/node-logger'; -import type { EventType, Payload, Options, TelemetryData } from './types'; -import { getStorybookMetadata } from './storybook-metadata'; -import { sendTelemetry } from './telemetry'; + import { notify } from './notify'; import { sanitizeError } from './sanitize'; +import { getStorybookMetadata } from './storybook-metadata'; +import { sendTelemetry } from './telemetry'; +import type { EventType, Options, Payload, TelemetryData } from './types'; export { oneWayHash } from './one-way-hash'; diff --git a/code/core/src/telemetry/notify.ts b/code/core/src/telemetry/notify.ts index 97ebe63d861..171d48ae671 100644 --- a/code/core/src/telemetry/notify.ts +++ b/code/core/src/telemetry/notify.ts @@ -1,6 +1,7 @@ -import chalk from 'chalk'; import { cache } from '@storybook/core/common'; +import chalk from 'chalk'; + const TELEMETRY_KEY_NOTIFY_DATE = 'telemetry-notification-date'; const logger = console; diff --git a/code/core/src/telemetry/package-json.ts b/code/core/src/telemetry/package-json.ts index df61f0e71a4..99c8476b64c 100644 --- a/code/core/src/telemetry/package-json.ts +++ b/code/core/src/telemetry/package-json.ts @@ -1,6 +1,7 @@ -import { readJson } from 'fs-extra'; import path from 'node:path'; +import { readJson } from 'fs-extra'; + import type { Dependency } from './types'; export const getActualPackageVersions = async (packages: Record>) => { diff --git a/code/core/src/telemetry/sanitize.test.ts b/code/core/src/telemetry/sanitize.test.ts index 659ed647362..d5cac7d16f5 100644 --- a/code/core/src/telemetry/sanitize.test.ts +++ b/code/core/src/telemetry/sanitize.test.ts @@ -1,5 +1,6 @@ -import { describe, it, expect, vi } from 'vitest'; -import { sanitizeError, cleanPaths } from './sanitize'; +import { describe, expect, it, vi } from 'vitest'; + +import { cleanPaths, sanitizeError } from './sanitize'; describe(`Errors Helpers`, () => { describe(`sanitizeError`, () => { diff --git a/code/core/src/telemetry/session-id.test.ts b/code/core/src/telemetry/session-id.test.ts index 78313fefb30..cff48bfa6dd 100644 --- a/code/core/src/telemetry/session-id.test.ts +++ b/code/core/src/telemetry/session-id.test.ts @@ -1,8 +1,11 @@ import type { MockInstance } from 'vitest'; -import { describe, it, beforeEach, expect, vi } from 'vitest'; -import { nanoid } from 'nanoid'; +import { beforeEach, describe, expect, it, vi } from 'vitest'; + import { cache } from '@storybook/core/common'; -import { resetSessionIdForTest, getSessionId, SESSION_TIMEOUT } from './session-id'; + +import { nanoid } from 'nanoid'; + +import { SESSION_TIMEOUT, getSessionId, resetSessionIdForTest } from './session-id'; vi.mock('@storybook/core/common', async (importOriginal) => ({ ...(await importOriginal()), diff --git a/code/core/src/telemetry/session-id.ts b/code/core/src/telemetry/session-id.ts index 36a92fe7cdf..3029855c5ce 100644 --- a/code/core/src/telemetry/session-id.ts +++ b/code/core/src/telemetry/session-id.ts @@ -1,6 +1,7 @@ -import { nanoid } from 'nanoid'; import { cache } from '@storybook/core/common'; +import { nanoid } from 'nanoid'; + export const SESSION_TIMEOUT = 1000 * 60 * 60 * 2; // 2h interface Session { diff --git a/code/core/src/telemetry/storybook-metadata.test.ts b/code/core/src/telemetry/storybook-metadata.test.ts index 3476aaeff1c..06bf355c068 100644 --- a/code/core/src/telemetry/storybook-metadata.test.ts +++ b/code/core/src/telemetry/storybook-metadata.test.ts @@ -1,8 +1,10 @@ +import path from 'node:path'; + import type { MockInstance } from 'vitest'; -import { describe, beforeEach, afterEach, expect, vi, it } from 'vitest'; +import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'; + import type { PackageJson, StorybookConfig } from '@storybook/core/types'; -import path from 'node:path'; import { computeStorybookMetadata, metaFrameworks, sanitizeAddonName } from './storybook-metadata'; const packageJsonMock: PackageJson = { diff --git a/code/core/src/telemetry/storybook-metadata.ts b/code/core/src/telemetry/storybook-metadata.ts index aba11c72137..75804b813fc 100644 --- a/code/core/src/telemetry/storybook-metadata.ts +++ b/code/core/src/telemetry/storybook-metadata.ts @@ -1,21 +1,23 @@ -import { findPackage } from 'fd-package-json'; -import { detect, getNpmVersion } from 'detect-package-manager'; import { - loadMainConfig, - getStorybookInfo, - getStorybookConfiguration, getProjectRoot, + getStorybookConfiguration, + getStorybookInfo, + loadMainConfig, } from '@storybook/core/common'; -import type { StorybookConfig, PackageJson } from '@storybook/core/types'; +import type { PackageJson, StorybookConfig } from '@storybook/core/types'; + import { readConfig } from '@storybook/core/csf-tools'; -import type { StorybookMetadata, Dependency, StorybookAddon } from './types'; -import { getActualPackageVersion, getActualPackageVersions } from './package-json'; -import { getMonorepoType } from './get-monorepo-type'; -import { cleanPaths } from './sanitize'; -import { getFrameworkInfo } from './get-framework-info'; +import { detect, getNpmVersion } from 'detect-package-manager'; +import { findPackage } from 'fd-package-json'; + import { getChromaticVersionSpecifier } from './get-chromatic-version'; +import { getFrameworkInfo } from './get-framework-info'; +import { getMonorepoType } from './get-monorepo-type'; import { getPortableStoriesFileCount } from './get-portable-stories-usage'; +import { getActualPackageVersion, getActualPackageVersions } from './package-json'; +import { cleanPaths } from './sanitize'; +import type { Dependency, StorybookAddon, StorybookMetadata } from './types'; export const metaFrameworks = { next: 'Next', diff --git a/code/core/src/telemetry/telemetry.test.ts b/code/core/src/telemetry/telemetry.test.ts index 8b13b94dcf6..b5ff3fb4caa 100644 --- a/code/core/src/telemetry/telemetry.test.ts +++ b/code/core/src/telemetry/telemetry.test.ts @@ -1,7 +1,6 @@ -import { fetch } from './fetch'; - -import { beforeEach, it, expect, vi } from 'vitest'; +import { beforeEach, expect, it, vi } from 'vitest'; +import { fetch } from './fetch'; import { sendTelemetry } from './telemetry'; vi.mock('./fetch'); diff --git a/code/core/src/telemetry/telemetry.ts b/code/core/src/telemetry/telemetry.ts index 6b365520106..90b0eaa4d9d 100644 --- a/code/core/src/telemetry/telemetry.ts +++ b/code/core/src/telemetry/telemetry.ts @@ -1,13 +1,13 @@ /// - -import * as os from 'os'; -import { nanoid } from 'nanoid'; import retry from 'fetch-retry'; -import type { Options, TelemetryData } from './types'; +import { nanoid } from 'nanoid'; +import * as os from 'os'; + import { getAnonymousProjectId } from './anonymous-id'; import { set as saveToCache } from './event-cache'; -import { getSessionId } from './session-id'; import { fetch } from './fetch'; +import { getSessionId } from './session-id'; +import type { Options, TelemetryData } from './types'; const retryingFetch = retry(fetch); diff --git a/code/core/src/telemetry/types.ts b/code/core/src/telemetry/types.ts index 4809d83c6a4..699a8da6e83 100644 --- a/code/core/src/telemetry/types.ts +++ b/code/core/src/telemetry/types.ts @@ -1,4 +1,5 @@ import type { StorybookConfig, TypescriptOptions } from '@storybook/core/types'; + import type { PM } from 'detect-package-manager'; import type { MonorepoType } from './get-monorepo-type'; diff --git a/code/core/src/theming/convert.ts b/code/core/src/theming/convert.ts index 9765adc03d6..1336c029493 100644 --- a/code/core/src/theming/convert.ts +++ b/code/core/src/theming/convert.ts @@ -1,10 +1,11 @@ import { opacify } from 'polished'; -import { background, typography, color } from './base'; + +import { animation, easing } from './animation'; +import { background, color, typography } from './base'; +import { themes } from './create'; +import { chromeDark, chromeLight, create as createSyntax } from './modules/syntax'; import type { Color, StorybookTheme, ThemeVars, ThemeVarsColors } from './types'; -import { easing, animation } from './animation'; -import { create as createSyntax, chromeLight, chromeDark } from './modules/syntax'; import { getPreferredColorScheme } from './utils'; -import { themes } from './create'; const lightSyntaxColors = { green1: '#008000', diff --git a/code/core/src/theming/create.ts b/code/core/src/theming/create.ts index d28769b5eb0..b5f97a34aee 100644 --- a/code/core/src/theming/create.ts +++ b/code/core/src/theming/create.ts @@ -1,7 +1,6 @@ // This generates theme variables in the correct shape for the UI -import lightThemeVars from './themes/light'; import darkThemeVars from './themes/dark'; - +import lightThemeVars from './themes/light'; import type { ThemeVars, ThemeVarsPartial } from './types'; import { getPreferredColorScheme } from './utils'; diff --git a/code/core/src/theming/emotionAugmentation.d.ts b/code/core/src/theming/emotionAugmentation.d.ts index d5ceb8b427f..92cfd3ccf58 100644 --- a/code/core/src/theming/emotionAugmentation.d.ts +++ b/code/core/src/theming/emotionAugmentation.d.ts @@ -1,6 +1,5 @@ // this file is only actually used in development // for prod/dist bundles we are bundling Emotion into our package - import '@emotion/react'; declare module '@emotion/react' { diff --git a/code/core/src/theming/ensure.ts b/code/core/src/theming/ensure.ts index 6ee5298e45c..39e3ee7e9d0 100644 --- a/code/core/src/theming/ensure.ts +++ b/code/core/src/theming/ensure.ts @@ -3,9 +3,9 @@ import { logger } from '@storybook/core/client-logger'; import { deletedDiff } from 'deep-object-diff'; import { dedent } from 'ts-dedent'; -import light from './themes/light'; -import type { ThemeVars, StorybookTheme } from './types'; import { convert } from './convert'; +import light from './themes/light'; +import type { StorybookTheme, ThemeVars } from './types'; export const ensure = (input: ThemeVars): StorybookTheme => { if (!input) { diff --git a/code/core/src/theming/global.ts b/code/core/src/theming/global.ts index 499d59cb224..2f22bcb77e0 100644 --- a/code/core/src/theming/global.ts +++ b/code/core/src/theming/global.ts @@ -1,5 +1,6 @@ import memoize from 'memoizerific'; -import type { Color, Background, Typography } from './types'; + +import type { Background, Color, Typography } from './types'; type Value = string | number; interface Return { diff --git a/code/core/src/theming/index.ts b/code/core/src/theming/index.ts index c533e838780..8fa92ea794f 100644 --- a/code/core/src/theming/index.ts +++ b/code/core/src/theming/index.ts @@ -1,7 +1,7 @@ /// /// - import type { FunctionInterpolation, Interpolation } from '@emotion/react'; + import type { StorybookTheme } from './types'; export { default as styled } from '@emotion/styled'; diff --git a/code/core/src/theming/tests/convert.test.js b/code/core/src/theming/tests/convert.test.js index 80a2512cb4d..779bbd0349d 100644 --- a/code/core/src/theming/tests/convert.test.js +++ b/code/core/src/theming/tests/convert.test.js @@ -1,4 +1,5 @@ -import { describe, it, expect } from 'vitest'; +import { describe, expect, it } from 'vitest'; + import { convert } from '../convert'; import { create } from '../create'; import darkThemeVars from '../themes/dark'; diff --git a/code/core/src/theming/tests/create.test.js b/code/core/src/theming/tests/create.test.js index b5f037e0a2e..524a424e6df 100644 --- a/code/core/src/theming/tests/create.test.js +++ b/code/core/src/theming/tests/create.test.js @@ -1,4 +1,5 @@ -import { describe, it, expect } from 'vitest'; +import { describe, expect, it } from 'vitest'; + import { create } from '../create'; describe('create base', () => { diff --git a/code/core/src/theming/tests/util.test.js b/code/core/src/theming/tests/util.test.js index f3e38f694e8..c20fccd3041 100644 --- a/code/core/src/theming/tests/util.test.js +++ b/code/core/src/theming/tests/util.test.js @@ -1,7 +1,7 @@ // @vitest-environment happy-dom +import { describe, expect, it, vi } from 'vitest'; -import { describe, it, expect, vi } from 'vitest'; -import { lightenColor as lighten, darkenColor as darken, getPreferredColorScheme } from '../utils'; +import { darkenColor as darken, getPreferredColorScheme, lightenColor as lighten } from '../utils'; describe('utils', () => { it('should apply polished when valid arguments are passed', () => { diff --git a/code/core/src/theming/themes/light.ts b/code/core/src/theming/themes/light.ts index 75d83f1e740..a5bf4def7e9 100644 --- a/code/core/src/theming/themes/light.ts +++ b/code/core/src/theming/themes/light.ts @@ -1,4 +1,4 @@ -import { color, typography, background } from '../base'; +import { background, color, typography } from '../base'; import type { ThemeVars } from '../types'; const theme: ThemeVars = { diff --git a/code/core/src/theming/types.ts b/code/core/src/theming/types.ts index e7c2827792c..1f386bfebd8 100644 --- a/code/core/src/theming/types.ts +++ b/code/core/src/theming/types.ts @@ -1,6 +1,5 @@ -import type { easing, animation } from './animation'; - -import type { color, background, typography } from './base'; +import type { animation, easing } from './animation'; +import type { background, color, typography } from './base'; export interface ThemeVars extends ThemeVarsBase, ThemeVarsColors {} diff --git a/code/core/src/theming/utils.ts b/code/core/src/theming/utils.ts index 2f8cb1c8230..f51a4f3473a 100644 --- a/code/core/src/theming/utils.ts +++ b/code/core/src/theming/utils.ts @@ -1,8 +1,9 @@ -import { rgba, lighten, darken } from 'polished'; import { global } from '@storybook/global'; import { logger } from '@storybook/core/client-logger'; +import { darken, lighten, rgba } from 'polished'; + const { window: globalWindow } = global; export const mkColor = (color: string) => ({ color }); diff --git a/code/core/src/types/modules/addons.ts b/code/core/src/types/modules/addons.ts index cc9d90251c2..7dceb312ccc 100644 --- a/code/core/src/types/modules/addons.ts +++ b/code/core/src/types/modules/addons.ts @@ -1,6 +1,6 @@ /* eslint-disable @typescript-eslint/naming-convention */ - import type { FC, PropsWithChildren, ReactElement, ReactNode } from 'react'; + import type { RenderData as RouterData } from '../../router/types'; import type { ThemeVars } from '../../theming/types'; import type { API_SidebarOptions } from './api'; @@ -9,11 +9,11 @@ import type { ArgsStoryFn as ArgsStoryFnForFramework, DecoratorFunction as DecoratorFunctionForFramework, InputType, - Renderer, LegacyStoryFn as LegacyStoryFnForFramework, LoaderFunction as LoaderFunctionForFramework, Parameters, PartialStoryFn as PartialStoryFnForFramework, + Renderer, StoryContext as StoryContextForFramework, StoryFn as StoryFnForFramework, StoryId, diff --git a/code/core/src/types/modules/api-stories.ts b/code/core/src/types/modules/api-stories.ts index 90a6962c7d1..7bde00d74f7 100644 --- a/code/core/src/types/modules/api-stories.ts +++ b/code/core/src/types/modules/api-stories.ts @@ -1,6 +1,6 @@ /* eslint-disable @typescript-eslint/naming-convention */ import type { DocsOptions } from './core-common'; -import type { Args, ArgTypes, Parameters, ComponentTitle, StoryId, Path, Tag } from './csf'; +import type { ArgTypes, Args, ComponentTitle, Parameters, Path, StoryId, Tag } from './csf'; import type { IndexEntry } from './indexer'; export interface API_BaseEntry { diff --git a/code/core/src/types/modules/api.ts b/code/core/src/types/modules/api.ts index 86ba7bbd02d..b338fc6ace6 100644 --- a/code/core/src/types/modules/api.ts +++ b/code/core/src/types/modules/api.ts @@ -1,13 +1,13 @@ /* eslint-disable @typescript-eslint/naming-convention */ - import type { ReactElement } from 'react'; -import type { RenderData } from '../../router/types'; + import type { Channel } from '../../channels'; +import type { RenderData } from '../../router/types'; import type { ThemeVars } from '../../theming/types'; -import type { DocsOptions } from './core-common'; +import type { Addon_RenderOptions } from './addons'; import type { API_FilterFunction, API_HashEntry, API_IndexHash } from './api-stories'; import type { SetStoriesStory, SetStoriesStoryData } from './channelApi'; -import type { Addon_RenderOptions } from './addons'; +import type { DocsOptions } from './core-common'; import type { StoryIndex } from './indexer'; type OrString = T | (string & {}); diff --git a/code/core/src/types/modules/channelApi.ts b/code/core/src/types/modules/channelApi.ts index 6c4f160a083..6097b610854 100644 --- a/code/core/src/types/modules/channelApi.ts +++ b/code/core/src/types/modules/channelApi.ts @@ -1,13 +1,13 @@ import type { API_ViewMode } from './api'; import type { - Args, ArgTypes, + Args, ComponentId, + GlobalTypes, + Globals, Parameters, StoryId, StoryKind, - Globals, - GlobalTypes, } from './csf'; // The data received on the (legacy) `setStories` event diff --git a/code/core/src/types/modules/composedStory.ts b/code/core/src/types/modules/composedStory.ts index ade2c302a99..7a5df854ff3 100644 --- a/code/core/src/types/modules/composedStory.ts +++ b/code/core/src/types/modules/composedStory.ts @@ -1,5 +1,4 @@ /* eslint-disable @typescript-eslint/naming-convention */ - import type { ProjectAnnotations, Renderer, diff --git a/code/core/src/types/modules/core-common.ts b/code/core/src/types/modules/core-common.ts index e7ee49c6710..1939ea25db3 100644 --- a/code/core/src/types/modules/core-common.ts +++ b/code/core/src/types/modules/core-common.ts @@ -1,12 +1,12 @@ /* eslint-disable @typescript-eslint/naming-convention */ -import type { FileSystemCache } from 'file-system-cache'; -import type * as telejson from 'telejson'; import type { Router } from 'express'; +import type { FileSystemCache } from 'file-system-cache'; // should be node:http, but that caused the ui/manager to fail to build, might be able to switch this back once ui/manager is in the core import type { Server } from 'http'; +import type * as telejson from 'telejson'; import type { PackageJson as PackageJsonFromTypeFest } from 'type-fest'; -import type { StoriesEntry, Indexer } from './indexer'; +import type { Indexer, StoriesEntry } from './indexer'; /** * ⚠️ This file contains internal WIP types they MUST NOT be exported outside this package for now! diff --git a/code/core/src/types/modules/docs.ts b/code/core/src/types/modules/docs.ts index 9202ea64dcf..386301e523e 100644 --- a/code/core/src/types/modules/docs.ts +++ b/code/core/src/types/modules/docs.ts @@ -1,13 +1,14 @@ import type { Channel } from '@storybook/core/channels'; -import type { Renderer, StoryContext, StoryId, StoryName, Parameters } from './csf'; + +import type { Parameters, Renderer, StoryContext, StoryId, StoryName } from './csf'; import type { + CSFFile, ModuleExport, ModuleExports, - CSFFile, - PreparedStory, NormalizedProjectAnnotations, - RenderContext, PreparedMeta, + PreparedStory, + RenderContext, } from './story'; export type RenderContextCallbacks = Pick< diff --git a/code/core/src/types/modules/indexer.ts b/code/core/src/types/modules/indexer.ts index cafbd8f90b7..daf0ddb2a73 100644 --- a/code/core/src/types/modules/indexer.ts +++ b/code/core/src/types/modules/indexer.ts @@ -1,4 +1,4 @@ -import type { StoryId, ComponentTitle, StoryName, Parameters, Tag, Path } from './csf'; +import type { ComponentTitle, Parameters, Path, StoryId, StoryName, Tag } from './csf'; type ExportName = string; type MetaId = string; diff --git a/code/core/src/types/modules/story.ts b/code/core/src/types/modules/story.ts index 2cbd803e563..f8deb8c522f 100644 --- a/code/core/src/types/modules/story.ts +++ b/code/core/src/types/modules/story.ts @@ -1,13 +1,13 @@ import type { - Renderer, + BeforeAll, + Canvas, + CleanupCallback, ProjectAnnotations as CsfProjectAnnotations, DecoratorFunction, + Globals, LoaderFunction, - CleanupCallback, + Renderer, StepRunner, - Canvas, - Globals, - BeforeAll, } from '@storybook/csf'; import type { diff --git a/code/core/template/stories/argMapping.stories.ts b/code/core/template/stories/argMapping.stories.ts index 169b68de995..41575e93123 100644 --- a/code/core/template/stories/argMapping.stories.ts +++ b/code/core/template/stories/argMapping.stories.ts @@ -1,6 +1,6 @@ -import { global as globalThis } from '@storybook/global'; import type { PartialStoryFn, PlayFunctionContext, StoryContext } from '@storybook/core/types'; -import { within, expect } from '@storybook/test'; +import { global as globalThis } from '@storybook/global'; +import { expect, within } from '@storybook/test'; const arrows = { ArrowUp: { name: 'ArrowUp' }, diff --git a/code/core/template/stories/argTypes.stories.ts b/code/core/template/stories/argTypes.stories.ts index dd2a53bd68f..6ad69132449 100644 --- a/code/core/template/stories/argTypes.stories.ts +++ b/code/core/template/stories/argTypes.stories.ts @@ -1,5 +1,5 @@ -import { global as globalThis } from '@storybook/global'; import type { PartialStoryFn, PlayFunctionContext, StoryContext } from '@storybook/core/types'; +import { global as globalThis } from '@storybook/global'; import { expect, within } from '@storybook/test'; export default { diff --git a/code/core/template/stories/args.stories.ts b/code/core/template/stories/args.stories.ts index ebe10a49240..c5beee93860 100644 --- a/code/core/template/stories/args.stories.ts +++ b/code/core/template/stories/args.stories.ts @@ -1,13 +1,15 @@ -import { global as globalThis } from '@storybook/global'; import type { PartialStoryFn, PlayFunctionContext, StoryContext } from '@storybook/core/types'; -import { within, expect } from '@storybook/test'; -import pick from 'lodash/pick'; +import { global as globalThis } from '@storybook/global'; +import { expect, within } from '@storybook/test'; + import { + RESET_STORY_ARGS, STORY_ARGS_UPDATED, UPDATE_STORY_ARGS, - RESET_STORY_ARGS, } from '@storybook/core/core-events'; +import pick from 'lodash/pick'; + export default { component: globalThis.Components.Pre, args: { diff --git a/code/core/template/stories/autotitle.stories.ts b/code/core/template/stories/autotitle.stories.ts index 48997645b03..0a675faadec 100644 --- a/code/core/template/stories/autotitle.stories.ts +++ b/code/core/template/stories/autotitle.stories.ts @@ -1,6 +1,6 @@ +import type { PlayFunctionContext } from '@storybook/core/types'; import { global as globalThis } from '@storybook/global'; import { expect } from '@storybook/test'; -import type { PlayFunctionContext } from '@storybook/core/types'; export default { component: globalThis.Components.Pre, diff --git a/code/core/template/stories/component-play.stories.ts b/code/core/template/stories/component-play.stories.ts index cff3803d85b..0571cf37b32 100644 --- a/code/core/template/stories/component-play.stories.ts +++ b/code/core/template/stories/component-play.stories.ts @@ -1,6 +1,6 @@ -import { global as globalThis } from '@storybook/global'; import type { PartialStoryFn, PlayFunctionContext, StoryContext } from '@storybook/core/types'; -import { within, expect } from '@storybook/test'; +import { global as globalThis } from '@storybook/global'; +import { expect, within } from '@storybook/test'; export default { component: globalThis.Components.Pre, diff --git a/code/core/template/stories/decorators.stories.ts b/code/core/template/stories/decorators.stories.ts index df13c1088eb..e04fbf5e637 100644 --- a/code/core/template/stories/decorators.stories.ts +++ b/code/core/template/stories/decorators.stories.ts @@ -1,17 +1,18 @@ -import { global as globalThis } from '@storybook/global'; import type { ArgsStoryFn, PartialStoryFn, PlayFunctionContext, StoryContext, } from '@storybook/core/types'; -import { within, expect } from '@storybook/test'; -import { useEffect } from '@storybook/core/preview-api'; +import { global as globalThis } from '@storybook/global'; +import { expect, within } from '@storybook/test'; + import { + RESET_STORY_ARGS, STORY_ARGS_UPDATED, UPDATE_STORY_ARGS, - RESET_STORY_ARGS, } from '@storybook/core/core-events'; +import { useEffect } from '@storybook/core/preview-api'; export default { component: globalThis.Components.Pre, diff --git a/code/core/template/stories/globals.stories.ts b/code/core/template/stories/globals.stories.ts index 788e4dd53bd..84a0c86d2ee 100644 --- a/code/core/template/stories/globals.stories.ts +++ b/code/core/template/stories/globals.stories.ts @@ -1,6 +1,6 @@ -import { global as globalThis } from '@storybook/global'; import type { PartialStoryFn, PlayFunctionContext, StoryContext } from '@storybook/core/types'; -import { within, expect } from '@storybook/test'; +import { global as globalThis } from '@storybook/global'; +import { expect, within } from '@storybook/test'; export default { component: globalThis.Components.Pre, diff --git a/code/core/template/stories/hooks.stories.ts b/code/core/template/stories/hooks.stories.ts index a329903c364..ce145288f14 100644 --- a/code/core/template/stories/hooks.stories.ts +++ b/code/core/template/stories/hooks.stories.ts @@ -1,7 +1,8 @@ -import { global as globalThis } from '@storybook/global'; import type { PartialStoryFn, PlayFunctionContext } from '@storybook/core/types'; +import { global as globalThis } from '@storybook/global'; +import { userEvent, within } from '@storybook/test'; + import { useEffect, useState } from '@storybook/core/preview-api'; -import { within, userEvent } from '@storybook/test'; export default { component: globalThis.Components.Button, diff --git a/code/core/template/stories/indexer.stories.ts b/code/core/template/stories/indexer.stories.ts index 94c0d7789d0..5468e698d3c 100644 --- a/code/core/template/stories/indexer.stories.ts +++ b/code/core/template/stories/indexer.stories.ts @@ -1,6 +1,6 @@ -import { expect } from '@storybook/test'; -import { global as globalThis } from '@storybook/global'; import type { PlayFunctionContext } from '@storybook/core/types'; +import { global as globalThis } from '@storybook/global'; +import { expect } from '@storybook/test'; export default { component: globalThis.Components.Pre, diff --git a/code/core/template/stories/interleavedExports.stories.ts b/code/core/template/stories/interleavedExports.stories.ts index 60f88e7e6ab..25931c1fd09 100644 --- a/code/core/template/stories/interleavedExports.stories.ts +++ b/code/core/template/stories/interleavedExports.stories.ts @@ -1,5 +1,7 @@ import { global as globalThis } from '@storybook/global'; +import './import'; + export default { component: globalThis.Components.Pre, args: { text: 'Check that stories are processed OK' }, @@ -7,6 +9,4 @@ export default { export const Story1 = {}; -import './import'; - export const Story2 = {}; diff --git a/code/core/template/stories/loaders.stories.ts b/code/core/template/stories/loaders.stories.ts index 34ef7ebc84d..37a4ac62c0c 100644 --- a/code/core/template/stories/loaders.stories.ts +++ b/code/core/template/stories/loaders.stories.ts @@ -1,6 +1,6 @@ -import { global as globalThis } from '@storybook/global'; import type { PartialStoryFn, PlayFunctionContext, StoryContext } from '@storybook/core/types'; -import { within, expect } from '@storybook/test'; +import { global as globalThis } from '@storybook/global'; +import { expect, within } from '@storybook/test'; export default { component: globalThis.Components.Pre, diff --git a/code/core/template/stories/names.stories.ts b/code/core/template/stories/names.stories.ts index f81df30334d..b89304a63f5 100644 --- a/code/core/template/stories/names.stories.ts +++ b/code/core/template/stories/names.stories.ts @@ -1,6 +1,6 @@ +import type { PlayFunctionContext } from '@storybook/core/types'; import { global as globalThis } from '@storybook/global'; import { expect } from '@storybook/test'; -import type { PlayFunctionContext } from '@storybook/core/types'; export default { component: globalThis.Components.Pre, diff --git a/code/core/template/stories/parameters.stories.ts b/code/core/template/stories/parameters.stories.ts index 702f039e991..a4200444cd0 100644 --- a/code/core/template/stories/parameters.stories.ts +++ b/code/core/template/stories/parameters.stories.ts @@ -1,6 +1,6 @@ -import { global as globalThis } from '@storybook/global'; import type { PartialStoryFn, PlayFunctionContext, StoryContext } from '@storybook/core/types'; -import { within, expect } from '@storybook/test'; +import { global as globalThis } from '@storybook/global'; +import { expect, within } from '@storybook/test'; export default { component: globalThis.Components.Pre, diff --git a/code/core/template/stories/rendering.stories.ts b/code/core/template/stories/rendering.stories.ts index 0ca4976ec2c..7e03897e3c0 100644 --- a/code/core/template/stories/rendering.stories.ts +++ b/code/core/template/stories/rendering.stories.ts @@ -1,6 +1,7 @@ -import { global as globalThis } from '@storybook/global'; import type { PlayFunctionContext } from '@storybook/core/types'; -import { within, waitFor, expect } from '@storybook/test'; +import { global as globalThis } from '@storybook/global'; +import { expect, waitFor, within } from '@storybook/test'; + import { FORCE_REMOUNT, RESET_STORY_ARGS, diff --git a/code/core/template/stories/shortcuts.stories.ts b/code/core/template/stories/shortcuts.stories.ts index fa121866bab..b64df8252da 100644 --- a/code/core/template/stories/shortcuts.stories.ts +++ b/code/core/template/stories/shortcuts.stories.ts @@ -1,7 +1,8 @@ +import type { PlayFunctionContext } from '@storybook/csf'; import { global as globalThis } from '@storybook/global'; -import { userEvent, within, expect, fn } from '@storybook/test'; +import { expect, fn, userEvent, within } from '@storybook/test'; + import { PREVIEW_KEYDOWN } from '@storybook/core/core-events'; -import type { PlayFunctionContext } from '@storybook/csf'; export default { component: globalThis.Components.Form, diff --git a/code/core/template/stories/tags-add.stories.ts b/code/core/template/stories/tags-add.stories.ts index e7ed51cb512..9a04ebe25bd 100644 --- a/code/core/template/stories/tags-add.stories.ts +++ b/code/core/template/stories/tags-add.stories.ts @@ -1,6 +1,6 @@ -import { global as globalThis } from '@storybook/global'; import type { PartialStoryFn, PlayFunctionContext, StoryContext } from '@storybook/core/types'; -import { within, expect } from '@storybook/test'; +import { global as globalThis } from '@storybook/global'; +import { expect, within } from '@storybook/test'; export default { component: globalThis.Components.Pre, diff --git a/code/core/template/stories/tags-config.stories.ts b/code/core/template/stories/tags-config.stories.ts index 5a009e63213..9d7b70f8478 100644 --- a/code/core/template/stories/tags-config.stories.ts +++ b/code/core/template/stories/tags-config.stories.ts @@ -1,6 +1,6 @@ -import { global as globalThis } from '@storybook/global'; import type { PartialStoryFn, PlayFunctionContext, StoryContext } from '@storybook/core/types'; -import { within, expect } from '@storybook/test'; +import { global as globalThis } from '@storybook/global'; +import { expect, within } from '@storybook/test'; export default { component: globalThis.Components.Pre, diff --git a/code/core/template/stories/tags-remove.stories.ts b/code/core/template/stories/tags-remove.stories.ts index 949dab96d68..f0148e6fb5b 100644 --- a/code/core/template/stories/tags-remove.stories.ts +++ b/code/core/template/stories/tags-remove.stories.ts @@ -1,6 +1,6 @@ -import { global as globalThis } from '@storybook/global'; import type { PartialStoryFn, PlayFunctionContext, StoryContext } from '@storybook/core/types'; -import { within, expect } from '@storybook/test'; +import { global as globalThis } from '@storybook/global'; +import { expect, within } from '@storybook/test'; export default { component: globalThis.Components.Pre, diff --git a/code/core/template/stories/title.stories.ts b/code/core/template/stories/title.stories.ts index cd9eed6387b..deabd76f762 100644 --- a/code/core/template/stories/title.stories.ts +++ b/code/core/template/stories/title.stories.ts @@ -1,6 +1,6 @@ +import type { PlayFunctionContext } from '@storybook/core/types'; import { global as globalThis } from '@storybook/global'; import { expect } from '@storybook/test'; -import type { PlayFunctionContext } from '@storybook/core/types'; export default { component: globalThis.Components.Pre, diff --git a/code/core/template/stories/utils.mock.ts b/code/core/template/stories/utils.mock.ts index bd3955dc072..93a72d03a0e 100644 --- a/code/core/template/stories/utils.mock.ts +++ b/code/core/template/stories/utils.mock.ts @@ -1,4 +1,5 @@ import { fn } from '@storybook/test'; + import * as utils from './utils.ts'; export const foo = fn(utils.foo).mockName('foo'); diff --git a/code/core/vitest.config.ts b/code/core/vitest.config.ts index b546d2ba6a4..df83dd4dc88 100644 --- a/code/core/vitest.config.ts +++ b/code/core/vitest.config.ts @@ -1,4 +1,5 @@ import { defineConfig, mergeConfig } from 'vitest/config'; + import { vitestCommonConfig } from '../vitest.workspace'; export default mergeConfig(vitestCommonConfig, defineConfig({})); diff --git a/code/e2e-tests/addon-actions.spec.ts b/code/e2e-tests/addon-actions.spec.ts index a67aa8599ce..6c3fa98034e 100644 --- a/code/e2e-tests/addon-actions.spec.ts +++ b/code/e2e-tests/addon-actions.spec.ts @@ -1,5 +1,6 @@ -import { test, expect } from '@playwright/test'; +import { expect, test } from '@playwright/test'; import process from 'process'; + import { SbPage } from './util'; const storybookUrl = process.env.STORYBOOK_URL || 'http://localhost:8001'; diff --git a/code/e2e-tests/addon-backgrounds.spec.ts b/code/e2e-tests/addon-backgrounds.spec.ts index 2e0a4a0825b..d40d922f858 100644 --- a/code/e2e-tests/addon-backgrounds.spec.ts +++ b/code/e2e-tests/addon-backgrounds.spec.ts @@ -1,5 +1,6 @@ -import { test, expect } from '@playwright/test'; +import { expect, test } from '@playwright/test'; import process from 'process'; + import { SbPage } from './util'; const storybookUrl = process.env.STORYBOOK_URL || 'http://localhost:8001'; diff --git a/code/e2e-tests/addon-controls.spec.ts b/code/e2e-tests/addon-controls.spec.ts index 2c388d7ef59..6499ef6c074 100644 --- a/code/e2e-tests/addon-controls.spec.ts +++ b/code/e2e-tests/addon-controls.spec.ts @@ -1,5 +1,6 @@ -import { test, expect } from '@playwright/test'; +import { expect, test } from '@playwright/test'; import process from 'process'; + import { SbPage } from './util'; const storybookUrl = process.env.STORYBOOK_URL || 'http://localhost:8001'; diff --git a/code/e2e-tests/addon-docs.spec.ts b/code/e2e-tests/addon-docs.spec.ts index a269bec909d..cce2c23c608 100644 --- a/code/e2e-tests/addon-docs.spec.ts +++ b/code/e2e-tests/addon-docs.spec.ts @@ -1,6 +1,7 @@ -import { test, expect } from '@playwright/test'; +import { expect, test } from '@playwright/test'; import process from 'process'; import { dedent } from 'ts-dedent'; + import { SbPage } from './util'; const storybookUrl = process.env.STORYBOOK_URL || 'http://localhost:8001'; diff --git a/code/e2e-tests/addon-interactions.spec.ts b/code/e2e-tests/addon-interactions.spec.ts index 5c86f165830..6ef484c038c 100644 --- a/code/e2e-tests/addon-interactions.spec.ts +++ b/code/e2e-tests/addon-interactions.spec.ts @@ -1,5 +1,6 @@ -import { test, expect } from '@playwright/test'; +import { expect, test } from '@playwright/test'; import process from 'process'; + import { SbPage } from './util'; const storybookUrl = process.env.STORYBOOK_URL || 'http://localhost:8001'; diff --git a/code/e2e-tests/addon-toolbars.spec.ts b/code/e2e-tests/addon-toolbars.spec.ts index b642ebca796..493de06ce6f 100644 --- a/code/e2e-tests/addon-toolbars.spec.ts +++ b/code/e2e-tests/addon-toolbars.spec.ts @@ -1,5 +1,6 @@ -import { test, expect } from '@playwright/test'; +import { expect, test } from '@playwright/test'; import process from 'process'; + import { SbPage } from './util'; const storybookUrl = process.env.STORYBOOK_URL || 'http://localhost:8001'; diff --git a/code/e2e-tests/addon-viewport.spec.ts b/code/e2e-tests/addon-viewport.spec.ts index 64f8eb097df..cf53bc89432 100644 --- a/code/e2e-tests/addon-viewport.spec.ts +++ b/code/e2e-tests/addon-viewport.spec.ts @@ -1,5 +1,6 @@ -import { test, expect } from '@playwright/test'; +import { expect, test } from '@playwright/test'; import process from 'process'; + import { SbPage } from './util'; const storybookUrl = process.env.STORYBOOK_URL || 'http://localhost:8001'; diff --git a/code/e2e-tests/composition.spec.ts b/code/e2e-tests/composition.spec.ts index 2cc2e18f42c..25923a44791 100644 --- a/code/e2e-tests/composition.spec.ts +++ b/code/e2e-tests/composition.spec.ts @@ -1,4 +1,5 @@ -import { test, expect } from '@playwright/test'; +import { expect, test } from '@playwright/test'; + import { SbPage } from './util'; const storybookUrl = process.env.STORYBOOK_URL || 'http://localhost:6006'; diff --git a/code/e2e-tests/framework-nextjs.spec.ts b/code/e2e-tests/framework-nextjs.spec.ts index 0b98e542885..c88d723ce46 100644 --- a/code/e2e-tests/framework-nextjs.spec.ts +++ b/code/e2e-tests/framework-nextjs.spec.ts @@ -1,6 +1,7 @@ import type { Locator } from '@playwright/test'; -import { test, expect } from '@playwright/test'; +import { expect, test } from '@playwright/test'; import process from 'process'; + import { SbPage } from './util'; const storybookUrl = process.env.STORYBOOK_URL || 'http://localhost:6006'; diff --git a/code/e2e-tests/framework-svelte.spec.ts b/code/e2e-tests/framework-svelte.spec.ts index ba42745c617..a56bb2db5f0 100644 --- a/code/e2e-tests/framework-svelte.spec.ts +++ b/code/e2e-tests/framework-svelte.spec.ts @@ -1,5 +1,6 @@ -import { test, expect } from '@playwright/test'; +import { expect, test } from '@playwright/test'; import process from 'process'; + import { SbPage } from './util'; const storybookUrl = process.env.STORYBOOK_URL || 'http://localhost:6006'; diff --git a/code/e2e-tests/json-files.spec.ts b/code/e2e-tests/json-files.spec.ts index 8cfdc966f56..920b072c093 100644 --- a/code/e2e-tests/json-files.spec.ts +++ b/code/e2e-tests/json-files.spec.ts @@ -1,4 +1,4 @@ -import { test, expect } from '@playwright/test'; +import { expect, test } from '@playwright/test'; import process from 'process'; const storybookUrl = process.env.STORYBOOK_URL || 'http://localhost:8001'; diff --git a/code/e2e-tests/manager.spec.ts b/code/e2e-tests/manager.spec.ts index 7131e764e63..f863b1cddf2 100644 --- a/code/e2e-tests/manager.spec.ts +++ b/code/e2e-tests/manager.spec.ts @@ -1,5 +1,6 @@ -import { test, expect } from '@playwright/test'; +import { expect, test } from '@playwright/test'; import process from 'process'; + import { SbPage } from './util'; const storybookUrl = process.env.STORYBOOK_URL || 'http://localhost:8001'; diff --git a/code/e2e-tests/module-mocking.spec.ts b/code/e2e-tests/module-mocking.spec.ts index 8b6b43713b6..7a9048e6cc2 100644 --- a/code/e2e-tests/module-mocking.spec.ts +++ b/code/e2e-tests/module-mocking.spec.ts @@ -1,5 +1,6 @@ -import { test, expect } from '@playwright/test'; +import { expect, test } from '@playwright/test'; import process from 'process'; + import { SbPage } from './util'; const storybookUrl = process.env.STORYBOOK_URL || 'http://localhost:8001'; diff --git a/code/e2e-tests/navigation.spec.ts b/code/e2e-tests/navigation.spec.ts index c7ac1a1263d..16c72d6ffe6 100644 --- a/code/e2e-tests/navigation.spec.ts +++ b/code/e2e-tests/navigation.spec.ts @@ -1,5 +1,6 @@ -import { test, expect } from '@playwright/test'; +import { expect, test } from '@playwright/test'; import process from 'process'; + import { SbPage } from './util'; const storybookUrl = process.env.STORYBOOK_URL || 'http://localhost:8001'; diff --git a/code/e2e-tests/preview-api.spec.ts b/code/e2e-tests/preview-api.spec.ts index 9132a6de495..bb7b3dc2be9 100644 --- a/code/e2e-tests/preview-api.spec.ts +++ b/code/e2e-tests/preview-api.spec.ts @@ -1,5 +1,6 @@ -import { test, expect } from '@playwright/test'; +import { expect, test } from '@playwright/test'; import process from 'process'; + import { SbPage } from './util'; const storybookUrl = process.env.STORYBOOK_URL || 'http://localhost:8001'; diff --git a/code/e2e-tests/save-from-controls.spec.ts b/code/e2e-tests/save-from-controls.spec.ts index b70a1607595..0fbc24b3859 100644 --- a/code/e2e-tests/save-from-controls.spec.ts +++ b/code/e2e-tests/save-from-controls.spec.ts @@ -1,5 +1,6 @@ import { test } from '@playwright/test'; import process from 'process'; + import { SbPage } from './util'; const storybookUrl = process.env.STORYBOOK_URL || 'http://localhost:8001'; diff --git a/code/e2e-tests/storybook-hooks.spec.ts b/code/e2e-tests/storybook-hooks.spec.ts index 97e2926eb92..4dbb0ccf6f1 100644 --- a/code/e2e-tests/storybook-hooks.spec.ts +++ b/code/e2e-tests/storybook-hooks.spec.ts @@ -1,7 +1,9 @@ /* eslint-disable no-underscore-dangle */ -import { join } from 'node:path'; import { promises as fs } from 'node:fs'; +import { join } from 'node:path'; + import { test } from '@playwright/test'; + import { SbPage } from './util'; declare global { diff --git a/code/e2e-tests/tags.spec.ts b/code/e2e-tests/tags.spec.ts index 2e7202357a1..3148f166104 100644 --- a/code/e2e-tests/tags.spec.ts +++ b/code/e2e-tests/tags.spec.ts @@ -1,4 +1,5 @@ -import { test, expect } from '@playwright/test'; +import { expect, test } from '@playwright/test'; + import { SbPage } from './util'; const storybookUrl = process.env.STORYBOOK_URL || 'http://localhost:8001'; diff --git a/code/e2e-tests/util.ts b/code/e2e-tests/util.ts index 02ecc753b5f..c4433fa4e2a 100644 --- a/code/e2e-tests/util.ts +++ b/code/e2e-tests/util.ts @@ -1,6 +1,7 @@ +import { toId } from '@storybook/csf'; + import type { Page } from '@playwright/test'; import { expect } from '@playwright/test'; -import { toId } from '@storybook/csf'; export class SbPage { readonly page: Page; diff --git a/code/frameworks/angular/src/builders/build-storybook/index.spec.ts b/code/frameworks/angular/src/builders/build-storybook/index.spec.ts index 964b23fe73f..d02f927227c 100644 --- a/code/frameworks/angular/src/builders/build-storybook/index.spec.ts +++ b/code/frameworks/angular/src/builders/build-storybook/index.spec.ts @@ -1,9 +1,8 @@ -// eslint-disable-next-line import/no-extraneous-dependencies -import { vi, describe, beforeEach, expect, it, afterEach } from 'vitest'; import { Architect, createBuilder } from '@angular-devkit/architect'; import { TestingArchitectHost } from '@angular-devkit/architect/testing'; import { schema } from '@angular-devkit/core'; import * as path from 'path'; +import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'; const buildDevStandaloneMock = vi.fn(); const buildStaticStandaloneMock = vi.fn(); diff --git a/code/frameworks/angular/src/builders/build-storybook/index.ts b/code/frameworks/angular/src/builders/build-storybook/index.ts index 0a7cdb642dc..9b4e98ec35f 100644 --- a/code/frameworks/angular/src/builders/build-storybook/index.ts +++ b/code/frameworks/angular/src/builders/build-storybook/index.ts @@ -1,3 +1,8 @@ +import { getEnvConfig, versions } from 'storybook/internal/common'; +import { buildStaticStandalone, withTelemetry } from 'storybook/internal/core-server'; +import { addToGlobalContext } from 'storybook/internal/telemetry'; +import { CLIOptions } from 'storybook/internal/types'; + import { BuilderContext, BuilderHandlerFn, @@ -7,26 +12,21 @@ import { createBuilder, targetFromTargetString, } from '@angular-devkit/architect'; -import { JsonObject } from '@angular-devkit/core'; -import { from, of, throwError } from 'rxjs'; -import { catchError, map, mapTo, switchMap } from 'rxjs/operators'; -import { sync as findUpSync } from 'find-up'; -import { findPackageSync } from 'fd-package-json'; import { BrowserBuilderOptions, StylePreprocessorOptions } from '@angular-devkit/build-angular'; - -import { CLIOptions } from 'storybook/internal/types'; -import { getEnvConfig, versions } from 'storybook/internal/common'; -import { addToGlobalContext } from 'storybook/internal/telemetry'; - -import { buildStaticStandalone, withTelemetry } from 'storybook/internal/core-server'; import { AssetPattern, SourceMapUnion, StyleElement, } from '@angular-devkit/build-angular/src/builders/browser/schema'; -import { StandaloneOptions } from '../utils/standalone-options'; -import { runCompodoc } from '../utils/run-compodoc'; +import { JsonObject } from '@angular-devkit/core'; +import { findPackageSync } from 'fd-package-json'; +import { sync as findUpSync } from 'find-up'; +import { from, of, throwError } from 'rxjs'; +import { catchError, map, mapTo, switchMap } from 'rxjs/operators'; + import { errorSummary, printErrorDetails } from '../utils/error-handler'; +import { runCompodoc } from '../utils/run-compodoc'; +import { StandaloneOptions } from '../utils/standalone-options'; addToGlobalContext('cliVersion', versions.storybook); diff --git a/code/frameworks/angular/src/builders/start-storybook/index.spec.ts b/code/frameworks/angular/src/builders/start-storybook/index.spec.ts index 7df20b08c5f..e4948d77acf 100644 --- a/code/frameworks/angular/src/builders/start-storybook/index.spec.ts +++ b/code/frameworks/angular/src/builders/start-storybook/index.spec.ts @@ -1,9 +1,8 @@ -// eslint-disable-next-line import/no-extraneous-dependencies -import { vi, describe, expect, it, beforeEach, afterEach } from 'vitest'; import { Architect, createBuilder } from '@angular-devkit/architect'; import { TestingArchitectHost } from '@angular-devkit/architect/testing'; import { schema } from '@angular-devkit/core'; import * as path from 'path'; +import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'; const buildDevStandaloneMock = vi.fn(); const buildStaticStandaloneMock = vi.fn(); diff --git a/code/frameworks/angular/src/builders/start-storybook/index.ts b/code/frameworks/angular/src/builders/start-storybook/index.ts index 3cd9804cca4..701d3c1d683 100644 --- a/code/frameworks/angular/src/builders/start-storybook/index.ts +++ b/code/frameworks/angular/src/builders/start-storybook/index.ts @@ -1,3 +1,8 @@ +import { getEnvConfig, versions } from 'storybook/internal/common'; +import { buildDevStandalone, withTelemetry } from 'storybook/internal/core-server'; +import { addToGlobalContext } from 'storybook/internal/telemetry'; +import { CLIOptions } from 'storybook/internal/types'; + import { BuilderContext, BuilderHandlerFn, @@ -6,25 +11,21 @@ import { createBuilder, targetFromTargetString, } from '@angular-devkit/architect'; -import { JsonObject } from '@angular-devkit/core'; import { BrowserBuilderOptions, StylePreprocessorOptions } from '@angular-devkit/build-angular'; -import { from, Observable, of } from 'rxjs'; -import { map, switchMap, mapTo } from 'rxjs/operators'; -import { sync as findUpSync } from 'find-up'; -import { findPackageSync } from 'fd-package-json'; - -import { CLIOptions } from 'storybook/internal/types'; -import { getEnvConfig, versions } from 'storybook/internal/common'; -import { addToGlobalContext } from 'storybook/internal/telemetry'; -import { buildDevStandalone, withTelemetry } from 'storybook/internal/core-server'; import { AssetPattern, SourceMapUnion, StyleElement, } from '@angular-devkit/build-angular/src/builders/browser/schema'; -import { StandaloneOptions } from '../utils/standalone-options'; +import { JsonObject } from '@angular-devkit/core'; +import { findPackageSync } from 'fd-package-json'; +import { sync as findUpSync } from 'find-up'; +import { Observable, from, of } from 'rxjs'; +import { map, mapTo, switchMap } from 'rxjs/operators'; + +import { errorSummary, printErrorDetails } from '../utils/error-handler'; import { runCompodoc } from '../utils/run-compodoc'; -import { printErrorDetails, errorSummary } from '../utils/error-handler'; +import { StandaloneOptions } from '../utils/standalone-options'; addToGlobalContext('cliVersion', versions.storybook); diff --git a/code/frameworks/angular/src/builders/utils/error-handler.ts b/code/frameworks/angular/src/builders/utils/error-handler.ts index 58094633b25..af0aaddbfbb 100644 --- a/code/frameworks/angular/src/builders/utils/error-handler.ts +++ b/code/frameworks/angular/src/builders/utils/error-handler.ts @@ -1,4 +1,5 @@ import { logger, instance as npmLog } from 'storybook/internal/node-logger'; + import { dedent } from 'ts-dedent'; export const printErrorDetails = (error: any): void => { diff --git a/code/frameworks/angular/src/builders/utils/run-compodoc.spec.ts b/code/frameworks/angular/src/builders/utils/run-compodoc.spec.ts index 14cb43103e1..4391c939fc4 100644 --- a/code/frameworks/angular/src/builders/utils/run-compodoc.spec.ts +++ b/code/frameworks/angular/src/builders/utils/run-compodoc.spec.ts @@ -1,8 +1,7 @@ -// eslint-disable-next-line import/no-extraneous-dependencies -import { vi, describe, afterEach, it, expect } from 'vitest'; +import { BuilderContext } from '@angular-devkit/architect'; import { LoggerApi } from '@angular-devkit/core/src/logger'; import { take } from 'rxjs/operators'; -import { BuilderContext } from '@angular-devkit/architect'; +import { afterEach, describe, expect, it, vi } from 'vitest'; import { runCompodoc } from './run-compodoc'; diff --git a/code/frameworks/angular/src/builders/utils/run-compodoc.ts b/code/frameworks/angular/src/builders/utils/run-compodoc.ts index e826d4e5232..bf87f04e83b 100644 --- a/code/frameworks/angular/src/builders/utils/run-compodoc.ts +++ b/code/frameworks/angular/src/builders/utils/run-compodoc.ts @@ -1,7 +1,8 @@ +import { JsPackageManagerFactory } from 'storybook/internal/common'; + import { BuilderContext } from '@angular-devkit/architect'; -import { Observable } from 'rxjs'; import * as path from 'path'; -import { JsPackageManagerFactory } from 'storybook/internal/common'; +import { Observable } from 'rxjs'; const hasTsConfigArg = (args: string[]) => args.indexOf('-p') !== -1; const hasOutputArg = (args: string[]) => diff --git a/code/frameworks/angular/src/builders/utils/standalone-options.ts b/code/frameworks/angular/src/builders/utils/standalone-options.ts index e4cf6384193..f96f051b519 100644 --- a/code/frameworks/angular/src/builders/utils/standalone-options.ts +++ b/code/frameworks/angular/src/builders/utils/standalone-options.ts @@ -1,3 +1,5 @@ +import { BuilderOptions, CLIOptions, LoadOptions } from 'storybook/internal/types'; + import { BuilderContext } from '@angular-devkit/architect'; import { AssetPattern, @@ -5,7 +7,6 @@ import { StyleElement, StylePreprocessorOptions, } from '@angular-devkit/build-angular/src/builders/browser/schema'; -import { LoadOptions, CLIOptions, BuilderOptions } from 'storybook/internal/types'; export type StandaloneOptions = CLIOptions & LoadOptions & diff --git a/code/frameworks/angular/src/client/angular-beta/AbstractRenderer.ts b/code/frameworks/angular/src/client/angular-beta/AbstractRenderer.ts index 86de5a16897..780951207cd 100644 --- a/code/frameworks/angular/src/client/angular-beta/AbstractRenderer.ts +++ b/code/frameworks/angular/src/client/angular-beta/AbstractRenderer.ts @@ -1,14 +1,13 @@ -import { ApplicationRef, enableProdMode, NgModule } from '@angular/core'; +import { ApplicationRef, NgModule, enableProdMode } from '@angular/core'; import { bootstrapApplication } from '@angular/platform-browser'; - import { BehaviorSubject, Subject } from 'rxjs'; import { stringify } from 'telejson'; import { ICollection, StoryFnAngularReturnType } from '../types'; import { getApplication } from './StorybookModule'; import { storyPropsProvider } from './StorybookProvider'; -import { PropertyExtractor } from './utils/PropertyExtractor'; import { queueBootstrapping } from './utils/BootstrapQueue'; +import { PropertyExtractor } from './utils/PropertyExtractor'; type StoryRenderInfo = { storyFnAngular: StoryFnAngularReturnType; diff --git a/code/frameworks/angular/src/client/angular-beta/CanvasRenderer.ts b/code/frameworks/angular/src/client/angular-beta/CanvasRenderer.ts index eeb6812ddab..e9c3178a872 100644 --- a/code/frameworks/angular/src/client/angular-beta/CanvasRenderer.ts +++ b/code/frameworks/angular/src/client/angular-beta/CanvasRenderer.ts @@ -1,5 +1,5 @@ +import { Parameters, StoryFnAngularReturnType } from '../types'; import { AbstractRenderer } from './AbstractRenderer'; -import { StoryFnAngularReturnType, Parameters } from '../types'; export class CanvasRenderer extends AbstractRenderer { public async render(options: { diff --git a/code/frameworks/angular/src/client/angular-beta/ComputesTemplateFromComponent.test.ts b/code/frameworks/angular/src/client/angular-beta/ComputesTemplateFromComponent.test.ts index cc12902b5c0..669c4ceea20 100644 --- a/code/frameworks/angular/src/client/angular-beta/ComputesTemplateFromComponent.test.ts +++ b/code/frameworks/angular/src/client/angular-beta/ComputesTemplateFromComponent.test.ts @@ -681,10 +681,10 @@ describe('angular source decorator', () => { `a string literal with 'single quotes'`, 'a single quoted string with "double quotes"', "a double quoted string with 'single quotes'", - // eslint-disable-next-line prettier/prettier - 'a single quoted string with escaped \'single quotes\'', - // eslint-disable-next-line prettier/prettier - "a double quoted string with escaped \"double quotes\"", + + "a single quoted string with escaped 'single quotes'", + + 'a double quoted string with escaped "double quotes"', `a string literal with \'escaped single quotes\'`, @@ -717,10 +717,10 @@ describe('angular source decorator', () => { `a string literal with 'single quotes'`, 'a single quoted string with "double quotes"', "a double quoted string with 'single quotes'", - // eslint-disable-next-line prettier/prettier - 'a single quoted string with escaped \'single quotes\'', - // eslint-disable-next-line prettier/prettier - "a double quoted string with escaped \"double quotes\"", + + "a single quoted string with escaped 'single quotes'", + + 'a double quoted string with escaped "double quotes"', `a string literal with \'escaped single quotes\'`, diff --git a/code/frameworks/angular/src/client/angular-beta/ComputesTemplateFromComponent.ts b/code/frameworks/angular/src/client/angular-beta/ComputesTemplateFromComponent.ts index 9e0d38f1798..10e1781c1af 100644 --- a/code/frameworks/angular/src/client/angular-beta/ComputesTemplateFromComponent.ts +++ b/code/frameworks/angular/src/client/angular-beta/ComputesTemplateFromComponent.ts @@ -1,5 +1,7 @@ -import { Type } from '@angular/core'; import { ArgTypes } from 'storybook/internal/types'; + +import { Type } from '@angular/core'; + import { ICollection } from '../types'; import { ComponentInputsOutputs, diff --git a/code/frameworks/angular/src/client/angular-beta/DocsRenderer.ts b/code/frameworks/angular/src/client/angular-beta/DocsRenderer.ts index 0cff0259688..449a7f1af7e 100644 --- a/code/frameworks/angular/src/client/angular-beta/DocsRenderer.ts +++ b/code/frameworks/angular/src/client/angular-beta/DocsRenderer.ts @@ -1,9 +1,9 @@ -import { addons } from 'storybook/internal/preview-api'; import { DOCS_RENDERED, STORY_CHANGED } from 'storybook/internal/core-events'; +import { addons } from 'storybook/internal/preview-api'; -import { getNextStoryUID } from './utils/StoryUID'; +import { Parameters, StoryFnAngularReturnType } from '../types'; import { AbstractRenderer, STORY_UID_ATTRIBUTE } from './AbstractRenderer'; -import { StoryFnAngularReturnType, Parameters } from '../types'; +import { getNextStoryUID } from './utils/StoryUID'; export class DocsRenderer extends AbstractRenderer { public async render(options: { diff --git a/code/frameworks/angular/src/client/angular-beta/RendererFactory.ts b/code/frameworks/angular/src/client/angular-beta/RendererFactory.ts index d9be786f22f..afe1ce91000 100644 --- a/code/frameworks/angular/src/client/angular-beta/RendererFactory.ts +++ b/code/frameworks/angular/src/client/angular-beta/RendererFactory.ts @@ -1,6 +1,6 @@ import { AbstractRenderer } from './AbstractRenderer'; -import { DocsRenderer } from './DocsRenderer'; import { CanvasRenderer } from './CanvasRenderer'; +import { DocsRenderer } from './DocsRenderer'; type RenderType = 'canvas' | 'docs'; export class RendererFactory { diff --git a/code/frameworks/angular/src/client/angular-beta/StorybookModule.ts b/code/frameworks/angular/src/client/angular-beta/StorybookModule.ts index 3535a85c698..09f558b8e05 100644 --- a/code/frameworks/angular/src/client/angular-beta/StorybookModule.ts +++ b/code/frameworks/angular/src/client/angular-beta/StorybookModule.ts @@ -1,6 +1,6 @@ import { StoryFnAngularReturnType } from '../types'; -import { createStorybookWrapperComponent } from './StorybookWrapperComponent'; import { computesTemplateFromComponent } from './ComputesTemplateFromComponent'; +import { createStorybookWrapperComponent } from './StorybookWrapperComponent'; import { PropertyExtractor } from './utils/PropertyExtractor'; export const getApplication = ({ diff --git a/code/frameworks/angular/src/client/angular-beta/StorybookProvider.ts b/code/frameworks/angular/src/client/angular-beta/StorybookProvider.ts index f40ef8d96aa..d6c4e460302 100644 --- a/code/frameworks/angular/src/client/angular-beta/StorybookProvider.ts +++ b/code/frameworks/angular/src/client/angular-beta/StorybookProvider.ts @@ -1,5 +1,6 @@ -import { Provider, InjectionToken, NgZone } from '@angular/core'; -import { Subject, Subscriber, Observable } from 'rxjs'; +import { InjectionToken, NgZone, Provider } from '@angular/core'; +import { Observable, Subject, Subscriber } from 'rxjs'; + import { ICollection } from '../types'; export const STORY_PROPS = new InjectionToken>('STORY_PROPS'); diff --git a/code/frameworks/angular/src/client/angular-beta/utils/BootstrapQueue.test.ts b/code/frameworks/angular/src/client/angular-beta/utils/BootstrapQueue.test.ts index fe7fbd9ec86..3b580573471 100644 --- a/code/frameworks/angular/src/client/angular-beta/utils/BootstrapQueue.test.ts +++ b/code/frameworks/angular/src/client/angular-beta/utils/BootstrapQueue.test.ts @@ -1,7 +1,6 @@ // @vitest-environment happy-dom - import { Subject, lastValueFrom } from 'rxjs'; -import { vi, describe, it, expect, beforeEach, afterEach } from 'vitest'; +import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'; import { queueBootstrapping } from './BootstrapQueue'; diff --git a/code/frameworks/angular/src/client/angular-beta/utils/NgComponentAnalyzer.ts b/code/frameworks/angular/src/client/angular-beta/utils/NgComponentAnalyzer.ts index 09b1f63211c..3b4404b09b0 100644 --- a/code/frameworks/angular/src/client/angular-beta/utils/NgComponentAnalyzer.ts +++ b/code/frameworks/angular/src/client/angular-beta/utils/NgComponentAnalyzer.ts @@ -1,11 +1,11 @@ import { - Type, Component, Directive, Input, Output, Pipe, ɵReflectionCapabilities as ReflectionCapabilities, + Type, } from '@angular/core'; const reflectionCapabilities = new ReflectionCapabilities(); diff --git a/code/frameworks/angular/src/client/angular-beta/utils/NgModulesAnalyzer.test.ts b/code/frameworks/angular/src/client/angular-beta/utils/NgModulesAnalyzer.test.ts index 3299a6d4e29..1258638e266 100644 --- a/code/frameworks/angular/src/client/angular-beta/utils/NgModulesAnalyzer.test.ts +++ b/code/frameworks/angular/src/client/angular-beta/utils/NgModulesAnalyzer.test.ts @@ -1,5 +1,6 @@ import { Component, NgModule } from '@angular/core'; import { describe, expect, it } from 'vitest'; + import { isComponentAlreadyDeclared } from './NgModulesAnalyzer'; const FooComponent = Component({})(class {}); diff --git a/code/frameworks/angular/src/client/angular-beta/utils/PropertyExtractor.test.ts b/code/frameworks/angular/src/client/angular-beta/utils/PropertyExtractor.test.ts index b5256a08370..1a8c725287a 100644 --- a/code/frameworks/angular/src/client/angular-beta/utils/PropertyExtractor.test.ts +++ b/code/frameworks/angular/src/client/angular-beta/utils/PropertyExtractor.test.ts @@ -1,4 +1,3 @@ -import { vi, describe, it, expect } from 'vitest'; import { CommonModule } from '@angular/common'; import { Component, Directive, Injectable, InjectionToken, NgModule } from '@angular/core'; import { BrowserModule } from '@angular/platform-browser'; @@ -8,9 +7,11 @@ import { provideAnimations, provideNoopAnimations, } from '@angular/platform-browser/animations'; +import { describe, expect, it, vi } from 'vitest'; + import { NgModuleMetadata } from '../../types'; -import { PropertyExtractor } from './PropertyExtractor'; import { WithOfficialModule } from '../__testfixtures__/test.module'; +import { PropertyExtractor } from './PropertyExtractor'; const TEST_TOKEN = new InjectionToken('testToken'); const TestTokenProvider = { provide: TEST_TOKEN, useValue: 123 }; diff --git a/code/frameworks/angular/src/client/angular-beta/utils/PropertyExtractor.ts b/code/frameworks/angular/src/client/angular-beta/utils/PropertyExtractor.ts index 67bcd7b5e6d..309ba09ea9e 100644 --- a/code/frameworks/angular/src/client/angular-beta/utils/PropertyExtractor.ts +++ b/code/frameworks/angular/src/client/angular-beta/utils/PropertyExtractor.ts @@ -2,7 +2,6 @@ import { CommonModule } from '@angular/common'; import { Component, Directive, - importProvidersFrom, Injectable, InjectionToken, Input, @@ -11,6 +10,7 @@ import { Pipe, Provider, ɵReflectionCapabilities as ReflectionCapabilities, + importProvidersFrom, } from '@angular/core'; import { BrowserModule } from '@angular/platform-browser'; import { @@ -20,6 +20,7 @@ import { provideNoopAnimations, } from '@angular/platform-browser/animations'; import { dedent } from 'ts-dedent'; + import { NgModuleMetadata } from '../../types'; import { isComponentAlreadyDeclared } from './NgModulesAnalyzer'; diff --git a/code/frameworks/angular/src/client/argsToTemplate.test.ts b/code/frameworks/angular/src/client/argsToTemplate.test.ts index 29a51acb1b9..decb40bc3d5 100644 --- a/code/frameworks/angular/src/client/argsToTemplate.test.ts +++ b/code/frameworks/angular/src/client/argsToTemplate.test.ts @@ -1,5 +1,8 @@ import { describe, expect, it } from 'vitest'; -import { argsToTemplate, ArgsToTemplateOptions } from './argsToTemplate'; // adjust path + +import { ArgsToTemplateOptions, argsToTemplate } from './argsToTemplate'; + +// adjust path describe('argsToTemplate', () => { it('should correctly convert args to template string and exclude undefined values', () => { diff --git a/code/frameworks/angular/src/client/decorateStory.ts b/code/frameworks/angular/src/client/decorateStory.ts index 1085191e77b..c2ac022b4a7 100644 --- a/code/frameworks/angular/src/client/decorateStory.ts +++ b/code/frameworks/angular/src/client/decorateStory.ts @@ -1,7 +1,7 @@ -import { DecoratorFunction, LegacyStoryFn, StoryContext } from 'storybook/internal/types'; import { sanitizeStoryContextUpdate } from 'storybook/internal/preview-api'; -import { computesTemplateFromComponent } from './angular-beta/ComputesTemplateFromComponent'; +import { DecoratorFunction, LegacyStoryFn, StoryContext } from 'storybook/internal/types'; +import { computesTemplateFromComponent } from './angular-beta/ComputesTemplateFromComponent'; import { AngularRenderer } from './types'; export default function decorateStory( diff --git a/code/frameworks/angular/src/client/decorators.ts b/code/frameworks/angular/src/client/decorators.ts index b08278ebef4..d9b2917d27f 100644 --- a/code/frameworks/angular/src/client/decorators.ts +++ b/code/frameworks/angular/src/client/decorators.ts @@ -1,9 +1,11 @@ +import { DecoratorFunction, StoryContext } from 'storybook/internal/types'; + import { Type } from '@angular/core'; import { ApplicationConfig } from '@angular/platform-browser'; -import { DecoratorFunction, StoryContext } from 'storybook/internal/types'; + import { computesTemplateFromComponent } from './angular-beta/ComputesTemplateFromComponent'; import { isComponent } from './angular-beta/utils/NgComponentAnalyzer'; -import { ICollection, NgModuleMetadata, AngularRenderer } from './types'; +import { AngularRenderer, ICollection, NgModuleMetadata } from './types'; // We use `any` here as the default type rather than `Args` because we need something that is // castable to any component-specific args type when the user is being careful. diff --git a/code/frameworks/angular/src/client/docs/angular-properties.test.ts b/code/frameworks/angular/src/client/docs/angular-properties.test.ts index 6649e9a4496..143efa84938 100644 --- a/code/frameworks/angular/src/client/docs/angular-properties.test.ts +++ b/code/frameworks/angular/src/client/docs/angular-properties.test.ts @@ -1,5 +1,5 @@ -import path from 'path'; import fs from 'fs'; +import path from 'path'; import { describe, expect, it } from 'vitest'; // File hierarchy: __testfixtures__ / some-test-case / input.* diff --git a/code/frameworks/angular/src/client/docs/compodoc.test.ts b/code/frameworks/angular/src/client/docs/compodoc.test.ts index ff91661c8d2..6e8d220e7e9 100644 --- a/code/frameworks/angular/src/client/docs/compodoc.test.ts +++ b/code/frameworks/angular/src/client/docs/compodoc.test.ts @@ -1,4 +1,5 @@ -import { describe, it, expect } from 'vitest'; +import { describe, expect, it } from 'vitest'; + import { extractType, setCompodocJson } from './compodoc'; import { CompodocJson, Decorator } from './types'; diff --git a/code/frameworks/angular/src/client/docs/compodoc.ts b/code/frameworks/angular/src/client/docs/compodoc.ts index e71d1f463ad..076f591e8a8 100644 --- a/code/frameworks/angular/src/client/docs/compodoc.ts +++ b/code/frameworks/angular/src/client/docs/compodoc.ts @@ -1,19 +1,20 @@ /* eslint-disable no-underscore-dangle */ +import { logger } from 'storybook/internal/client-logger'; +import { ArgTypes, InputType, SBType } from 'storybook/internal/types'; + import { global } from '@storybook/global'; -import { InputType, ArgTypes, SBType } from 'storybook/internal/types'; -import { logger } from 'storybook/internal/client-logger'; import { Argument, Class, CompodocJson, Component, + Directive, Injectable, + JsDocTag, Method, Pipe, Property, - Directive, - JsDocTag, } from './types'; export const isMethod = (methodOrProp: Method | Property): methodOrProp is Method => { diff --git a/code/frameworks/angular/src/client/docs/config.ts b/code/frameworks/angular/src/client/docs/config.ts index 819e73e398e..30dc3f20f81 100644 --- a/code/frameworks/angular/src/client/docs/config.ts +++ b/code/frameworks/angular/src/client/docs/config.ts @@ -1,5 +1,6 @@ import { SourceType, enhanceArgTypes } from 'storybook/internal/docs-tools'; -import { Parameters, DecoratorFunction, ArgTypesEnhancer } from 'storybook/internal/types'; +import { ArgTypesEnhancer, DecoratorFunction, Parameters } from 'storybook/internal/types'; + import { extractArgTypes, extractComponentDescription } from './compodoc'; import { sourceDecorator } from './sourceDecorator'; diff --git a/code/frameworks/angular/src/client/docs/sourceDecorator.ts b/code/frameworks/angular/src/client/docs/sourceDecorator.ts index 31a84d27349..09296a2a4f1 100644 --- a/code/frameworks/angular/src/client/docs/sourceDecorator.ts +++ b/code/frameworks/angular/src/client/docs/sourceDecorator.ts @@ -1,8 +1,9 @@ +import { SNIPPET_RENDERED, SourceType } from 'storybook/internal/docs-tools'; import { addons, useEffect } from 'storybook/internal/preview-api'; import { PartialStoryFn } from 'storybook/internal/types'; -import { SNIPPET_RENDERED, SourceType } from 'storybook/internal/docs-tools'; -import { StoryContext, AngularRenderer } from '../types'; + import { computesTemplateSourceFromComponent } from '../../renderer'; +import { AngularRenderer, StoryContext } from '../types'; export const skipSourceRender = (context: StoryContext) => { const sourceParams = context?.parameters.docs?.source; diff --git a/code/frameworks/angular/src/client/globals.ts b/code/frameworks/angular/src/client/globals.ts index c16095858f1..cf5c3eca103 100644 --- a/code/frameworks/angular/src/client/globals.ts +++ b/code/frameworks/angular/src/client/globals.ts @@ -25,7 +25,9 @@ import { global } from '@storybook/global'; /** ************************************************************************************************* * Zone JS is required by Angular itself. */ -import 'zone.js'; // Included with Angular CLI. +import 'zone.js'; + +// Included with Angular CLI. /** ************************************************************************************************* * APPLICATION IMPORTS diff --git a/code/frameworks/angular/src/client/index.ts b/code/frameworks/angular/src/client/index.ts index 8f2e0a4172c..45388bcad32 100644 --- a/code/frameworks/angular/src/client/index.ts +++ b/code/frameworks/angular/src/client/index.ts @@ -1,5 +1,4 @@ /// - import './globals'; export * from './public-types'; diff --git a/code/frameworks/angular/src/client/render.ts b/code/frameworks/angular/src/client/render.ts index b3fc38c4da0..817d985bd16 100644 --- a/code/frameworks/angular/src/client/render.ts +++ b/code/frameworks/angular/src/client/render.ts @@ -1,10 +1,9 @@ -import '@angular/compiler'; - -import { RenderContext, ArgsStoryFn } from 'storybook/internal/types'; +import { ArgsStoryFn, RenderContext } from 'storybook/internal/types'; -import { AngularRenderer } from './types'; +import '@angular/compiler'; import { RendererFactory } from './angular-beta/RendererFactory'; +import { AngularRenderer } from './types'; export const rendererFactory = new RendererFactory(); diff --git a/code/frameworks/angular/src/client/types.ts b/code/frameworks/angular/src/client/types.ts index 33b4346c2d7..7f65f6245b2 100644 --- a/code/frameworks/angular/src/client/types.ts +++ b/code/frameworks/angular/src/client/types.ts @@ -1,11 +1,12 @@ -import { Provider, importProvidersFrom } from '@angular/core'; -import { ApplicationConfig } from '@angular/platform-browser'; import { Parameters as DefaultParameters, StoryContext as DefaultStoryContext, WebRenderer, } from 'storybook/internal/types'; +import { Provider, importProvidersFrom } from '@angular/core'; +import { ApplicationConfig } from '@angular/platform-browser'; + export interface NgModuleMetadata { /** * List of components, directives, and pipes that belong to your component. diff --git a/code/frameworks/angular/src/preset.ts b/code/frameworks/angular/src/preset.ts index 6d32ae831c4..31b86b2616d 100644 --- a/code/frameworks/angular/src/preset.ts +++ b/code/frameworks/angular/src/preset.ts @@ -1,7 +1,9 @@ -import { dirname, join } from 'path'; import { PresetProperty } from 'storybook/internal/types'; -import { StorybookConfig } from './types'; + +import { dirname, join } from 'path'; + import { StandaloneOptions } from './builders/utils/standalone-options'; +import { StorybookConfig } from './types'; const getAbsolutePath = (input: I): I => dirname(require.resolve(join(input, 'package.json'))) as any; diff --git a/code/frameworks/angular/src/server/angular-cli-webpack.d.ts b/code/frameworks/angular/src/server/angular-cli-webpack.d.ts index b2f79e4d963..ec5359716dd 100644 --- a/code/frameworks/angular/src/server/angular-cli-webpack.d.ts +++ b/code/frameworks/angular/src/server/angular-cli-webpack.d.ts @@ -1,5 +1,5 @@ -import { JsonObject } from '@angular-devkit/core'; import { BuilderContext } from '@angular-devkit/architect'; +import { JsonObject } from '@angular-devkit/core'; export declare function getWebpackConfig( baseConfig: any, diff --git a/code/frameworks/angular/src/server/framework-preset-angular-cli.ts b/code/frameworks/angular/src/server/framework-preset-angular-cli.ts index acadb3c8e1d..7f10d33ea5f 100644 --- a/code/frameworks/angular/src/server/framework-preset-angular-cli.ts +++ b/code/frameworks/angular/src/server/framework-preset-angular-cli.ts @@ -1,13 +1,14 @@ -import webpack from 'webpack'; import { logger } from 'storybook/internal/node-logger'; import { AngularLegacyBuildOptionsError } from 'storybook/internal/server-errors'; + import { BuilderContext, targetFromTargetString } from '@angular-devkit/architect'; -import { sync as findUpSync } from 'find-up'; import { JsonObject, logging } from '@angular-devkit/core'; +import { sync as findUpSync } from 'find-up'; +import webpack from 'webpack'; import { getWebpackConfig as getCustomWebpackConfig } from './angular-cli-webpack'; -import { moduleIsAvailable } from './utils/module-is-available'; import { PresetOptions } from './preset-options'; +import { moduleIsAvailable } from './utils/module-is-available'; export async function webpackFinal(baseConfig: webpack.Configuration, options: PresetOptions) { if (!moduleIsAvailable('@angular-devkit/build-angular')) { diff --git a/code/frameworks/angular/src/server/framework-preset-angular-docs.ts b/code/frameworks/angular/src/server/framework-preset-angular-docs.ts index 7f7c259ea4f..291e131547e 100644 --- a/code/frameworks/angular/src/server/framework-preset-angular-docs.ts +++ b/code/frameworks/angular/src/server/framework-preset-angular-docs.ts @@ -1,5 +1,5 @@ -import { PresetProperty } from 'storybook/internal/types'; import { hasDocsOrControls } from 'storybook/internal/docs-tools'; +import { PresetProperty } from 'storybook/internal/types'; export const previewAnnotations: PresetProperty<'previewAnnotations'> = (entry = [], options) => { if (!hasDocsOrControls(options)) return entry; diff --git a/code/frameworks/angular/src/server/framework-preset-angular-ivy.ts b/code/frameworks/angular/src/server/framework-preset-angular-ivy.ts index 31279d958ae..d5a509e2ff8 100644 --- a/code/frameworks/angular/src/server/framework-preset-angular-ivy.ts +++ b/code/frameworks/angular/src/server/framework-preset-angular-ivy.ts @@ -1,10 +1,11 @@ -import { Configuration } from 'webpack'; -import * as path from 'path'; import { Preset } from 'storybook/internal/types'; + import fs from 'fs'; +import * as path from 'path'; +import { Configuration } from 'webpack'; -import { PresetOptions } from './preset-options'; import { AngularOptions } from '../types'; +import { PresetOptions } from './preset-options'; /** * Source : https://github.com/angular/angular-cli/blob/ebccb5de4a455af813c5e82483db6af20666bdbd/packages/angular_devkit/build_angular/src/utils/load-esm.ts#L23 diff --git a/code/frameworks/angular/src/test-setup.ts b/code/frameworks/angular/src/test-setup.ts index d28182c6e7b..5ed15c667ba 100644 --- a/code/frameworks/angular/src/test-setup.ts +++ b/code/frameworks/angular/src/test-setup.ts @@ -1,10 +1,8 @@ -// eslint-disable-next-line import/no-extraneous-dependencies import '@analogjs/vite-plugin-angular/setup-vitest'; - +import { getTestBed } from '@angular/core/testing'; import { BrowserDynamicTestingModule, platformBrowserDynamicTesting, } from '@angular/platform-browser-dynamic/testing'; -import { getTestBed } from '@angular/core/testing'; getTestBed().initTestEnvironment(BrowserDynamicTestingModule, platformBrowserDynamicTesting()); diff --git a/code/frameworks/angular/src/types.ts b/code/frameworks/angular/src/types.ts index f2d1684b74b..c477fd756bb 100644 --- a/code/frameworks/angular/src/types.ts +++ b/code/frameworks/angular/src/types.ts @@ -1,13 +1,14 @@ +import { CompatibleString } from 'storybook/internal/types'; + import { - StorybookConfig as StorybookConfigBase, - TypescriptOptions as TypescriptOptionsReact, -} from '@storybook/core-webpack'; -import { - StorybookConfigWebpack, BuilderOptions, + StorybookConfigWebpack, TypescriptOptions as TypescriptOptionsBuilder, } from '@storybook/builder-webpack5'; -import { CompatibleString } from 'storybook/internal/types'; +import { + StorybookConfig as StorybookConfigBase, + TypescriptOptions as TypescriptOptionsReact, +} from '@storybook/core-webpack'; type FrameworkName = CompatibleString<'@storybook/angular'>; type BuilderName = CompatibleString<'@storybook/builder-webpack5'>; diff --git a/code/frameworks/angular/template/cli/button.stories.ts b/code/frameworks/angular/template/cli/button.stories.ts index 886310bed9a..dedeca1f2e9 100644 --- a/code/frameworks/angular/template/cli/button.stories.ts +++ b/code/frameworks/angular/template/cli/button.stories.ts @@ -1,5 +1,6 @@ import type { Meta, StoryObj } from '@storybook/angular'; import { fn } from '@storybook/test'; + import { ButtonComponent } from './button.component'; // More on how to set up stories at: https://storybook.js.org/docs/writing-stories diff --git a/code/frameworks/angular/template/cli/header.stories.ts b/code/frameworks/angular/template/cli/header.stories.ts index 3f3fb684e85..ea9b0894e4b 100644 --- a/code/frameworks/angular/template/cli/header.stories.ts +++ b/code/frameworks/angular/template/cli/header.stories.ts @@ -1,7 +1,7 @@ import type { Meta, StoryObj } from '@storybook/angular'; +import { fn } from '@storybook/test'; import { HeaderComponent } from './header.component'; -import { fn } from '@storybook/test'; const meta: Meta = { title: 'Example/Header', diff --git a/code/frameworks/angular/template/cli/page.stories.ts b/code/frameworks/angular/template/cli/page.stories.ts index 5a64cdbc2ef..74deedbfccc 100644 --- a/code/frameworks/angular/template/cli/page.stories.ts +++ b/code/frameworks/angular/template/cli/page.stories.ts @@ -1,5 +1,5 @@ import type { Meta, StoryObj } from '@storybook/angular'; -import { within, userEvent, expect } from '@storybook/test'; +import { expect, userEvent, within } from '@storybook/test'; import { PageComponent } from './page.component'; diff --git a/code/frameworks/angular/template/components/index.js b/code/frameworks/angular/template/components/index.js index 71aafe7204f..5e8c4f41362 100644 --- a/code/frameworks/angular/template/components/index.js +++ b/code/frameworks/angular/template/components/index.js @@ -1,8 +1,8 @@ import { global } from '@storybook/global'; import Button from './button.component'; +import Form from './form.component'; import Html from './html.component'; import Pre from './pre.component'; -import Form from './form.component'; global.Components = { Button, Html, Pre, Form }; diff --git a/code/frameworks/angular/template/stories/argTypes/doc-button/doc-button.stories.ts b/code/frameworks/angular/template/stories/argTypes/doc-button/doc-button.stories.ts index 11dc4d7cd32..329162d2a5c 100644 --- a/code/frameworks/angular/template/stories/argTypes/doc-button/doc-button.stories.ts +++ b/code/frameworks/angular/template/stories/argTypes/doc-button/doc-button.stories.ts @@ -1,4 +1,5 @@ import { Meta, StoryObj, argsToTemplate } from '@storybook/angular'; + import { DocButtonComponent } from './doc-button.component'; const meta: Meta> = { diff --git a/code/frameworks/angular/template/stories/argTypes/doc-directive/doc-directive.stories.ts b/code/frameworks/angular/template/stories/argTypes/doc-directive/doc-directive.stories.ts index e949d8e8825..77682191d2b 100644 --- a/code/frameworks/angular/template/stories/argTypes/doc-directive/doc-directive.stories.ts +++ b/code/frameworks/angular/template/stories/argTypes/doc-directive/doc-directive.stories.ts @@ -1,4 +1,5 @@ import { Meta, StoryObj } from '@storybook/angular'; + import { DocDirective } from './doc-directive.directive'; const meta: Meta = { diff --git a/code/frameworks/angular/template/stories/argTypes/doc-injectable/doc-injectable.stories.ts b/code/frameworks/angular/template/stories/argTypes/doc-injectable/doc-injectable.stories.ts index 7741bca9ba8..55c8b1fe86e 100644 --- a/code/frameworks/angular/template/stories/argTypes/doc-injectable/doc-injectable.stories.ts +++ b/code/frameworks/angular/template/stories/argTypes/doc-injectable/doc-injectable.stories.ts @@ -1,4 +1,5 @@ import { Meta, StoryObj } from '@storybook/angular'; + import { DocInjectableService } from './doc-injectable.service'; const meta: Meta = { diff --git a/code/frameworks/angular/template/stories/argTypes/doc-pipe/doc-pipe.stories.ts b/code/frameworks/angular/template/stories/argTypes/doc-pipe/doc-pipe.stories.ts index 018ab04a995..f3f90d3196b 100644 --- a/code/frameworks/angular/template/stories/argTypes/doc-pipe/doc-pipe.stories.ts +++ b/code/frameworks/angular/template/stories/argTypes/doc-pipe/doc-pipe.stories.ts @@ -1,4 +1,5 @@ import { Meta, StoryObj } from '@storybook/angular'; + import { DocPipe } from './doc-pipe.pipe'; const meta: Meta = { diff --git a/code/frameworks/angular/template/stories/basics/angular-forms/customControlValueAccessor/custom-cva-component.stories.ts b/code/frameworks/angular/template/stories/basics/angular-forms/customControlValueAccessor/custom-cva-component.stories.ts index 0396bae99ac..59a656bea1e 100644 --- a/code/frameworks/angular/template/stories/basics/angular-forms/customControlValueAccessor/custom-cva-component.stories.ts +++ b/code/frameworks/angular/template/stories/basics/angular-forms/customControlValueAccessor/custom-cva-component.stories.ts @@ -1,5 +1,7 @@ -import { FormsModule } from '@angular/forms'; import { Meta, StoryFn, StoryObj, moduleMetadata } from '@storybook/angular'; + +import { FormsModule } from '@angular/forms'; + import { CustomCvaComponent } from './custom-cva.component'; const meta: Meta = { diff --git a/code/frameworks/angular/template/stories/basics/component-with-complex-selectors/attribute-selectors.component.stories.ts b/code/frameworks/angular/template/stories/basics/component-with-complex-selectors/attribute-selectors.component.stories.ts index 73894b83b34..8b442fa011d 100644 --- a/code/frameworks/angular/template/stories/basics/component-with-complex-selectors/attribute-selectors.component.stories.ts +++ b/code/frameworks/angular/template/stories/basics/component-with-complex-selectors/attribute-selectors.component.stories.ts @@ -1,4 +1,5 @@ import { Meta, StoryObj } from '@storybook/angular'; + import { AttributeSelectorComponent } from './attribute-selector.component'; const meta: Meta = { diff --git a/code/frameworks/angular/template/stories/basics/component-with-enums/enums.component.stories.ts b/code/frameworks/angular/template/stories/basics/component-with-enums/enums.component.stories.ts index b79bd371baf..bf1b632b168 100644 --- a/code/frameworks/angular/template/stories/basics/component-with-enums/enums.component.stories.ts +++ b/code/frameworks/angular/template/stories/basics/component-with-enums/enums.component.stories.ts @@ -1,9 +1,10 @@ import { Meta, StoryObj } from '@storybook/angular'; + import { - EnumsComponent, EnumNumeric, EnumNumericInitial, EnumStringValues, + EnumsComponent, } from './enums.component'; const meta: Meta = { diff --git a/code/frameworks/angular/template/stories/basics/component-with-inheritance/base-button.stories.ts b/code/frameworks/angular/template/stories/basics/component-with-inheritance/base-button.stories.ts index 271e6a3fcc9..37e24d9cce9 100644 --- a/code/frameworks/angular/template/stories/basics/component-with-inheritance/base-button.stories.ts +++ b/code/frameworks/angular/template/stories/basics/component-with-inheritance/base-button.stories.ts @@ -1,4 +1,5 @@ import { Meta, StoryObj } from '@storybook/angular'; + import { BaseButtonComponent } from './base-button.component'; const meta: Meta = { diff --git a/code/frameworks/angular/template/stories/basics/component-with-inheritance/icon-button.stories.ts b/code/frameworks/angular/template/stories/basics/component-with-inheritance/icon-button.stories.ts index bb5c5fb02bc..cc94c6d6483 100644 --- a/code/frameworks/angular/template/stories/basics/component-with-inheritance/icon-button.stories.ts +++ b/code/frameworks/angular/template/stories/basics/component-with-inheritance/icon-button.stories.ts @@ -1,4 +1,5 @@ import { Meta, StoryObj } from '@storybook/angular'; + import { IconButtonComponent } from './icon-button.component'; const meta: Meta = { diff --git a/code/frameworks/angular/template/stories/basics/component-with-on-push/on-push.stories.ts b/code/frameworks/angular/template/stories/basics/component-with-on-push/on-push.stories.ts index cc672938a7f..9fca26be1e5 100644 --- a/code/frameworks/angular/template/stories/basics/component-with-on-push/on-push.stories.ts +++ b/code/frameworks/angular/template/stories/basics/component-with-on-push/on-push.stories.ts @@ -1,4 +1,5 @@ import { Meta, StoryObj } from '@storybook/angular'; + import { OnPushBoxComponent } from './on-push-box.component'; const meta: Meta = { diff --git a/code/frameworks/angular/template/stories/basics/component-with-provider/di.component.stories.ts b/code/frameworks/angular/template/stories/basics/component-with-provider/di.component.stories.ts index 381c272fb96..2311222c756 100644 --- a/code/frameworks/angular/template/stories/basics/component-with-provider/di.component.stories.ts +++ b/code/frameworks/angular/template/stories/basics/component-with-provider/di.component.stories.ts @@ -1,4 +1,5 @@ import { Args, Meta, StoryObj } from '@storybook/angular'; + import { DiComponent } from './di.component'; const meta: Meta = { diff --git a/code/frameworks/angular/template/stories/basics/component-with-style/styled.component.stories.ts b/code/frameworks/angular/template/stories/basics/component-with-style/styled.component.stories.ts index c0cd88c09bc..9047dcc9e4d 100644 --- a/code/frameworks/angular/template/stories/basics/component-with-style/styled.component.stories.ts +++ b/code/frameworks/angular/template/stories/basics/component-with-style/styled.component.stories.ts @@ -1,4 +1,5 @@ import { Meta, StoryObj } from '@storybook/angular'; + import { StyledComponent } from './styled.component'; const meta: Meta = { diff --git a/code/frameworks/angular/template/stories/basics/component-with-template/template.stories.ts b/code/frameworks/angular/template/stories/basics/component-with-template/template.stories.ts index 55639870f26..75b8c4e018e 100644 --- a/code/frameworks/angular/template/stories/basics/component-with-template/template.stories.ts +++ b/code/frameworks/angular/template/stories/basics/component-with-template/template.stories.ts @@ -1,4 +1,5 @@ import { Meta, StoryObj, argsToTemplate } from '@storybook/angular'; + import { Template } from './template.component'; const meta: Meta