diff --git a/code/__mocks__/lodash-es/add.js b/code/__mocks__/lodash-es/add.js index d12fc6f83033..b1faa7d3c99b 100644 --- a/code/__mocks__/lodash-es/add.js +++ b/code/__mocks__/lodash-es/add.js @@ -1,4 +1,4 @@ -function add(a, b) { +function add(_a, _b) { return 'mocked 3'; } diff --git a/code/addons/a11y/src/components/A11yContext.test.tsx b/code/addons/a11y/src/components/A11yContext.test.tsx index 4d72f31e2955..3496ba2cb100 100644 --- a/code/addons/a11y/src/components/A11yContext.test.tsx +++ b/code/addons/a11y/src/components/A11yContext.test.tsx @@ -13,8 +13,7 @@ import { import type { AxeResults } from 'axe-core'; import * as api from 'storybook/manager-api'; -import { EVENTS, UI_STATE_ID } from '../constants'; -import { RuleType } from '../types'; +import { EVENTS } from '../constants'; import { A11yContextProvider, useA11yContext } from './A11yContext'; vi.mock('storybook/manager-api'); diff --git a/code/addons/a11y/src/manager.tsx b/code/addons/a11y/src/manager.tsx index 32225dcaaf16..e21dfcd4d30d 100644 --- a/code/addons/a11y/src/manager.tsx +++ b/code/addons/a11y/src/manager.tsx @@ -47,7 +47,7 @@ const Title = () => { ); }; -addons.register(ADDON_ID, (api) => { +addons.register(ADDON_ID, (_api) => { addons.add(PANEL_ID, { title: '', type: types.TOOL, diff --git a/code/addons/docs/src/blocks/blocks/ArgTypes.stories.tsx b/code/addons/docs/src/blocks/blocks/ArgTypes.stories.tsx index 63f493e39313..f5037dec7cb8 100644 --- a/code/addons/docs/src/blocks/blocks/ArgTypes.stories.tsx +++ b/code/addons/docs/src/blocks/blocks/ArgTypes.stories.tsx @@ -1,5 +1,3 @@ -import React from 'react'; - import type { PlayFunctionContext } from 'storybook/internal/csf'; import type { Meta, StoryObj } from '@storybook/react-vite'; diff --git a/code/addons/docs/src/blocks/blocks/Controls.stories.tsx b/code/addons/docs/src/blocks/blocks/Controls.stories.tsx index b029147036a9..19d31b4715a0 100644 --- a/code/addons/docs/src/blocks/blocks/Controls.stories.tsx +++ b/code/addons/docs/src/blocks/blocks/Controls.stories.tsx @@ -1,5 +1,3 @@ -import React from 'react'; - import type { PlayFunctionContext } from 'storybook/internal/csf'; import type { Meta, StoryObj } from '@storybook/react-vite'; diff --git a/code/addons/docs/src/blocks/blocks/Description.stories.tsx b/code/addons/docs/src/blocks/blocks/Description.stories.tsx index 2e78949e756b..b35883bd644c 100644 --- a/code/addons/docs/src/blocks/blocks/Description.stories.tsx +++ b/code/addons/docs/src/blocks/blocks/Description.stories.tsx @@ -1,5 +1,3 @@ -import React from 'react'; - import type { Meta, StoryObj } from '@storybook/react-vite'; import { Button as ButtonComponent } from '../examples/Button'; diff --git a/code/addons/docs/src/blocks/blocks/Source.tsx b/code/addons/docs/src/blocks/blocks/Source.tsx index 135ec93cec76..3c5a69750de1 100644 --- a/code/addons/docs/src/blocks/blocks/Source.tsx +++ b/code/addons/docs/src/blocks/blocks/Source.tsx @@ -1,4 +1,4 @@ -import type { ComponentProps, FC } from 'react'; +import type { ComponentProps } from 'react'; import React, { useContext, useMemo } from 'react'; import { SourceType } from 'storybook/internal/docs-tools'; diff --git a/code/addons/docs/src/blocks/blocks/Story.stories.tsx b/code/addons/docs/src/blocks/blocks/Story.stories.tsx index 4df1e7f9878b..8daf935afe0f 100644 --- a/code/addons/docs/src/blocks/blocks/Story.stories.tsx +++ b/code/addons/docs/src/blocks/blocks/Story.stories.tsx @@ -1,5 +1,3 @@ -import React from 'react'; - import type { Meta, StoryObj } from '@storybook/react-vite'; import { expect, waitFor } from 'storybook/test'; diff --git a/code/addons/docs/src/blocks/blocks/mdx.tsx b/code/addons/docs/src/blocks/blocks/mdx.tsx index c54fc07ced62..5d626da478a7 100644 --- a/code/addons/docs/src/blocks/blocks/mdx.tsx +++ b/code/addons/docs/src/blocks/blocks/mdx.tsx @@ -1,4 +1,4 @@ -import type { FC, MouseEvent, PropsWithChildren, SyntheticEvent } from 'react'; +import type { FC, MouseEvent, PropsWithChildren } from 'react'; import React, { useContext } from 'react'; import type { SupportedLanguage } from 'storybook/internal/components'; @@ -77,7 +77,7 @@ const AnchorInPage: FC> = ({ hash, children { + onClick={() => { const id = hash.substring(1); const element = document.getElementById(id); if (element) { @@ -193,7 +193,7 @@ const HeaderWithOcticonAnchor: FC { + onClick={() => { const element = document.getElementById(id); if (element) { navigate(context, hash); diff --git a/code/addons/docs/src/blocks/components/ArgsTable/ArgControl.tsx b/code/addons/docs/src/blocks/components/ArgsTable/ArgControl.tsx index c9b6064f9099..dd6f7a997544 100644 --- a/code/addons/docs/src/blocks/components/ArgsTable/ArgControl.tsx +++ b/code/addons/docs/src/blocks/components/ArgsTable/ArgControl.tsx @@ -6,7 +6,6 @@ import { Link } from 'storybook/internal/components'; import { BooleanControl, ColorControl, - type ControlProps, DateControl, FilesControl, NumberControl, diff --git a/code/addons/docs/src/blocks/components/ArgsTable/SectionRow.tsx b/code/addons/docs/src/blocks/components/ArgsTable/SectionRow.tsx index 46c2d1c5dd89..1ee025e40ec9 100644 --- a/code/addons/docs/src/blocks/components/ArgsTable/SectionRow.tsx +++ b/code/addons/docs/src/blocks/components/ArgsTable/SectionRow.tsx @@ -44,11 +44,11 @@ const ExpanderIconRight = styled(ChevronRightIcon)(({ theme }) => ({ display: 'inline-block', })); -const FlexWrapper = styled.span(({ theme }) => ({ +const FlexWrapper = styled.span({ display: 'flex', lineHeight: '20px', alignItems: 'center', -})); +}); const Section = styled.td(({ theme }) => ({ position: 'relative', @@ -125,7 +125,7 @@ export const SectionRow: FC = ({ <> - setExpanded(!expanded)} tabIndex={0}> + setExpanded(!expanded)} tabIndex={0}> {helperText} @@ -135,7 +135,7 @@ export const SectionRow: FC = ({ setExpanded(!expanded)} + onClick={() => setExpanded(!expanded)} tabIndex={-1} style={{ outline: 'none' }} > diff --git a/code/addons/docs/src/blocks/components/ArgsTable/Skeleton.tsx b/code/addons/docs/src/blocks/components/ArgsTable/Skeleton.tsx index 5fe16ad49045..ed5a3df47a97 100644 --- a/code/addons/docs/src/blocks/components/ArgsTable/Skeleton.tsx +++ b/code/addons/docs/src/blocks/components/ArgsTable/Skeleton.tsx @@ -18,43 +18,41 @@ const Row = styled.div(({ theme }) => ({ }, })); -const Column = styled.div<{ position: 'first' | 'second' | 'third' | 'last' }>( - ({ position, theme }) => { - const baseStyles = { - display: 'flex', - flexDirection: 'column' as const, - gap: 5, - padding: '10px 15px', - alignItems: 'flex-start', - }; +const Column = styled.div<{ position: 'first' | 'second' | 'third' | 'last' }>(({ position }) => { + const baseStyles = { + display: 'flex', + flexDirection: 'column' as const, + gap: 5, + padding: '10px 15px', + alignItems: 'flex-start', + }; - // Apply the same column width ratios as the actual ArgsTable component - switch (position) { - case 'first': - return { - ...baseStyles, - width: '25%', - paddingLeft: 20, - }; - case 'second': - return { - ...baseStyles, - width: '35%', - }; - case 'third': - return { - ...baseStyles, - width: '15%', - }; - case 'last': - return { - ...baseStyles, - width: '25%', - paddingRight: 20, - }; - } + // Apply the same column width ratios as the actual ArgsTable component + switch (position) { + case 'first': + return { + ...baseStyles, + width: '25%', + paddingLeft: 20, + }; + case 'second': + return { + ...baseStyles, + width: '35%', + }; + case 'third': + return { + ...baseStyles, + width: '15%', + }; + case 'last': + return { + ...baseStyles, + width: '25%', + paddingRight: 20, + }; } -); +}); const SkeletonText = styled.div<{ width?: number | string; height?: number }>( ({ theme, width, height }) => ({ diff --git a/code/addons/docs/src/blocks/components/Preview.tsx b/code/addons/docs/src/blocks/components/Preview.tsx index b43dd30519a3..92e6669ba259 100644 --- a/code/addons/docs/src/blocks/components/Preview.tsx +++ b/code/addons/docs/src/blocks/components/Preview.tsx @@ -210,7 +210,7 @@ export const Preview: FC = ({ const context = useContext(DocsContext); - const copyToClipboard = useCallback(async (text: string) => { + const copyToClipboard = useCallback(async () => { const { createCopyToClipboardFunction } = await import('storybook/internal/components'); createCopyToClipboardFunction(); }, []); @@ -226,7 +226,7 @@ export const Preview: FC = ({ e.preventDefault(); if (additionalActionItems.filter((item) => item.title === 'Copied').length === 0) { - copyToClipboard(source?.props.code ?? '').then(() => { + copyToClipboard().then(() => { setAdditionalActionItems([ ...additionalActionItems, { diff --git a/code/addons/docs/src/blocks/controls/Color.tsx b/code/addons/docs/src/blocks/controls/Color.tsx index 578acfb90e75..50851ffbffc7 100644 --- a/code/addons/docs/src/blocks/controls/Color.tsx +++ b/code/addons/docs/src/blocks/controls/Color.tsx @@ -76,7 +76,7 @@ const Swatch = ({ value, style, ...props }: SwatchProps) => { return ; }; -const Input = styled(Form.Input)(({ theme, readOnly }) => ({ +const Input = styled(Form.Input)(({ theme }) => ({ width: '100%', paddingLeft: 30, paddingRight: 30, diff --git a/code/addons/docs/src/blocks/examples/ArgTypesParameters.tsx b/code/addons/docs/src/blocks/examples/ArgTypesParameters.tsx index 038b3ac85f18..09efbf9fca49 100644 --- a/code/addons/docs/src/blocks/examples/ArgTypesParameters.tsx +++ b/code/addons/docs/src/blocks/examples/ArgTypesParameters.tsx @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/no-unused-vars */ import React from 'react'; type PropTypes = { a?: string; b: string }; diff --git a/code/addons/docs/src/blocks/examples/Button.stories.tsx b/code/addons/docs/src/blocks/examples/Button.stories.tsx index 73f59e5188da..27e343eabdb7 100644 --- a/code/addons/docs/src/blocks/examples/Button.stories.tsx +++ b/code/addons/docs/src/blocks/examples/Button.stories.tsx @@ -101,7 +101,7 @@ export const Clicking: Story = { ); }, - play: async ({ canvasElement, id }) => { + play: async ({ canvasElement }) => { const canvas = within(canvasElement); const button = canvas.getByText('Increment'); diff --git a/code/addons/docs/src/blocks/examples/ControlsParameters.tsx b/code/addons/docs/src/blocks/examples/ControlsParameters.tsx index ceaa0801eb76..d775551576ff 100644 --- a/code/addons/docs/src/blocks/examples/ControlsParameters.tsx +++ b/code/addons/docs/src/blocks/examples/ControlsParameters.tsx @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/no-unused-vars */ import React from 'react'; type PropTypes = { a?: string; b: string }; diff --git a/code/addons/docs/src/preset.ts b/code/addons/docs/src/preset.ts index ce4cab9a4ffe..396095da5982 100644 --- a/code/addons/docs/src/preset.ts +++ b/code/addons/docs/src/preset.ts @@ -3,7 +3,6 @@ import { fileURLToPath } from 'node:url'; import { logger } from 'storybook/internal/node-logger'; import type { Options, PresetProperty, StorybookConfigRaw } from 'storybook/internal/types'; -import { type CsfEnricher } from 'storybook/internal/types'; import type { CsfPluginOptions } from '@storybook/csf-plugin'; diff --git a/code/addons/links/src/react/components/link.test.tsx b/code/addons/links/src/react/components/link.test.tsx index 77c6e2224a90..0a259c8a4939 100644 --- a/code/addons/links/src/react/components/link.test.tsx +++ b/code/addons/links/src/react/components/link.test.tsx @@ -58,6 +58,8 @@ describe('LinkTo', () => { expect(container.firstChild).toMatchInlineSnapshot(` link diff --git a/code/addons/links/src/react/components/link.tsx b/code/addons/links/src/react/components/link.tsx index 0f1f5d34718f..a8b374801230 100644 --- a/code/addons/links/src/react/components/link.tsx +++ b/code/addons/links/src/react/components/link.tsx @@ -75,7 +75,7 @@ export default class LinkTo extends PureComponent { }; render() { - const { kind, title = kind, story, name = story, children, ...rest } = this.props; + const { kind, story, children, ...rest } = this.props; const { href } = this.state; return ( diff --git a/code/addons/links/template/stories/linkto.stories.ts b/code/addons/links/template/stories/linkto.stories.ts index 6bf541639af4..ddf0d8661ea0 100644 --- a/code/addons/links/template/stories/linkto.stories.ts +++ b/code/addons/links/template/stories/linkto.stories.ts @@ -60,8 +60,8 @@ export const NormalizedTitleAndName = { export const Callback = { args: { onClick: linkTo( - (event: Event) => 'addons-links-linkto', - (event: Event) => 'target' + () => 'addons-links-linkto', + () => 'target' ), }, }; diff --git a/code/addons/onboarding/src/components/Confetti/Confetti.tsx b/code/addons/onboarding/src/components/Confetti/Confetti.tsx index 36972edc9022..b1b952135017 100644 --- a/code/addons/onboarding/src/components/Confetti/Confetti.tsx +++ b/code/addons/onboarding/src/components/Confetti/Confetti.tsx @@ -14,10 +14,9 @@ const Wrapper = styled.div({ }); export const Confetti = React.memo(function Confetti({ - timeToFade = 5000, colors = ['#CA90FF', '#FC521F', '#66BF3C', '#FF4785', '#FFAE00', '#1EA7FD'], ...confettiProps -}: ComponentProps & { timeToFade?: number }) { +}: ComponentProps) { return ( ({ Object.entries(themes) .filter(([themeName]) => themeName !== selectedThemeName) - .forEach(([themeName, className]) => { + .forEach(([_themeName, className]) => { const classes = classStringToArray(className); if (classes.length > 0) { parentElement.classList.remove(...classes); diff --git a/code/addons/vitest/src/components/TestProviderRender.stories.tsx b/code/addons/vitest/src/components/TestProviderRender.stories.tsx index bf7c6671f734..44bd4a025f18 100644 --- a/code/addons/vitest/src/components/TestProviderRender.stories.tsx +++ b/code/addons/vitest/src/components/TestProviderRender.stories.tsx @@ -1,7 +1,5 @@ import React from 'react'; -import { Addon_TypesEnum } from 'storybook/internal/types'; - import type { Meta, StoryObj } from '@storybook/react-vite'; import { ManagerContext, addons } from 'storybook/manager-api'; diff --git a/code/addons/vitest/src/node/boot-test-runner.test.ts b/code/addons/vitest/src/node/boot-test-runner.test.ts index 6257cc333553..6168fe94010f 100644 --- a/code/addons/vitest/src/node/boot-test-runner.test.ts +++ b/code/addons/vitest/src/node/boot-test-runner.test.ts @@ -10,8 +10,7 @@ import { execaNode } from 'execa'; import { storeOptions } from '../constants'; import { log } from '../logger'; -import type { StoreEvent } from '../types'; -import type { StoreState } from '../types'; +import type { StoreEvent, StoreState } from '../types'; import { killTestRunner, runTestRunner } from './boot-test-runner'; let stdout: (chunk: any) => void; @@ -47,27 +46,18 @@ vi.mock('../logger', () => ({ vi.mock('../../../../core/src/shared/utils/module', () => ({ importMetaResolve: vi .fn() - .mockImplementation( - (a) => 'file://' + join(__dirname, '..', '..', 'dist', 'node', 'vitest.js') - ), + .mockImplementation(() => 'file://' + join(__dirname, '..', '..', 'dist', 'node', 'vitest.js')), })); -let statusStoreSubscriber = vi.hoisted(() => undefined); -let testProviderStoreSubscriber = vi.hoisted(() => undefined); - vi.mock('storybook/internal/core-server', async (importOriginal) => { const actual = await importOriginal(); return { ...actual, internal_universalStatusStore: { - subscribe: (listener: any) => { - statusStoreSubscriber = listener; - }, + subscribe: () => {}, }, internal_universalTestProviderStore: { - subscribe: (listener: any) => { - testProviderStoreSubscriber = listener; - }, + subscribe: () => {}, }, }; }); diff --git a/code/addons/vitest/src/node/test-manager.test.ts b/code/addons/vitest/src/node/test-manager.test.ts index ff8cfa4e64df..cbc88d178a32 100644 --- a/code/addons/vitest/src/node/test-manager.test.ts +++ b/code/addons/vitest/src/node/test-manager.test.ts @@ -1,7 +1,6 @@ import { describe, expect, it, vi } from 'vitest'; import { createVitest as actualCreateVitest } from 'vitest/node'; -import { Channel, type ChannelTransport } from 'storybook/internal/channels'; import { experimental_MockUniversalStore } from 'storybook/internal/core-server'; import type { Options, @@ -50,8 +49,6 @@ vi.mock('vitest/node', async (importOriginal) => ({ const createVitest = vi.mocked(actualCreateVitest); -const transport = { setHandler: vi.fn(), send: vi.fn() } satisfies ChannelTransport; -const mockChannel = new Channel({ transport }); const mockStore = new experimental_MockUniversalStore( { ...storeOptions, diff --git a/code/addons/vitest/src/preset.ts b/code/addons/vitest/src/preset.ts index b96623a7ea27..441ce9843cf3 100644 --- a/code/addons/vitest/src/preset.ts +++ b/code/addons/vitest/src/preset.ts @@ -1,4 +1,3 @@ -import { readFileSync } from 'node:fs'; import { mkdir } from 'node:fs/promises'; import type { Channel } from 'storybook/internal/channels'; @@ -33,8 +32,7 @@ import { } from './constants'; import { log } from './logger'; import { runTestRunner } from './node/boot-test-runner'; -import type { CachedState, ErrorLike, StoreState } from './types'; -import type { StoreEvent } from './types'; +import type { CachedState, ErrorLike, StoreEvent, StoreState } from './types'; type Event = { type: 'test-discrepancy'; diff --git a/code/addons/vitest/src/types.ts b/code/addons/vitest/src/types.ts index b6eca96f92de..f4fe468c7a8c 100644 --- a/code/addons/vitest/src/types.ts +++ b/code/addons/vitest/src/types.ts @@ -1,6 +1,5 @@ import type { experimental_UniversalStore } from 'storybook/internal/core-server'; -import type { PreviewAnnotation, StoryId } from 'storybook/internal/types'; -import type { API_HashEntry } from 'storybook/internal/types'; +import type { API_HashEntry, PreviewAnnotation, StoryId } from 'storybook/internal/types'; export interface VitestError extends Error { VITEST_TEST_PATH?: string; diff --git a/code/addons/vitest/src/vitest-plugin/index.ts b/code/addons/vitest/src/vitest-plugin/index.ts index 4d4981797291..b78437f914f9 100644 --- a/code/addons/vitest/src/vitest-plugin/index.ts +++ b/code/addons/vitest/src/vitest-plugin/index.ts @@ -1,8 +1,7 @@ import { fileURLToPath } from 'node:url'; -import type { Plugin } from 'vitest/config'; +import type { Plugin, ViteUserConfig } from 'vitest/config'; import { mergeConfig } from 'vitest/config'; -import type { ViteUserConfig } from 'vitest/config'; import { DEFAULT_FILES_PATTERN, @@ -19,12 +18,11 @@ import { } from 'storybook/internal/core-server'; import { readConfig, vitestTransform } from 'storybook/internal/csf-tools'; import { MainFileMissingError } from 'storybook/internal/server-errors'; -import { telemetry } from 'storybook/internal/telemetry'; -import { oneWayHash } from 'storybook/internal/telemetry'; +import { oneWayHash, telemetry } from 'storybook/internal/telemetry'; import type { Presets } from 'storybook/internal/types'; import { match } from 'micromatch'; -import { dirname, join, normalize, relative, resolve, sep } from 'pathe'; +import { join, normalize, relative, resolve, sep } from 'pathe'; import picocolors from 'picocolors'; import sirv from 'sirv'; import { dedent } from 'ts-dedent'; diff --git a/code/addons/vitest/template/stories/unhandled-errors.stories.ts b/code/addons/vitest/template/stories/unhandled-errors.stories.ts index 01103f88847c..01a00af8c787 100644 --- a/code/addons/vitest/template/stories/unhandled-errors.stories.ts +++ b/code/addons/vitest/template/stories/unhandled-errors.stories.ts @@ -20,7 +20,7 @@ export default { export const Default = { play: async (context) => { - const { args, canvasElement } = context; + const { canvasElement } = context; const canvas = within(canvasElement); await userEvent.click(canvas.getByRole('button')); }, diff --git a/code/builders/builder-vite/src/codegen-importfn-script.test.ts b/code/builders/builder-vite/src/codegen-importfn-script.test.ts index da0e15c2154d..4902fd2b6906 100644 --- a/code/builders/builder-vite/src/codegen-importfn-script.test.ts +++ b/code/builders/builder-vite/src/codegen-importfn-script.test.ts @@ -41,7 +41,6 @@ describe('toImportFn', () => { }); it('should handle an empty array of stories', async () => { - const root = '/absolute/path'; const stories: string[] = []; const result = await toImportFn(stories); 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 9f3dea9bd835..9052b23642ee 100644 --- a/code/builders/builder-vite/src/plugins/code-generator-plugin.ts +++ b/code/builders/builder-vite/src/plugins/code-generator-plugin.ts @@ -91,7 +91,7 @@ export function codeGeneratorPlugin(options: Options): Plugin { return undefined; }, - async load(id, config) { + async load(id) { if (id === getResolvedVirtualModuleId(SB_VIRTUAL_FILES.VIRTUAL_STORIES_FILE)) { return generateImportFnScriptCode(options); } 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 242fb98ff3dc..d2f34317980b 100644 --- a/code/builders/builder-vite/src/plugins/external-globals-plugin.ts +++ b/code/builders/builder-vite/src/plugins/external-globals-plugin.ts @@ -75,7 +75,7 @@ export async function externalGlobalsPlugin(externals: Record): }; }, // Replace imports with variables destructured from global scope - async transform(code: string, id: string) { + async transform(code: string) { const globalsList = Object.keys(externals); if (globalsList.every((glob) => !code.includes(glob))) { 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 61dd70798232..109ca1622aa2 100644 --- a/code/builders/builder-vite/src/plugins/webpack-stats-plugin.ts +++ b/code/builders/builder-vite/src/plugins/webpack-stats-plugin.ts @@ -6,11 +6,7 @@ import type { BuilderStats } from 'storybook/internal/types'; import slash from 'slash'; import type { Plugin } from 'vite'; -import { - SB_VIRTUAL_FILES, - getOriginalVirtualModuleId, - getResolvedVirtualModuleId, -} from '../virtual-file-names'; +import { SB_VIRTUAL_FILES, getOriginalVirtualModuleId } from '../virtual-file-names'; /* * Reason, Module are copied from chromatic types 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 f4f243ebc439..040dc2256cc4 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,5 @@ import { describe, expect, it } from 'vitest'; -import { onlyWindows, skipWindows } from '../../../../vitest.helpers'; import { processPreviewAnnotation } from './process-preview-annotation'; describe('processPreviewAnnotation()', () => { diff --git a/code/builders/builder-vite/src/vite-config.ts b/code/builders/builder-vite/src/vite-config.ts index 7a4bd5b7d089..50852eb307c9 100644 --- a/code/builders/builder-vite/src/vite-config.ts +++ b/code/builders/builder-vite/src/vite-config.ts @@ -2,7 +2,6 @@ import { resolve } from 'node:path'; import { getBuilderOptions, - getFrameworkName, isPreservingSymlinks, resolvePathInStorybookCache, } from 'storybook/internal/common'; diff --git a/code/builders/builder-webpack5/src/index.ts b/code/builders/builder-webpack5/src/index.ts index 37b9ef963038..76a2e119f333 100644 --- a/code/builders/builder-webpack5/src/index.ts +++ b/code/builders/builder-webpack5/src/index.ts @@ -97,7 +97,7 @@ export const bail: WebpackBuilder['bail'] = async () => { reject(); } // we wait for the compiler to finish it's work, so it's command-line output doesn't interfere - return new Promise((res, rej) => { + return new Promise((res) => { if (process && compilation) { try { compilation.close(() => res()); @@ -248,7 +248,7 @@ function getWebpackStats({ config, stats }: { config: Configuration; stats: Stat * * I am sorry for making you read about generators today :') */ -const builder: BuilderFunction = async function* builderGeneratorFn({ startTime, options }) { +const builder: BuilderFunction = async function* builderGeneratorFn({ options }) { const webpackInstance = await executor.get(options); yield; const config = await getConfig(options); 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 0f28b883d413..89c63454762d 100644 --- a/code/builders/builder-webpack5/src/preview/iframe-webpack.config.ts +++ b/code/builders/builder-webpack5/src/preview/iframe-webpack.config.ts @@ -1,4 +1,4 @@ -import { dirname, join, resolve } from 'node:path'; +import { join, resolve } from 'node:path'; import { fileURLToPath } from 'node:url'; import { diff --git a/code/core/scripts/generate-source-files.ts b/code/core/scripts/generate-source-files.ts index 04d7fdb7f4cd..1cd23f7f0abe 100644 --- a/code/core/scripts/generate-source-files.ts +++ b/code/core/scripts/generate-source-files.ts @@ -1,5 +1,4 @@ -import { existsSync } from 'node:fs'; -import { mkdirSync } from 'node:fs'; +import { existsSync, mkdirSync } from 'node:fs'; import { readdir, realpath, writeFile } from 'node:fs/promises'; import os from 'node:os'; import { join } from 'node:path'; diff --git a/code/core/src/actions/addArgsHelpers.ts b/code/core/src/actions/addArgsHelpers.ts index 8e81aebb934e..14896bba134a 100644 --- a/code/core/src/actions/addArgsHelpers.ts +++ b/code/core/src/actions/addArgsHelpers.ts @@ -31,7 +31,7 @@ export const inferActionsFromArgTypesRegex: ArgsEnhancer = (context) = ([name]) => !!argTypesRegex.test(name) ); - return argTypesMatchingRegex.reduce((acc, [name, argType]) => { + return argTypesMatchingRegex.reduce((acc, [name]) => { if (isInInitialArgs(name, initialArgs)) { acc[name] = action(name, { implicit: true, id }); } @@ -50,7 +50,9 @@ export const addActionsFromArgTypes: ArgsEnhancer = (context) => { return {}; } - const argTypesWithAction = Object.entries(argTypes).filter(([name, argType]) => !!argType.action); + const argTypesWithAction = Object.entries(argTypes).filter( + ([_name, argType]) => !!argType.action + ); return argTypesWithAction.reduce((acc, [name, argType]) => { if (isInInitialArgs(name, initialArgs)) { diff --git a/code/core/src/babel/index.ts b/code/core/src/babel/index.ts index 8aee3d8f5391..0b5432f04821 100644 --- a/code/core/src/babel/index.ts +++ b/code/core/src/babel/index.ts @@ -1,3 +1,5 @@ +/* eslint-disable import/no-duplicates */ + /** * This entry is to ensure we use a single version of Babel across the codebase. This is to prevent * issues with multiple versions of Babel being used in the same project. It also prevents us from diff --git a/code/core/src/channels/index.test.ts b/code/core/src/channels/index.test.ts index 5bb7baf6babe..a6fb586cca85 100644 --- a/code/core/src/channels/index.test.ts +++ b/code/core/src/channels/index.test.ts @@ -14,7 +14,7 @@ const MockedWebsocket = vi.hoisted(() => { onclose: (event: any) => void; - constructor(url: string) { + constructor(_url: string) { this.onopen = vi.fn(); this.onmessage = vi.fn(); this.onerror = vi.fn(); diff --git a/code/core/src/channels/postmessage/index.ts b/code/core/src/channels/postmessage/index.ts index 49e0aa307475..59061921a227 100644 --- a/code/core/src/channels/postmessage/index.ts +++ b/code/core/src/channels/postmessage/index.ts @@ -86,7 +86,7 @@ export class PostMessageTransport implements ChannelTransport { allowUndefined, maxDepth, space, - }).filter(([k, v]) => typeof v !== 'undefined') + }).filter(([_k, v]) => typeof v !== 'undefined') ); const stringifyOptions = { diff --git a/code/core/src/cli/helpers.test.ts b/code/core/src/cli/helpers.test.ts index ca8e6f7c8638..0150b10eeaba 100644 --- a/code/core/src/cli/helpers.test.ts +++ b/code/core/src/cli/helpers.test.ts @@ -110,7 +110,7 @@ describe('Helpers', () => { ], ])('svelte %s => %s', async (svelteSpecifier, expectedAddonSpecifier) => { const packageManager = { - getInstalledVersion: async (pkg: string) => undefined, + getInstalledVersion: async () => undefined, getAllDependencies: () => ({ svelte: svelteSpecifier }), } as any as JsPackageManager; await expect(helpers.getVersionSafe(packageManager, 'svelte')).resolves.toBe( diff --git a/code/core/src/common/js-package-manager/BUNProxy.ts b/code/core/src/common/js-package-manager/BUNProxy.ts index 8a8b9dcbd6fc..17838012e073 100644 --- a/code/core/src/common/js-package-manager/BUNProxy.ts +++ b/code/core/src/common/js-package-manager/BUNProxy.ts @@ -1,4 +1,4 @@ -import { existsSync, readFileSync } from 'node:fs'; +import { readFileSync } from 'node:fs'; import { platform } from 'node:os'; import { join } from 'node:path'; diff --git a/code/core/src/common/js-package-manager/JsPackageManager.ts b/code/core/src/common/js-package-manager/JsPackageManager.ts index ed4bdd86157b..a8cc2721d689 100644 --- a/code/core/src/common/js-package-manager/JsPackageManager.ts +++ b/code/core/src/common/js-package-manager/JsPackageManager.ts @@ -663,7 +663,7 @@ export abstract class JsPackageManager { // If ignoreError is true, catch and suppress errors if (ignoreError) { - execaProcess.catch((err) => { + execaProcess.catch(() => { // Silently ignore errors when ignoreError is true }); } 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 cff5121f2c29..8e12ff26e27c 100644 --- a/code/core/src/common/js-package-manager/NPMProxy.test.ts +++ b/code/core/src/common/js-package-manager/NPMProxy.test.ts @@ -135,7 +135,7 @@ describe('NPM Proxy', () => { vi.spyOn(npmProxy, 'packageJsonPaths', 'get').mockImplementation(() => ['package.json']); const writePackageSpy = vi.spyOn(npmProxy, 'writePackageJson').mockImplementation(vi.fn()); - vi.spyOn(JsPackageManager, 'getPackageJson').mockImplementation((args) => { + vi.spyOn(JsPackageManager, 'getPackageJson').mockImplementation(() => { return { dependencies: {}, devDependencies: { 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 5c194a69c2df..74ca3de1f60a 100644 --- a/code/core/src/common/js-package-manager/PNPMProxy.test.ts +++ b/code/core/src/common/js-package-manager/PNPMProxy.test.ts @@ -77,7 +77,7 @@ describe('PNPM Proxy', () => { .mockResolvedValue({ stdout: '7.0.0' } as any); const writePackageSpy = vi.spyOn(pnpmProxy, 'writePackageJson').mockImplementation(vi.fn()); - vi.spyOn(JsPackageManager, 'getPackageJson').mockImplementation((args) => { + vi.spyOn(JsPackageManager, 'getPackageJson').mockImplementation(() => { return { dependencies: {}, devDependencies: { 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 edeb7b932a44..f55e1f3f8ce9 100644 --- a/code/core/src/common/js-package-manager/Yarn1Proxy.test.ts +++ b/code/core/src/common/js-package-manager/Yarn1Proxy.test.ts @@ -96,7 +96,7 @@ describe('Yarn 1 Proxy', () => { .mockReturnValue(Promise.resolve({ stdout: '7.0.0' }) as any); const writePackageSpy = vi.spyOn(yarn1Proxy, 'writePackageJson').mockImplementation(vi.fn()); - vi.spyOn(JsPackageManager, 'getPackageJson').mockImplementation((args) => { + vi.spyOn(JsPackageManager, 'getPackageJson').mockImplementation(() => { return { dependencies: {}, devDependencies: { diff --git a/code/core/src/common/presets.test.ts b/code/core/src/common/presets.test.ts index 3233734e1516..1813024729fe 100644 --- a/code/core/src/common/presets.test.ts +++ b/code/core/src/common/presets.test.ts @@ -1,5 +1,4 @@ -import path, { join, normalize, relative } from 'node:path'; -import { fileURLToPath, pathToFileURL, resolve } from 'node:url'; +import { normalize } from 'node:path'; import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'; @@ -304,8 +303,8 @@ describe('presets', () => { }); it('applies presets in chain', async () => { - const mockPresetFooExtendWebpack = vi.fn((...args: any[]) => ({})); - const mockPresetBarExtendWebpack = vi.fn((...args: any[]) => ({})); + const mockPresetFooExtendWebpack = vi.fn(() => ({})); + const mockPresetBarExtendWebpack = vi.fn(() => ({})); mockedResolveUtils.importModule.mockImplementation(async (path: string) => { if (path === 'preset-foo') { @@ -361,7 +360,7 @@ describe('presets', () => { it('allows for presets to export presets array', async () => { const input = {}; - const mockPresetBar = vi.fn((...args: any[]) => input); + const mockPresetBar = vi.fn(() => input); mockedResolveUtils.importModule.mockImplementation(async (path: string) => { if (path === 'preset-foo') { @@ -390,8 +389,8 @@ describe('presets', () => { const input = {}; const storybookOptions = { a: 1 }; const presetOptions = { b: 2 }; - const mockPresetBar = vi.fn((...args: any[]) => input); - const mockPresetFoo = vi.fn((...args: any[]) => ['preset-bar']); + const mockPresetBar = vi.fn(() => input); + const mockPresetFoo = vi.fn(() => ['preset-bar']); mockedResolveUtils.importModule.mockImplementation(async (path: string) => { if (path === 'preset-foo') { diff --git a/code/core/src/common/presets.ts b/code/core/src/common/presets.ts index cb340f7cb6b2..4a94a9c82b70 100644 --- a/code/core/src/common/presets.ts +++ b/code/core/src/common/presets.ts @@ -179,7 +179,7 @@ export async function loadPreset( if (isObject(contents)) { const { addons: addonsInput = [], presets: presetsInput = [], ...rest } = contents; - let filter = (i: PresetConfig) => { + let filter = (_i: PresetConfig) => { return true; }; 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 c104114f7e3f..2840c21e1561 100644 --- a/code/core/src/common/utils/__tests__/normalize-stories.test.ts +++ b/code/core/src/common/utils/__tests__/normalize-stories.test.ts @@ -28,7 +28,7 @@ vi.mock('node:fs', () => { }; return { - access: (path: string, mode: number, cb: (err?: Error) => void): void => undefined, + access: (): void => undefined, lstatSync: (path: string) => ({ isDirectory: () => !path.match(/\.[a-z]+$/), }), diff --git a/code/core/src/common/utils/formatter.ts b/code/core/src/common/utils/formatter.ts index 67114256ba7c..7199e385cde7 100644 --- a/code/core/src/common/utils/formatter.ts +++ b/code/core/src/common/utils/formatter.ts @@ -1,5 +1,5 @@ export async function getPrettier() { - return import('prettier').catch((e) => ({ + return import('prettier').catch(() => ({ resolveConfig: async () => null, format: (content: string) => content, })); diff --git a/code/core/src/common/utils/framework-to-renderer.ts b/code/core/src/common/utils/framework-to-renderer.ts index c5cbddda6d6f..73eea7aa1c83 100644 --- a/code/core/src/common/utils/framework-to-renderer.ts +++ b/code/core/src/common/utils/framework-to-renderer.ts @@ -1,5 +1,4 @@ -import type { SupportedRenderers } from 'storybook/internal/types'; -import type { SupportedFrameworks } from 'storybook/internal/types'; +import type { SupportedFrameworks, SupportedRenderers } from 'storybook/internal/types'; export const frameworkToRenderer: Record< SupportedFrameworks | SupportedRenderers, diff --git a/code/core/src/common/utils/get-storybook-info.ts b/code/core/src/common/utils/get-storybook-info.ts index 3cf0639721e5..1b424e507dc6 100644 --- a/code/core/src/common/utils/get-storybook-info.ts +++ b/code/core/src/common/utils/get-storybook-info.ts @@ -1,8 +1,11 @@ import { existsSync, readFileSync } from 'node:fs'; import { dirname, join } from 'node:path'; -import type { SupportedFrameworks } from 'storybook/internal/types'; -import type { CoreCommon_StorybookInfo, PackageJson } from 'storybook/internal/types'; +import type { + CoreCommon_StorybookInfo, + PackageJson, + SupportedFrameworks, +} from 'storybook/internal/types'; import { JsPackageManager } from '../js-package-manager/JsPackageManager'; import { getStorybookConfiguration } from './get-storybook-configuration'; diff --git a/code/core/src/component-testing/components/Subnav.stories.tsx b/code/core/src/component-testing/components/Subnav.stories.tsx index dd5dd6151125..ba8f97c92655 100644 --- a/code/core/src/component-testing/components/Subnav.stories.tsx +++ b/code/core/src/component-testing/components/Subnav.stories.tsx @@ -1,5 +1,3 @@ -import React from 'react'; - import { action } from 'storybook/actions'; import { Subnav } from './Subnav'; diff --git a/code/core/src/components/components/tabs/tabs.stories.tsx b/code/core/src/components/components/tabs/tabs.stories.tsx index a69f8d735d8c..1742e0a8d604 100644 --- a/code/core/src/components/components/tabs/tabs.stories.tsx +++ b/code/core/src/components/components/tabs/tabs.stories.tsx @@ -5,8 +5,16 @@ import { BottomBarIcon, CloseIcon } from '@storybook/icons'; import type { Meta, StoryObj } from '@storybook/react-vite'; import { action } from 'storybook/actions'; -import { expect, spyOn } from 'storybook/test'; -import { findByText, fireEvent, screen, userEvent, waitFor, within } from 'storybook/test'; +import { + expect, + findByText, + fireEvent, + screen, + spyOn, + userEvent, + waitFor, + within, +} from 'storybook/test'; import { IconButton } from '../IconButton/IconButton'; import { TabWrapper, Tabs, TabsState } from './tabs'; diff --git a/code/core/src/components/components/tooltip/ListItem.tsx b/code/core/src/components/components/tooltip/ListItem.tsx index 63e13f8b1d05..cdd18db3bbc0 100644 --- a/code/core/src/components/components/tooltip/ListItem.tsx +++ b/code/core/src/components/components/tooltip/ListItem.tsx @@ -73,10 +73,10 @@ export interface CenterTextProps { } const CenterText = styled.span( - ({ theme }) => ({ + { fontSize: '11px', lineHeight: '14px', - }), + }, ({ active, theme }) => active ? { @@ -201,11 +201,8 @@ const ListItem = (props: ListItemProps) => { active = false, disabled = false, isIndented = false, - href = undefined, - onClick = undefined, icon, input, - LinkWrapper = undefined, ...rest } = props; const commonProps = { active, disabled }; diff --git a/code/core/src/components/components/typography/link/link.tsx b/code/core/src/components/components/typography/link/link.tsx index 3ae17e6494eb..e5d9f5b2c4cf 100644 --- a/code/core/src/components/components/typography/link/link.tsx +++ b/code/core/src/components/components/typography/link/link.tsx @@ -192,7 +192,6 @@ export const Link = ({ withArrow = false, containsIcon = false, className = undefined, - style = undefined, ...rest }: LinkProps) => ( Promise.reject(new Error('Story already exists.'))), + createStory: fn(() => Promise.reject(new Error('Story already exists.'))), }, play: Created.play, }; diff --git a/code/core/src/core-server/build-static.ts b/code/core/src/core-server/build-static.ts index c4d844ca8d8e..098884aab5ef 100644 --- a/code/core/src/core-server/build-static.ts +++ b/code/core/src/core-server/build-static.ts @@ -1,5 +1,4 @@ -import { cp, mkdir, writeFile } from 'node:fs/promises'; -import { rm } from 'node:fs/promises'; +import { cp, mkdir, rm, writeFile } from 'node:fs/promises'; import { loadAllPresets, diff --git a/code/core/src/core-server/dev-server.ts b/code/core/src/core-server/dev-server.ts index cd3c5d02f1b8..cdea617934bb 100644 --- a/code/core/src/core-server/dev-server.ts +++ b/code/core/src/core-server/dev-server.ts @@ -1,8 +1,7 @@ import { logConfig } from 'storybook/internal/common'; import { logger } from 'storybook/internal/node-logger'; import { MissingBuilderError } from 'storybook/internal/server-errors'; -import type { ComponentsManifest, Options } from 'storybook/internal/types'; -import { type ComponentManifestGenerator } from 'storybook/internal/types'; +import { type ComponentsManifest, type Options } from 'storybook/internal/types'; import compression from '@polka/compression'; import polka from 'polka'; diff --git a/code/core/src/core-server/manifest.ts b/code/core/src/core-server/manifest.ts index 6e6f18b23533..06421b36c6e9 100644 --- a/code/core/src/core-server/manifest.ts +++ b/code/core/src/core-server/manifest.ts @@ -778,7 +778,7 @@ function renderComponentCard(key: string, c: ComponentManifest, id: string) {
${errorStories .map( - (ex, j) => ` + (ex) => `
${esc(ex.name)} diff --git a/code/core/src/core-server/presets/favicon.test.ts b/code/core/src/core-server/presets/favicon.test.ts index e6be6ebb054f..abf18e472108 100644 --- a/code/core/src/core-server/presets/favicon.test.ts +++ b/code/core/src/core-server/presets/favicon.test.ts @@ -56,10 +56,10 @@ vi.mock('storybook/internal/node-logger', () => { vi.mock('node:fs', async (importOriginal) => ({ ...(await importOriginal()), - existsSync: vi.fn((p: string) => { + existsSync: vi.fn(() => { return false; }), - statSync: vi.fn((p: string) => { + statSync: vi.fn(() => { return { isFile: () => false, }; diff --git a/code/core/src/core-server/presets/vitePlugins/vite-mock/utils.ts b/code/core/src/core-server/presets/vitePlugins/vite-mock/utils.ts index d3d1de0d4bcf..6f582b9570cd 100644 --- a/code/core/src/core-server/presets/vitePlugins/vite-mock/utils.ts +++ b/code/core/src/core-server/presets/vitePlugins/vite-mock/utils.ts @@ -1,4 +1,3 @@ -import { realpathSync } from 'fs'; import type { ViteDevServer } from 'vite'; /** diff --git a/code/core/src/core-server/presets/webpack/plugins/webpack-mock-plugin.ts b/code/core/src/core-server/presets/webpack/plugins/webpack-mock-plugin.ts index 6bb87d340fc1..838cd6ff9c26 100644 --- a/code/core/src/core-server/presets/webpack/plugins/webpack-mock-plugin.ts +++ b/code/core/src/core-server/presets/webpack/plugins/webpack-mock-plugin.ts @@ -1,4 +1,3 @@ -import { createRequire } from 'node:module'; import { dirname, isAbsolute } from 'node:path'; import { fileURLToPath } from 'node:url'; @@ -11,8 +10,6 @@ import { resolveWithExtensions, } from '../../../mocking-utils/resolve'; -const require = createRequire(import.meta.url); - // --- Type Definitions --- /** Options for configuring the WebpackMockPlugin. */ diff --git a/code/core/src/core-server/server-channel/open-in-editor-channel.ts b/code/core/src/core-server/server-channel/open-in-editor-channel.ts index 3f90477c5bad..7688962e5635 100644 --- a/code/core/src/core-server/server-channel/open-in-editor-channel.ts +++ b/code/core/src/core-server/server-channel/open-in-editor-channel.ts @@ -5,7 +5,7 @@ import type { } from 'storybook/internal/core-events'; import { OPEN_IN_EDITOR_REQUEST, OPEN_IN_EDITOR_RESPONSE } from 'storybook/internal/core-events'; import { telemetry } from 'storybook/internal/telemetry'; -import type { CoreConfig, Options, StoryIndex } from 'storybook/internal/types'; +import type { CoreConfig, Options } from 'storybook/internal/types'; import launch from 'launch-editor'; diff --git a/code/core/src/core-server/stores/status.ts b/code/core/src/core-server/stores/status.ts index 24fc4310f6cd..3fba982491c3 100644 --- a/code/core/src/core-server/stores/status.ts +++ b/code/core/src/core-server/stores/status.ts @@ -1,6 +1,5 @@ import { optionalEnvToBoolean } from '../../common/utils/envs'; -import { createStatusStore } from '../../shared/status-store'; -import { UNIVERSAL_STATUS_STORE_OPTIONS } from '../../shared/status-store'; +import { UNIVERSAL_STATUS_STORE_OPTIONS, createStatusStore } from '../../shared/status-store'; import { UniversalStore } from '../../shared/universal-store'; const statusStore = createStatusStore({ diff --git a/code/core/src/core-server/stores/test-provider.ts b/code/core/src/core-server/stores/test-provider.ts index 21c8a5112b05..4bb1e568f03f 100644 --- a/code/core/src/core-server/stores/test-provider.ts +++ b/code/core/src/core-server/stores/test-provider.ts @@ -1,6 +1,8 @@ import { optionalEnvToBoolean } from '../../common/utils/envs'; -import { createTestProviderStore } from '../../shared/test-provider-store'; -import { UNIVERSAL_TEST_PROVIDER_STORE_OPTIONS } from '../../shared/test-provider-store'; +import { + UNIVERSAL_TEST_PROVIDER_STORE_OPTIONS, + createTestProviderStore, +} from '../../shared/test-provider-store'; import { UniversalStore } from '../../shared/universal-store'; const testProviderStore = createTestProviderStore({ diff --git a/code/core/src/core-server/utils/StoryIndexGenerator.ts b/code/core/src/core-server/utils/StoryIndexGenerator.ts index ce9689d65b36..c318d32001b1 100644 --- a/code/core/src/core-server/utils/StoryIndexGenerator.ts +++ b/code/core/src/core-server/utils/StoryIndexGenerator.ts @@ -384,7 +384,7 @@ export class StoryIndexGenerator { let resolved; try { resolved = resolveImport(matchedPath, { basedir: dirname(absolutePath) }); - } catch (_) { + } catch { return matchedPath; } const relativePath = relative(this.options.workingDir, resolved); 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 f75b6675ddfa..06dfaea585f5 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,3 +1,4 @@ +/* eslint-disable @typescript-eslint/no-unused-vars */ import React from 'react'; import type { FC } from 'react'; 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 b0f0c86b6116..10fffb456335 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,3 +1,4 @@ +/* eslint-disable @typescript-eslint/no-unused-vars */ import React from 'react'; import type { FC } from 'react'; 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 8e99617dcbbe..7c046b5c89b9 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,3 +1,4 @@ +/* eslint-disable @typescript-eslint/no-unused-vars */ import React from 'react'; import type { FC } from 'react'; 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 11404058e20d..1a7be74b2965 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 @@ -74,7 +74,7 @@ export function initializeSaveStory(channel: Channel, options: Options, coreConf newStoryName = name && storyNameFromExport(name); newStoryId = newStoryName && toId(componentId, newStoryName); - const [storyName] = stories.find(([key, value]) => value.id.endsWith(`--${storyId}`)) || []; + const [storyName] = stories.find(([_key, value]) => value.id.endsWith(`--${storyId}`)) || []; if (!storyName) { throw new SaveStoryError(`Source story not found.`); } 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 c86afac79ac9..2c1926269ca3 100644 --- a/code/core/src/core-server/utils/search-files.test.ts +++ b/code/core/src/core-server/utils/search-files.test.ts @@ -5,7 +5,7 @@ import { describe, expect, it } from 'vitest'; import { searchFiles } from './search-files'; describe('search-files', () => { - it('should automatically convert static search to a dynamic glob search', async (t) => { + it('should automatically convert static search to a dynamic glob search', async () => { const files = await searchFiles({ searchQuery: 'ommonjs', cwd: join(__dirname, '__search-files-tests__'), @@ -14,7 +14,7 @@ describe('search-files', () => { expect(files).toEqual(['src/commonjs-module-default.js', 'src/commonjs-module.js']); }); - it('should automatically convert static search to a dynamic glob search (with file extension)', async (t) => { + it('should automatically convert static search to a dynamic glob search (with file extension)', async () => { const files = await searchFiles({ searchQuery: 'module.js', cwd: join(__dirname, '__search-files-tests__'), @@ -23,7 +23,7 @@ describe('search-files', () => { expect(files).toEqual(['src/commonjs-module.js', 'src/es-module.js']); }); - it('should return all files if the search query matches the parent folder', async (t) => { + it('should return all files if the search query matches the parent folder', async () => { const files = await searchFiles({ searchQuery: 'file-extensions', cwd: join(__dirname, '__search-files-tests__'), @@ -41,7 +41,7 @@ describe('search-files', () => { ]); }); - it('should ignore files that do not have the allowed extensions', async (t) => { + it('should ignore files that do not have the allowed extensions', async () => { const files = await searchFiles({ searchQuery: 'asset', cwd: join(__dirname, '__search-files-tests__'), @@ -50,7 +50,7 @@ describe('search-files', () => { expect(files).toEqual([]); }); - it('should ignore test files (*.spec.*, *.test.*)', async (t) => { + it('should ignore test files (*.spec.*, *.test.*)', async () => { const files = await searchFiles({ searchQuery: 'tests', cwd: join(__dirname, '__search-files-tests__'), @@ -59,7 +59,7 @@ describe('search-files', () => { expect(files).toEqual([]); }); - it('should work with glob search patterns', async (t) => { + it('should work with glob search patterns', async () => { const files = await searchFiles({ searchQuery: '**/commonjs-module.js', cwd: join(__dirname, '__search-files-tests__'), @@ -68,7 +68,7 @@ describe('search-files', () => { expect(files).toEqual(['src/commonjs-module.js']); }); - it('should respect glob but also the allowed file extensions', async (t) => { + it('should respect glob but also the allowed file extensions', async () => { const files = await searchFiles({ searchQuery: '**/*', cwd: join(__dirname, '__search-files-tests__'), @@ -90,7 +90,7 @@ describe('search-files', () => { ]); }); - it('should ignore node_modules', async (t) => { + it('should ignore node_modules', async () => { const files = await searchFiles({ searchQuery: 'file-in-common.js', cwd: join(__dirname, '__search-files-tests__'), @@ -99,7 +99,7 @@ describe('search-files', () => { expect(files).toEqual([]); }); - it('should ignore story files', async (t) => { + it('should ignore story files', async () => { const files = await searchFiles({ searchQuery: 'es-module.stories.js', cwd: join(__dirname, '__search-files-tests__'), @@ -108,7 +108,7 @@ describe('search-files', () => { expect(files).toEqual([]); }); - it('should not return files outside of project root', async (t) => { + it('should not return files outside of project root', async () => { await expect(() => searchFiles({ searchQuery: '../**/*', diff --git a/code/core/src/core-server/utils/server-statics.ts b/code/core/src/core-server/utils/server-statics.ts index c7b567bc0593..4d0789684b31 100644 --- a/code/core/src/core-server/utils/server-statics.ts +++ b/code/core/src/core-server/utils/server-statics.ts @@ -1,6 +1,6 @@ import { existsSync, statSync } from 'node:fs'; import { readFile, stat } from 'node:fs/promises'; -import { basename, dirname, isAbsolute, join, posix, resolve, sep, win32 } from 'node:path'; +import { basename, isAbsolute, join, posix, resolve, sep, win32 } from 'node:path'; import { getDirectoryFromWorkingDir, resolvePathInStorybookCache } from 'storybook/internal/common'; import { logger, once } from 'storybook/internal/node-logger'; diff --git a/code/core/src/core-server/utils/summarizeIndex.ts b/code/core/src/core-server/utils/summarizeIndex.ts index 5e6520323c78..3732dee9cb92 100644 --- a/code/core/src/core-server/utils/summarizeIndex.ts +++ b/code/core/src/core-server/utils/summarizeIndex.ts @@ -4,7 +4,6 @@ import type { IndexEntry, StoryIndex } from 'storybook/internal/types'; import { AUTODOCS_TAG, PLAY_FN_TAG, TEST_FN_TAG, isMdxEntry } from './StoryIndexGenerator'; const PAGE_REGEX = /(page|screen)/i; -const SVELTE_CSF_TAG = 'svelte-csf'; export const isPageStory = (storyId: string) => PAGE_REGEX.test(storyId); 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 33c678767134..0e74b73e0948 100644 --- a/code/core/src/core-server/utils/watch-story-specifiers.ts +++ b/code/core/src/core-server/utils/watch-story-specifiers.ts @@ -115,7 +115,7 @@ export function watchStorySpecifiers( } } - wp.on('change', async (filePath: Path, mtime: Date, explanation: string) => { + wp.on('change', async (filePath: Path, mtime: Date) => { // When a file is renamed (including being moved out of the watched dir) // we see first an event with explanation=rename and no mtime for the old name. // then an event with explanation=rename with an mtime for the new name. @@ -125,7 +125,7 @@ export function watchStorySpecifiers( const removed = !mtime; await onChangeOrRemove(filePath, removed); }); - wp.on('remove', async (filePath: Path, explanation: string) => { + wp.on('remove', async (filePath: Path) => { await onChangeOrRemove(filePath, true); }); diff --git a/code/core/src/core-server/utils/watchConfig.ts b/code/core/src/core-server/utils/watchConfig.ts index c3b993d04b1d..f5bcdc424830 100644 --- a/code/core/src/core-server/utils/watchConfig.ts +++ b/code/core/src/core-server/utils/watchConfig.ts @@ -16,11 +16,11 @@ export function watchConfig( wp.watch({ directories: [configDir], }); - wp.on('change', async (filePath: Path, mtime: Date, explanation: string) => { + wp.on('change', async (filePath: Path, mtime: Date) => { const removed = !mtime; await onInvalidate(filePath, removed); }); - wp.on('remove', async (filePath: Path, explanation: string) => { + wp.on('remove', async (filePath: Path) => { await onInvalidate(filePath, true); }); diff --git a/code/core/src/csf-tools/ConfigFile.test.ts b/code/core/src/csf-tools/ConfigFile.test.ts index f702579aeecd..34b95dbcda4c 100644 --- a/code/core/src/csf-tools/ConfigFile.test.ts +++ b/code/core/src/csf-tools/ConfigFile.test.ts @@ -8,7 +8,7 @@ import { loadConfig, printConfig } from './ConfigFile'; expect.addSnapshotSerializer({ serialize: (val: any) => (typeof val === 'string' ? val : val.toString()), - test: (val) => true, + test: () => true, }); const getField = (path: string[], source: string) => { diff --git a/code/core/src/csf-tools/CsfFile.ts b/code/core/src/csf-tools/CsfFile.ts index 1f2d39e031da..40478a2e3fde 100644 --- a/code/core/src/csf-tools/CsfFile.ts +++ b/code/core/src/csf-tools/CsfFile.ts @@ -221,7 +221,6 @@ export class NoMetaError extends Error { export class MultipleMetaError extends Error { constructor(message: string, ast: t.Node, fileName?: string) { - const msg = `${message} ${formatLocation(ast, fileName)}`.trim(); super(dedent` CSF: ${message} ${formatLocation(ast, fileName)} @@ -233,7 +232,6 @@ export class MultipleMetaError extends Error { export class MixedFactoryError extends Error { constructor(message: string, ast: t.Node, fileName?: string) { - const msg = `${message} ${formatLocation(ast, fileName)}`.trim(); super(dedent` CSF: ${message} ${formatLocation(ast, fileName)} @@ -245,7 +243,6 @@ export class MixedFactoryError extends Error { export class BadMetaError extends Error { constructor(message: string, ast: t.Node, fileName?: string) { - const msg = ``.trim(); super(dedent` CSF: ${message} ${formatLocation(ast, fileName)} diff --git a/code/core/src/csf-tools/vitest-plugin/transformer.test.ts b/code/core/src/csf-tools/vitest-plugin/transformer.test.ts index 840d16f57499..d82f5a419e99 100644 --- a/code/core/src/csf-tools/vitest-plugin/transformer.test.ts +++ b/code/core/src/csf-tools/vitest-plugin/transformer.test.ts @@ -17,7 +17,7 @@ vi.mock('storybook/internal/common', async (importOriginal) => { expect.addSnapshotSerializer({ serialize: (val: any) => (typeof val === 'string' ? val : val.toString()), - test: (val) => true, + test: () => true, }); const transform = async ({ diff --git a/code/core/src/csf/csf-factories.test.ts b/code/core/src/csf/csf-factories.test.ts index cd25dc723c08..b3b5664e65cf 100644 --- a/code/core/src/csf/csf-factories.test.ts +++ b/code/core/src/csf/csf-factories.test.ts @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/no-unused-vars */ //* @vitest-environment happy-dom */ import { describe, expect, test, vi } from 'vitest'; diff --git a/code/core/src/csf/csf-factories.ts b/code/core/src/csf/csf-factories.ts index 22af4a85f64c..ce1627ea9fd3 100644 --- a/code/core/src/csf/csf-factories.ts +++ b/code/core/src/csf/csf-factories.ts @@ -61,7 +61,7 @@ export function definePreview +export interface PreviewAddon extends ProjectAnnotations {} export function definePreviewAddon( diff --git a/code/core/src/csf/story.test.ts b/code/core/src/csf/story.test.ts index 3784cca3aaa6..a1bf6340ef78 100644 --- a/code/core/src/csf/story.test.ts +++ b/code/core/src/csf/story.test.ts @@ -1,3 +1,5 @@ +/* eslint-disable @typescript-eslint/no-unused-vars */ + /* global HTMLElement */ import { test } from 'vitest'; 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 b3cb9649b70c..b2584e48df6c 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 @@ -2,7 +2,7 @@ import React from 'react'; import PropTypes from 'prop-types'; -export const Component = (props) => <>JSON.stringify(props); +export const Component = (props) => <>{JSON.stringify(props)}; Component.propTypes = { optionalArray: PropTypes.array, arrayOfStrings: PropTypes.arrayOf(PropTypes.string), 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 2bfa6a5e7417..6daea4608372 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 @@ -2,7 +2,7 @@ import React from 'react'; import PropTypes from 'prop-types'; -export const Component = (props) => <>JSON.stringify(props); +export const Component = (props) => <>{JSON.stringify(props)}; Component.propTypes = { oneOfNumber: PropTypes.oneOf([1, 2, 3]), oneOfMiscellaneous: PropTypes.oneOf([false, true, undefined]), 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 a5e0d60dcf70..bcc47f898e74 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 @@ -2,7 +2,7 @@ import React from 'react'; import PropTypes from 'prop-types'; -export const Component = (props) => <>JSON.stringify(props); +export const Component = (props) => <>{JSON.stringify(props)}; Component.propTypes = { // An object that could be one of many types optionalUnion: PropTypes.oneOfType([ 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 12d81862672a..677ad39e954a 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 @@ -2,7 +2,7 @@ import React from 'react'; import PropTypes from 'prop-types'; -export const Component = (props) => <>JSON.stringify(props); +export const Component = (props) => <>{JSON.stringify(props)}; Component.propTypes = { optionalObject: PropTypes.object, optionalObjectOf: PropTypes.objectOf(PropTypes.number), 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 0b772151166a..b4e3cf0384d4 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 @@ -2,7 +2,7 @@ import React from 'react'; import PropTypes from 'prop-types'; -export const Component = (props) => <>JSON.stringify(props); +export const Component = (props) => <>{JSON.stringify(props)}; Component.propTypes = { // Anything that can be rendered: numbers, strings, elements or an array // (or fragment) containing these types. 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 c28a4e4bb991..fb85288c4f24 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 @@ -2,7 +2,7 @@ import React from 'react'; import PropTypes from 'prop-types'; -export const Component = (props) => <>JSON.stringify(props); +export const Component = (props) => <>{JSON.stringify(props)}; Component.propTypes = { optionalBool: PropTypes.bool, optionalFunc: PropTypes.func, diff --git a/code/core/src/docs-tools/argTypes/convert/__testfixtures__/typescript/aliases.tsx b/code/core/src/docs-tools/argTypes/convert/__testfixtures__/typescript/aliases.tsx index 16edafc4b785..f10b4808f770 100644 --- a/code/core/src/docs-tools/argTypes/convert/__testfixtures__/typescript/aliases.tsx +++ b/code/core/src/docs-tools/argTypes/convert/__testfixtures__/typescript/aliases.tsx @@ -14,4 +14,4 @@ interface Props { aliasesUnion: AliasesUnion; genericAlias: GenericAlias; } -export const Component: FC = (props: Props) => <>JSON.stringify(props); +export const Component: FC = (props: Props) => <>{JSON.stringify(props)}; diff --git a/code/core/src/docs-tools/argTypes/convert/__testfixtures__/typescript/arrays.tsx b/code/core/src/docs-tools/argTypes/convert/__testfixtures__/typescript/arrays.tsx index b2814a32beca..a059cefc22e6 100644 --- a/code/core/src/docs-tools/argTypes/convert/__testfixtures__/typescript/arrays.tsx +++ b/code/core/src/docs-tools/argTypes/convert/__testfixtures__/typescript/arrays.tsx @@ -15,4 +15,4 @@ interface Props { arrayOfPrimitive: string[]; arrayOfComplexObject: ItemInterface[]; } -export const Component: FC = (props: Props) => <>JSON.stringify(props); +export const Component: FC = (props: Props) => <>{JSON.stringify(props)}; diff --git a/code/core/src/docs-tools/argTypes/convert/__testfixtures__/typescript/enums.tsx b/code/core/src/docs-tools/argTypes/convert/__testfixtures__/typescript/enums.tsx index 9df56e056e40..1daf407723e4 100644 --- a/code/core/src/docs-tools/argTypes/convert/__testfixtures__/typescript/enums.tsx +++ b/code/core/src/docs-tools/argTypes/convert/__testfixtures__/typescript/enums.tsx @@ -21,4 +21,4 @@ interface Props { numericEnum: NumericEnum; stringEnum: StringEnum; } -export const Component: FC = (props: Props) => <>JSON.stringify(props); +export const Component: FC = (props: Props) => <>{JSON.stringify(props)}; diff --git a/code/core/src/docs-tools/argTypes/convert/__testfixtures__/typescript/functions.tsx b/code/core/src/docs-tools/argTypes/convert/__testfixtures__/typescript/functions.tsx index fa182c493257..843cfaded3f5 100644 --- a/code/core/src/docs-tools/argTypes/convert/__testfixtures__/typescript/functions.tsx +++ b/code/core/src/docs-tools/argTypes/convert/__testfixtures__/typescript/functions.tsx @@ -12,4 +12,4 @@ interface Props { funcWithUnionArg: (a: string | number) => string; funcWithMultipleUnionReturns: () => string | ItemInterface; } -export const Component: FC = (props: Props) => <>JSON.stringify(props); +export const Component: FC = (props: Props) => <>{JSON.stringify(props)}; diff --git a/code/core/src/docs-tools/argTypes/convert/__testfixtures__/typescript/interfaces.tsx b/code/core/src/docs-tools/argTypes/convert/__testfixtures__/typescript/interfaces.tsx index b31607760911..9799ea0541c0 100644 --- a/code/core/src/docs-tools/argTypes/convert/__testfixtures__/typescript/interfaces.tsx +++ b/code/core/src/docs-tools/argTypes/convert/__testfixtures__/typescript/interfaces.tsx @@ -12,4 +12,5 @@ interface Props { interface: ItemInterface; genericInterface: GenericInterface; } -export const Component: FC = (props: Props) => <>JSON.stringify(props); + +export const Component: FC = (props: Props) => <>{JSON.stringify(props)}; diff --git a/code/core/src/docs-tools/argTypes/convert/__testfixtures__/typescript/intersections.tsx b/code/core/src/docs-tools/argTypes/convert/__testfixtures__/typescript/intersections.tsx index ee813a419ffe..eaff2619f0cf 100644 --- a/code/core/src/docs-tools/argTypes/convert/__testfixtures__/typescript/intersections.tsx +++ b/code/core/src/docs-tools/argTypes/convert/__testfixtures__/typescript/intersections.tsx @@ -13,4 +13,4 @@ interface Props { intersectionType: InterfaceIntersection; intersectionWithInlineType: ItemInterface & { inlineValue: string }; } -export const Component: FC = (props: Props) => <>JSON.stringify(props); +export const Component: FC = (props: Props) => <>{JSON.stringify(props)}; diff --git a/code/core/src/docs-tools/argTypes/convert/__testfixtures__/typescript/records.tsx b/code/core/src/docs-tools/argTypes/convert/__testfixtures__/typescript/records.tsx index 18af13445f5e..b3bc8966ca2e 100644 --- a/code/core/src/docs-tools/argTypes/convert/__testfixtures__/typescript/records.tsx +++ b/code/core/src/docs-tools/argTypes/convert/__testfixtures__/typescript/records.tsx @@ -9,4 +9,4 @@ interface Props { recordOfPrimitive: Record; recordOfComplexObject: Record; } -export const Component: FC = (props: Props) => <>JSON.stringify(props); +export const Component: FC = (props: Props) => <>{JSON.stringify(props)}; diff --git a/code/core/src/docs-tools/argTypes/convert/__testfixtures__/typescript/scalars.tsx b/code/core/src/docs-tools/argTypes/convert/__testfixtures__/typescript/scalars.tsx index b4739d6af28a..7cbf93db7cbf 100644 --- a/code/core/src/docs-tools/argTypes/convert/__testfixtures__/typescript/scalars.tsx +++ b/code/core/src/docs-tools/argTypes/convert/__testfixtures__/typescript/scalars.tsx @@ -9,4 +9,4 @@ interface Props { symbol: symbol; readonly readonlyPrimitive: string; } -export const Component: FC = (props: Props) => <>JSON.stringify(props); +export const Component: FC = (props: Props) => <>{JSON.stringify(props)}; diff --git a/code/core/src/docs-tools/argTypes/convert/__testfixtures__/typescript/tuples.tsx b/code/core/src/docs-tools/argTypes/convert/__testfixtures__/typescript/tuples.tsx index 062af22f4beb..6c4b79ba9dc3 100644 --- a/code/core/src/docs-tools/argTypes/convert/__testfixtures__/typescript/tuples.tsx +++ b/code/core/src/docs-tools/argTypes/convert/__testfixtures__/typescript/tuples.tsx @@ -9,4 +9,4 @@ interface Props { tupleOfPrimitive: [string, number]; tupleWithComplexType: [string, ItemInterface]; } -export const Component: FC = (props: Props) => <>JSON.stringify(props); +export const Component: FC = (props: Props) => <>{JSON.stringify(props)}; diff --git a/code/core/src/docs-tools/argTypes/convert/__testfixtures__/typescript/unions.tsx b/code/core/src/docs-tools/argTypes/convert/__testfixtures__/typescript/unions.tsx index 2465efe96c8a..41bff6411e89 100644 --- a/code/core/src/docs-tools/argTypes/convert/__testfixtures__/typescript/unions.tsx +++ b/code/core/src/docs-tools/argTypes/convert/__testfixtures__/typescript/unions.tsx @@ -18,4 +18,4 @@ interface Props { inlinedNumericLiteralUnion: 0 | 1; enumUnion: EnumUnion; } -export const Component: FC = (props: Props) => <>JSON.stringify(props); +export const Component: FC = (props: 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 354a4779324b..ae50f2423dae 100644 --- a/code/core/src/docs-tools/argTypes/convert/convert.test.ts +++ b/code/core/src/docs-tools/argTypes/convert/convert.test.ts @@ -34,7 +34,7 @@ describe('storybook type system', () => { funcWithUnionArg: (a: string | number) => string; funcWithMultipleUnionReturns: () => string | ItemInterface; } - export const Component: FC = (props: Props) => <>JSON.stringify(props); + export const Component: FC = (props: Props) => <>{JSON.stringify(props)}; " `); expect(convertTs(input)).toMatchInlineSnapshot(` @@ -79,7 +79,7 @@ describe('storybook type system', () => { funcWithUnionArg: (a: string | number) => string; funcWithMultipleUnionReturns: () => string | ItemInterface; } - export const Component: FC = (props: Props) => <>JSON.stringify(props); + export const Component: FC = (props: Props) => <>{JSON.stringify(props)}; " `); expect(convertTs(input)).toMatchInlineSnapshot(` @@ -133,7 +133,7 @@ describe('storybook type system', () => { numericEnum: NumericEnum; stringEnum: StringEnum; } - export const Component: FC = (props: Props) => <>JSON.stringify(props); + export const Component: FC = (props: Props) => <>{JSON.stringify(props)}; " `); expect(convertTs(input)).toMatchInlineSnapshot(` @@ -176,7 +176,7 @@ describe('storybook type system', () => { inlinedNumericLiteralUnion: 0 | 1; enumUnion: EnumUnion; } - export const Component: FC = (props: Props) => <>JSON.stringify(props); + export const Component: FC = (props: Props) => <>{JSON.stringify(props)}; " `); expect(convertTs(input)).toMatchInlineSnapshot(` @@ -232,7 +232,7 @@ describe('storybook type system', () => { intersectionType: InterfaceIntersection; intersectionWithInlineType: ItemInterface & { inlineValue: string }; } - export const Component: FC = (props: Props) => <>JSON.stringify(props); + export const Component: FC = (props: Props) => <>{JSON.stringify(props)}; " `); expect(convertTs(input)).toMatchInlineSnapshot(` @@ -293,7 +293,7 @@ describe('storybook type system', () => { arrayOfPrimitive: string[]; arrayOfComplexObject: ItemInterface[]; } - export const Component: FC = (props: Props) => <>JSON.stringify(props); + export const Component: FC = (props: Props) => <>{JSON.stringify(props)}; " `); expect(convertTs(input)).toMatchInlineSnapshot(` @@ -365,7 +365,8 @@ describe('storybook type system', () => { interface: ItemInterface; genericInterface: GenericInterface; } - export const Component: FC = (props: Props) => <>JSON.stringify(props); + + export const Component: FC = (props: Props) => <>{JSON.stringify(props)}; " `); expect(convertTs(input)).toMatchInlineSnapshot(` @@ -396,7 +397,7 @@ describe('storybook type system', () => { recordOfPrimitive: Record; recordOfComplexObject: Record; } - export const Component: FC = (props: Props) => <>JSON.stringify(props); + export const Component: FC = (props: Props) => <>{JSON.stringify(props)}; " `); expect(convertTs(input)).toMatchInlineSnapshot(` @@ -433,7 +434,7 @@ describe('storybook type system', () => { aliasesUnion: AliasesUnion; genericAlias: GenericAlias; } - export const Component: FC = (props: Props) => <>JSON.stringify(props); + export const Component: FC = (props: Props) => <>{JSON.stringify(props)}; " `); expect(convertTs(input)).toMatchInlineSnapshot(` @@ -487,7 +488,7 @@ describe('storybook type system', () => { tupleOfPrimitive: [string, number]; tupleWithComplexType: [string, ItemInterface]; } - export const Component: FC = (props: Props) => <>JSON.stringify(props); + export const Component: FC = (props: Props) => <>{JSON.stringify(props)}; " `); expect(convertTs(input)).toMatchInlineSnapshot(` @@ -514,7 +515,7 @@ describe('storybook type system', () => { import PropTypes from 'prop-types'; - export const Component = (props) => <>JSON.stringify(props); + export const Component = (props) => <>{JSON.stringify(props)}; Component.propTypes = { optionalBool: PropTypes.bool, optionalFunc: PropTypes.func, @@ -551,7 +552,7 @@ describe('storybook type system', () => { import PropTypes from 'prop-types'; - export const Component = (props) => <>JSON.stringify(props); + export const Component = (props) => <>{JSON.stringify(props)}; Component.propTypes = { optionalArray: PropTypes.array, arrayOfStrings: PropTypes.arrayOf(PropTypes.string), @@ -595,7 +596,7 @@ describe('storybook type system', () => { import PropTypes from 'prop-types'; - export const Component = (props) => <>JSON.stringify(props); + export const Component = (props) => <>{JSON.stringify(props)}; Component.propTypes = { oneOfNumber: PropTypes.oneOf([1, 2, 3]), oneOfMiscellaneous: PropTypes.oneOf([false, true, undefined]), @@ -647,7 +648,7 @@ describe('storybook type system', () => { import PropTypes from 'prop-types'; - export const Component = (props) => <>JSON.stringify(props); + export const Component = (props) => <>{JSON.stringify(props)}; Component.propTypes = { // An object that could be one of many types optionalUnion: PropTypes.oneOfType([ @@ -696,7 +697,7 @@ describe('storybook type system', () => { import PropTypes from 'prop-types'; - export const Component = (props) => <>JSON.stringify(props); + export const Component = (props) => <>{JSON.stringify(props)}; Component.propTypes = { optionalObject: PropTypes.object, optionalObjectOf: PropTypes.objectOf(PropTypes.number), @@ -754,7 +755,7 @@ describe('storybook type system', () => { import PropTypes from 'prop-types'; - export const Component = (props) => <>JSON.stringify(props); + export const Component = (props) => <>{JSON.stringify(props)}; Component.propTypes = { // Anything that can be rendered: numbers, strings, elements or an array // (or fragment) containing these types. diff --git a/code/core/src/docs-tools/argTypes/jsdocParser.ts b/code/core/src/docs-tools/argTypes/jsdocParser.ts index 887bab58c719..c3d976ce5263 100644 --- a/code/core/src/docs-tools/argTypes/jsdocParser.ts +++ b/code/core/src/docs-tools/argTypes/jsdocParser.ts @@ -233,7 +233,7 @@ jsdocStringifyRules.JsdocTypeUnion = (result, transform) => function extractType(typeString: string): JSDocType | null { try { return parseJSDocType(typeString, 'typescript'); - } catch (_err) { + } catch { return null; } } diff --git a/code/core/src/instrumenter/instrumenter.test.ts b/code/core/src/instrumenter/instrumenter.test.ts index 2d75669b6c1e..6cb34773e2c7 100644 --- a/code/core/src/instrumenter/instrumenter.test.ts +++ b/code/core/src/instrumenter/instrumenter.test.ts @@ -191,7 +191,7 @@ describe('Instrumenter', () => { }); it('emits a "call" event every time a patched function is invoked', async () => { - const { fn } = instrument({ fn: (...args: any) => {} }); + const { fn } = instrument({ fn: (..._args: any) => {} }); fn('foo', 'bar'); fn('baz'); @@ -210,7 +210,7 @@ describe('Instrumenter', () => { }); it('handles circular references', () => { - const { fn } = instrument({ fn: (...args: any) => {} }); + const { fn } = instrument({ fn: (..._args: any) => {} }); const obj = { key: 'value', obj: {}, array: [] as any[] }; obj.obj = obj; obj.array = [obj]; @@ -247,7 +247,7 @@ describe('Instrumenter', () => { it('maps event args which originate from an earlier call to a call ref', () => { const { fn1, fn2 } = instrument({ fn1: (arg: any) => arg, - fn2: (arg: any) => {}, + fn2: (_arg: any) => {}, }); fn2(fn1({})); expect(mocks.callSpy).toHaveBeenLastCalledWith( @@ -261,7 +261,7 @@ describe('Instrumenter', () => { it('does not map primitive event args which originate from an earlier call', () => { const { fn1, fn2 } = instrument({ fn1: (...args: any) => args[0], - fn2: (...args: any) => {}, + fn2: (..._args: any) => {}, }); fn2( fn1(undefined), @@ -297,7 +297,7 @@ describe('Instrumenter', () => { }); it('maps HTML Elements in event args to an element ref', () => { - const { fn } = instrument({ fn: (...args: any) => {} }); + const { fn } = instrument({ fn: (..._args: any) => {} }); fn(new HTMLElement({ prefix: '', localName: 'div', id: 'root', classList: [] })); expect(mocks.callSpy).toHaveBeenLastCalledWith( expect.objectContaining({ @@ -449,7 +449,7 @@ describe('Instrumenter', () => { }); it('emits a "sync" event with debounce after a patched function is invoked', () => { - const { fn } = instrument({ fn: (...args: any) => {} }, { intercept: true }); + const { fn } = instrument({ fn: (..._args: any) => {} }, { intercept: true }); vi.useFakeTimers(); mocks.syncSpy.mockClear(); fn('foo'); @@ -459,7 +459,7 @@ describe('Instrumenter', () => { }); it('sends a folded log with the "sync" event', () => { - const { fn } = instrument({ fn: (...args: any) => ({ fn2: () => {} }) }, { intercept: true }); + const { fn } = instrument({ fn: (..._args: any) => ({ fn2: () => {} }) }, { intercept: true }); vi.useFakeTimers(); mocks.syncSpy.mockClear(); fn('foo', fn('bar')).fn2(); @@ -476,7 +476,7 @@ describe('Instrumenter', () => { }); it('sends control states with the "sync" event', () => { - const { fn } = instrument({ fn: (...args: any) => {} }, { intercept: true }); + const { fn } = instrument({ fn: (..._args: any) => {} }, { intercept: true }); vi.useFakeTimers(); mocks.syncSpy.mockClear(); fn('foo'); @@ -743,7 +743,7 @@ describe('Instrumenter', () => { }); it('disables control states', async () => { - const { fn } = instrument({ fn: (...args: any) => {} }, { intercept: true }); + const { fn } = instrument({ fn: (..._args: any) => {} }, { intercept: true }); vi.useFakeTimers(); mocks.syncSpy.mockClear(); fn('foo'); diff --git a/code/core/src/manager-api/modules/addons.ts b/code/core/src/manager-api/modules/addons.ts index 55ed5a559369..0f496226699e 100644 --- a/code/core/src/manager-api/modules/addons.ts +++ b/code/core/src/manager-api/modules/addons.ts @@ -90,7 +90,7 @@ export function ensurePanel( return currentPanel; } -export const init: ModuleFn = ({ provider, store, fullAPI }): any => { +export const init: ModuleFn = ({ provider, store }): any => { const api: SubAPI = { getElements: (type) => provider.getElements(type), getSelectedPanel: (): any => { diff --git a/code/core/src/manager-api/modules/refs.ts b/code/core/src/manager-api/modules/refs.ts index 586453443c05..60eecffa14da 100644 --- a/code/core/src/manager-api/modules/refs.ts +++ b/code/core/src/manager-api/modules/refs.ts @@ -294,7 +294,7 @@ export const init: ModuleFn = ( return refs; }, - setRef: async (id, { storyIndex, setStoriesData, ...rest }, ready = false) => { + setRef: async (id, { storyIndex, setStoriesData, ...rest }, _ready = false) => { if (singleStory) { return; } diff --git a/code/core/src/manager-api/modules/stories.ts b/code/core/src/manager-api/modules/stories.ts index 4af228dcf048..724d0582b944 100644 --- a/code/core/src/manager-api/modules/stories.ts +++ b/code/core/src/manager-api/modules/stories.ts @@ -881,12 +881,12 @@ export const init: ModuleFn = ({ ); // When there's a preview error, we don't show it in the manager, but simply - provider.channel?.on(CONFIG_ERROR, function handleConfigError(this: any, err: any) { + provider.channel?.on(CONFIG_ERROR, function handleConfigError(this: any, _err: any) { const { ref } = getEventMetadata(this, fullAPI)!; api.setPreviewInitialized(ref); }); - provider.channel?.on(STORY_MISSING, function handleConfigError(this: any, err: any) { + provider.channel?.on(STORY_MISSING, function handleConfigError(this: any, _err: any) { const { ref } = getEventMetadata(this, fullAPI)!; api.setPreviewInitialized(ref); }); diff --git a/code/core/src/manager-api/stores/__mocks__/status.ts b/code/core/src/manager-api/stores/__mocks__/status.ts index c00880254e08..442fc4bd757b 100644 --- a/code/core/src/manager-api/stores/__mocks__/status.ts +++ b/code/core/src/manager-api/stores/__mocks__/status.ts @@ -1,5 +1,4 @@ -import { createStatusStore } from '../../../shared/status-store'; -import { UNIVERSAL_STATUS_STORE_OPTIONS } from '../../../shared/status-store'; +import { UNIVERSAL_STATUS_STORE_OPTIONS, createStatusStore } from '../../../shared/status-store'; import { useUniversalStore } from '../../../shared/universal-store/use-universal-store-manager'; import { experimental_MockUniversalStore } from '../../index.mock'; diff --git a/code/core/src/manager-api/stores/__mocks__/test-provider.ts b/code/core/src/manager-api/stores/__mocks__/test-provider.ts index 5986d69c8cc2..1dad8e033567 100644 --- a/code/core/src/manager-api/stores/__mocks__/test-provider.ts +++ b/code/core/src/manager-api/stores/__mocks__/test-provider.ts @@ -1,5 +1,7 @@ -import { createTestProviderStore } from '../../../shared/test-provider-store'; -import { UNIVERSAL_TEST_PROVIDER_STORE_OPTIONS } from '../../../shared/test-provider-store'; +import { + UNIVERSAL_TEST_PROVIDER_STORE_OPTIONS, + createTestProviderStore, +} from '../../../shared/test-provider-store'; import { useUniversalStore } from '../../../shared/universal-store/use-universal-store-manager'; import { experimental_MockUniversalStore } from '../../index.mock'; diff --git a/code/core/src/manager-api/stores/status.ts b/code/core/src/manager-api/stores/status.ts index 2450f5f9efb2..e9f7dd6ad448 100644 --- a/code/core/src/manager-api/stores/status.ts +++ b/code/core/src/manager-api/stores/status.ts @@ -1,5 +1,4 @@ -import { createStatusStore } from '../../shared/status-store'; -import { UNIVERSAL_STATUS_STORE_OPTIONS } from '../../shared/status-store'; +import { UNIVERSAL_STATUS_STORE_OPTIONS, createStatusStore } from '../../shared/status-store'; import { UniversalStore } from '../../shared/universal-store'; import { useUniversalStore } from '../../shared/universal-store/use-universal-store-manager'; diff --git a/code/core/src/manager-api/stores/test-provider.ts b/code/core/src/manager-api/stores/test-provider.ts index dad06f5b33bb..c9f0bcc812f4 100644 --- a/code/core/src/manager-api/stores/test-provider.ts +++ b/code/core/src/manager-api/stores/test-provider.ts @@ -1,5 +1,7 @@ -import { createTestProviderStore } from '../../shared/test-provider-store'; -import { UNIVERSAL_TEST_PROVIDER_STORE_OPTIONS } from '../../shared/test-provider-store'; +import { + UNIVERSAL_TEST_PROVIDER_STORE_OPTIONS, + createTestProviderStore, +} from '../../shared/test-provider-store'; import { UniversalStore } from '../../shared/universal-store'; import { useUniversalStore } from '../../shared/universal-store/use-universal-store-manager'; diff --git a/code/core/src/manager-api/tests/notifications.test.js b/code/core/src/manager-api/tests/notifications.test.js index 95ccbe1f1187..176fce3db3bc 100644 --- a/code/core/src/manager-api/tests/notifications.test.js +++ b/code/core/src/manager-api/tests/notifications.test.js @@ -1,4 +1,4 @@ -import { describe, expect, it, vi } from 'vitest'; +import { describe, expect, it } from 'vitest'; import { init as initNotifications } from '../modules/notifications'; diff --git a/code/core/src/manager-api/tests/refs.test.ts b/code/core/src/manager-api/tests/refs.test.ts index 07eddf864e49..3c97ca1d6c85 100644 --- a/code/core/src/manager-api/tests/refs.test.ts +++ b/code/core/src/manager-api/tests/refs.test.ts @@ -57,7 +57,7 @@ const store = { }, }, }), - setState: vi.fn((a: any) => {}), + setState: vi.fn((_a: any) => {}), }; function createMockStore(initialState: Partial = {}) { diff --git a/code/core/src/manager-api/tests/url.test.js b/code/core/src/manager-api/tests/url.test.js index 349783223291..0e9b768d354c 100644 --- a/code/core/src/manager-api/tests/url.test.js +++ b/code/core/src/manager-api/tests/url.test.js @@ -19,8 +19,6 @@ const storyState = (storyId) => ({ }); describe('initial state', () => { - const viewMode = 'story'; - describe('config query parameters', () => { it('handles full parameter', () => { const navigate = vi.fn(); @@ -213,7 +211,7 @@ describe('initModule', () => { store.setState({ ...storyState('test--story'), customQueryParams: { full: 1 }, location }); const navigate = vi.fn(); const channel = new EventEmitter(); - const { api } = initURL({ + initURL({ store, provider: { channel }, state: { location }, diff --git a/code/core/src/manager/components/layout/Layout.tsx b/code/core/src/manager/components/layout/Layout.tsx index 0af2c051dd21..86a3110c6d83 100644 --- a/code/core/src/manager/components/layout/Layout.tsx +++ b/code/core/src/manager/components/layout/Layout.tsx @@ -205,7 +205,7 @@ export const Layout = ({ managerLayoutState, setManagerLayoutState, hasTab, ...s }; const LayoutContainer = styled.div( - ({ navSize, rightPanelWidth, bottomPanelHeight, viewMode, panelPosition, showPanel }) => { + ({ navSize, rightPanelWidth, bottomPanelHeight, panelPosition, showPanel }) => { return { width: '100%', height: ['100vh', '100dvh'], // This array is a special Emotion syntax to set a fallback if 100dvh is not supported diff --git a/code/core/src/manager/components/layout/useDragging.ts b/code/core/src/manager/components/layout/useDragging.ts index 88727a1ff2b3..1e2bf7089426 100644 --- a/code/core/src/manager/components/layout/useDragging.ts +++ b/code/core/src/manager/components/layout/useDragging.ts @@ -59,7 +59,7 @@ export function useDragging({ } }; - const onDragEnd = (e: MouseEvent) => { + const onDragEnd = (_e: MouseEvent) => { setState((state) => { if (draggedElement === sidebarResizer) { if (state.navSize < SIDEBAR_MIN_WIDTH_PX && state.navSize > 0) { diff --git a/code/core/src/manager/components/mobile/navigation/MobileAddonsDrawer.tsx b/code/core/src/manager/components/mobile/navigation/MobileAddonsDrawer.tsx index 2170a07e3bc3..ebda4bd07dac 100644 --- a/code/core/src/manager/components/mobile/navigation/MobileAddonsDrawer.tsx +++ b/code/core/src/manager/components/mobile/navigation/MobileAddonsDrawer.tsx @@ -1,5 +1,5 @@ import type { FC, ReactNode } from 'react'; -import React, { useCallback, useRef } from 'react'; +import React, { useCallback } from 'react'; import { Transition } from 'react-transition-group'; import type { TransitionStatus } from 'react-transition-group/Transition'; diff --git a/code/core/src/manager/components/mobile/navigation/MobileMenuDrawer.tsx b/code/core/src/manager/components/mobile/navigation/MobileMenuDrawer.tsx index 7e85a47c3d00..1a0e9be7cdb5 100644 --- a/code/core/src/manager/components/mobile/navigation/MobileMenuDrawer.tsx +++ b/code/core/src/manager/components/mobile/navigation/MobileMenuDrawer.tsx @@ -134,7 +134,7 @@ const Container = styled.dialog<{ state: TransitionStatus }>(({ theme, state }) }, })); -const SidebarContainer = styled.div<{ state: TransitionStatus }>(({ theme, state }) => ({ +const SidebarContainer = styled.div<{ state: TransitionStatus }>(({ state }) => ({ position: 'absolute', width: '100%', height: '100%', diff --git a/code/core/src/manager/components/notifications/NotificationItem.tsx b/code/core/src/manager/components/notifications/NotificationItem.tsx index 286578dbd109..486cc61d72ef 100644 --- a/code/core/src/manager/components/notifications/NotificationItem.tsx +++ b/code/core/src/manager/components/notifications/NotificationItem.tsx @@ -110,7 +110,7 @@ const NotificationTextWrapper = styled.div(({ theme }) => ({ color: theme.base === 'dark' ? theme.color.mediumdark : theme.color.mediumlight, })); -const Headline = styled.div<{ hasIcon: boolean }>(({ theme, hasIcon }) => ({ +const Headline = styled.div(({ theme }) => ({ height: '100%', alignItems: 'center', whiteSpace: 'balance', @@ -136,9 +136,7 @@ const ItemContent: FC> = ({ <> {!icon || {icon}} - - {headline} - + {headline} {subHeadline && {subHeadline}} diff --git a/code/core/src/manager/components/preview/tools/zoom.tsx b/code/core/src/manager/components/preview/tools/zoom.tsx index 742e4fdd9839..4325ffd16bc0 100644 --- a/code/core/src/manager/components/preview/tools/zoom.tsx +++ b/code/core/src/manager/components/preview/tools/zoom.tsx @@ -10,7 +10,7 @@ import { types } from 'storybook/manager-api'; const initialZoom = 1 as const; -const Context = createContext({ value: initialZoom, set: (v: number) => {} }); +const Context = createContext({ value: initialZoom, set: (_v: number) => {} }); class ZoomProvider extends Component< PropsWithChildren<{ shouldScale: boolean }>, diff --git a/code/core/src/manager/components/preview/utils/components.ts b/code/core/src/manager/components/preview/utils/components.ts index b5a355618312..ba1ea9ec81b4 100644 --- a/code/core/src/manager/components/preview/utils/components.ts +++ b/code/core/src/manager/components/preview/utils/components.ts @@ -46,7 +46,7 @@ export const DesktopOnly = styled.span({ }, }); -export const IframeWrapper = styled.div(({ theme }) => ({ +export const IframeWrapper = styled.div({ alignContent: 'center', alignItems: 'center', justifyContent: 'center', @@ -60,7 +60,7 @@ export const IframeWrapper = styled.div(({ theme }) => ({ position: 'relative', width: '100%', height: '100%', -})); +}); export const LoaderWrapper = styled.div(({ theme }) => ({ position: 'absolute', diff --git a/code/core/src/manager/components/sidebar/FileList.tsx b/code/core/src/manager/components/sidebar/FileList.tsx index a2c179439801..960ec83c9fab 100644 --- a/code/core/src/manager/components/sidebar/FileList.tsx +++ b/code/core/src/manager/components/sidebar/FileList.tsx @@ -16,7 +16,7 @@ export const FileListWrapper = styled('div')(({ theme }) => ({ }, })); -export const FileList = styled('div')(({ theme }) => ({ +export const FileList = styled('div')({ height: '280px', overflow: 'auto', msOverflowStyle: 'none', @@ -25,7 +25,7 @@ export const FileList = styled('div')(({ theme }) => ({ '::-webkit-scrollbar': { display: 'none', }, -})); +}); export const FileListLi = styled('li')(({ theme }) => ({ ':focus-visible': { @@ -42,11 +42,11 @@ export const FileListLi = styled('li')(({ theme }) => ({ }, })); -export const FileListItem = styled('div')(({ theme }) => ({ +export const FileListItem = styled('div')({ display: 'flex', flexDirection: 'column', position: 'relative', -})); +}); export const FileListItemContentWrapper = styled.div<{ selected: boolean; @@ -135,10 +135,10 @@ export const FileListItemPath = styled('div')(({ theme }) => ({ maxWidth: '100%', })); -export const FileListExport = styled('ul')(({ theme }) => ({ +export const FileListExport = styled('ul')({ margin: 0, padding: 0, -})); +}); export const FileListItemExport = styled('li')<{ error: boolean }>(({ theme, error }) => ({ padding: '8px 16px 8px 16px', @@ -177,20 +177,20 @@ export const FileListItemExport = styled('li')<{ error: boolean }>(({ theme, err }, })); -export const FileListItemExportName = styled('div')(({ theme }) => ({ +export const FileListItemExportName = styled('div')({ display: 'flex', alignItems: 'center', gap: '8px', width: 'calc(100% - 20px)', -})); +}); -export const FileListItemExportNameContent = styled('span')(({ theme }) => ({ +export const FileListItemExportNameContent = styled('span')({ whiteSpace: 'nowrap', textOverflow: 'ellipsis', overflow: 'hidden', maxWidth: 'calc(100% - 160px)', display: 'inline-block', -})); +}); export const DefaultExport = styled('span')(({ theme }) => ({ display: 'inline-block', diff --git a/code/core/src/manager/components/sidebar/FileSearchListSkeleton.tsx b/code/core/src/manager/components/sidebar/FileSearchListSkeleton.tsx index 88437baed136..58e531f7ce16 100644 --- a/code/core/src/manager/components/sidebar/FileSearchListSkeleton.tsx +++ b/code/core/src/manager/components/sidebar/FileSearchListSkeleton.tsx @@ -4,13 +4,13 @@ import { styled } from 'storybook/theming'; import { FileList, FileListItem } from './FileList'; -const FileListItemContentWrapperSkeleton = styled('div')(({ theme }) => ({ +const FileListItemContentWrapperSkeleton = styled('div')({ display: 'flex', alignItems: 'flex-start', gap: '8px', alignSelf: 'stretch', padding: '8px 16px', -})); +}); const FileListItemContentSkeleton = styled('div')({ display: 'flex', diff --git a/code/core/src/manager/components/sidebar/RefIndicator.tsx b/code/core/src/manager/components/sidebar/RefIndicator.tsx index c7259181b29d..62b5daa555b3 100644 --- a/code/core/src/manager/components/sidebar/RefIndicator.tsx +++ b/code/core/src/manager/components/sidebar/RefIndicator.tsx @@ -1,7 +1,6 @@ import type { FC, MouseEventHandler } from 'react'; import React, { forwardRef, useCallback, useMemo } from 'react'; -import type { TooltipLinkListLink } from 'storybook/internal/components'; import { Spaced, TooltipLinkList, WithTooltip } from 'storybook/internal/components'; import { global } from '@storybook/global'; @@ -150,7 +149,7 @@ const Version = styled.div(({ theme }) => ({ const CurrentVersion: FC = ({ url, versions }) => { const currentVersionId = useMemo(() => { // @ts-expect-error (non strict) - const c = Object.entries(versions).find(([k, v]) => v === url); + const c = Object.entries(versions).find(([_k, v]) => v === url); return c && c[0] ? c[0] : 'current'; }, [url, versions]); diff --git a/code/core/src/manager/components/sidebar/Search.stories.tsx b/code/core/src/manager/components/sidebar/Search.stories.tsx index 045c89e39052..2a07331804ad 100644 --- a/code/core/src/manager/components/sidebar/Search.stories.tsx +++ b/code/core/src/manager/components/sidebar/Search.stories.tsx @@ -2,7 +2,6 @@ import React from 'react'; import type { Meta, StoryFn } from '@storybook/react-vite'; -import { action } from 'storybook/actions'; import type { API } from 'storybook/manager-api'; import { ManagerContext } from 'storybook/manager-api'; diff --git a/code/core/src/manager/components/sidebar/Search.tsx b/code/core/src/manager/components/sidebar/Search.tsx index a6113815b4e6..90c6263ebe40 100644 --- a/code/core/src/manager/components/sidebar/Search.tsx +++ b/code/core/src/manager/components/sidebar/Search.tsx @@ -258,7 +258,7 @@ export const Search = React.memo(function Search({ [api] ); - const onInputValueChange = useCallback((inputValue: string, stateAndHelpers: any) => { + const onInputValueChange = useCallback(() => { showAllComponents(false); }, []); diff --git a/code/core/src/manager/components/sidebar/SearchResults.stories.tsx b/code/core/src/manager/components/sidebar/SearchResults.stories.tsx index 19b8af0bdf64..214442f376f7 100644 --- a/code/core/src/manager/components/sidebar/SearchResults.stories.tsx +++ b/code/core/src/manager/components/sidebar/SearchResults.stories.tsx @@ -6,7 +6,7 @@ import { searchItem } from '../../utils/tree'; import { IconSymbols } from './IconSymbols'; import { SearchResults } from './SearchResults'; import { mockDataset } from './mockdata'; -import type { CombinedDataset, Refs, SearchItem } from './types'; +import type { CombinedDataset, 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 0fdee2722640..e0257c6d6879 100644 --- a/code/core/src/manager/components/sidebar/SearchResults.tsx +++ b/code/core/src/manager/components/sidebar/SearchResults.tsx @@ -119,7 +119,7 @@ const Highlight: FC> = React.memo(function return {result}; }); -const Title = styled.div(({ theme }) => ({ +const Title = styled.div({ display: 'grid', justifyContent: 'start', gridAutoColumns: 'auto', @@ -131,7 +131,7 @@ const Title = styled.div(({ theme }) => ({ overflow: 'hidden', textOverflow: 'ellipsis', }, -})); +}); const Path = styled.div(({ theme }) => ({ display: 'grid', diff --git a/code/core/src/manager/components/sidebar/Sidebar.tsx b/code/core/src/manager/components/sidebar/Sidebar.tsx index 3306ae21c817..499332bb3820 100644 --- a/code/core/src/manager/components/sidebar/Sidebar.tsx +++ b/code/core/src/manager/components/sidebar/Sidebar.tsx @@ -7,8 +7,12 @@ import { TooltipNote, WithTooltip, } from 'storybook/internal/components'; -import type { API_LoadedRefData, StoryIndex, TagsOptions } from 'storybook/internal/types'; -import type { StatusesByStoryIdAndTypeId } from 'storybook/internal/types'; +import type { + API_LoadedRefData, + StatusesByStoryIdAndTypeId, + StoryIndex, + TagsOptions, +} from 'storybook/internal/types'; import { global } from '@storybook/global'; import { PlusIcon } from '@storybook/icons'; diff --git a/code/core/src/manager/components/sidebar/TestingModule.stories.tsx b/code/core/src/manager/components/sidebar/TestingModule.stories.tsx index 121ec8fb3c05..58288219560d 100644 --- a/code/core/src/manager/components/sidebar/TestingModule.stories.tsx +++ b/code/core/src/manager/components/sidebar/TestingModule.stories.tsx @@ -1,11 +1,11 @@ import React from 'react'; import type { Listener } from 'storybook/internal/channels'; -import type { TestProviderStateByProviderId } from 'storybook/internal/types'; import { type Addon_Collection, type Addon_TestProviderType, Addon_TypesEnum, + type TestProviderStateByProviderId, } from 'storybook/internal/types'; import type { Meta, StoryObj } from '@storybook/react-vite'; diff --git a/code/core/src/manager/components/sidebar/TestingModule.tsx b/code/core/src/manager/components/sidebar/TestingModule.tsx index d63a68feaacd..e47394ff29fb 100644 --- a/code/core/src/manager/components/sidebar/TestingModule.tsx +++ b/code/core/src/manager/components/sidebar/TestingModule.tsx @@ -1,8 +1,7 @@ import React, { type SyntheticEvent, useCallback, useEffect, useRef, useState } from 'react'; import { once } from 'storybook/internal/client-logger'; -import { Button, IconButton, TooltipNote } from 'storybook/internal/components'; -import { WithTooltip } from 'storybook/internal/components'; +import { Button, IconButton, TooltipNote, WithTooltip } from 'storybook/internal/components'; import type { Addon_Collection, Addon_TestProviderType, diff --git a/code/core/src/manager/components/sidebar/Tree.tsx b/code/core/src/manager/components/sidebar/Tree.tsx index 96281fd811d7..1b1003ba107a 100644 --- a/code/core/src/manager/components/sidebar/Tree.tsx +++ b/code/core/src/manager/components/sidebar/Tree.tsx @@ -3,10 +3,10 @@ import React, { useCallback, useMemo, useRef } from 'react'; import { Button, IconButton, ListItem } from 'storybook/internal/components'; import { PRELOAD_ENTRIES } from 'storybook/internal/core-events'; -import type { StatusValue } from 'storybook/internal/types'; import { type API_HashEntry, type StatusByTypeId, + type StatusValue, type StatusesByStoryIdAndTypeId, type StoryId, } from 'storybook/internal/types'; diff --git a/code/core/src/manager/components/sidebar/TreeNode.tsx b/code/core/src/manager/components/sidebar/TreeNode.tsx index f86c0f00fd00..0ed04225b0e1 100644 --- a/code/core/src/manager/components/sidebar/TreeNode.tsx +++ b/code/core/src/manager/components/sidebar/TreeNode.tsx @@ -1,7 +1,7 @@ import type { ComponentProps, FC } from 'react'; import React from 'react'; -import { type FunctionInterpolation, type Theme, styled } from 'storybook/theming'; +import { type FunctionInterpolation, styled } from 'storybook/theming'; import { UseSymbol } from './IconSymbols'; import { CollapseIcon } from './components/CollapseIcon'; diff --git a/code/core/src/manager/manager-stores.mock.ts b/code/core/src/manager/manager-stores.mock.ts index 0c94203bad0e..a8427e3e506f 100644 --- a/code/core/src/manager/manager-stores.mock.ts +++ b/code/core/src/manager/manager-stores.mock.ts @@ -14,8 +14,10 @@ import type { TestProviderStateByProviderId, TestProviderStoreEvent, } from '../shared/test-provider-store'; -import { UNIVERSAL_TEST_PROVIDER_STORE_OPTIONS } from '../shared/test-provider-store'; -import { createTestProviderStore } from '../shared/test-provider-store'; +import { + UNIVERSAL_TEST_PROVIDER_STORE_OPTIONS, + createTestProviderStore, +} from '../shared/test-provider-store'; import type { UniversalStore } from '../shared/universal-store'; export const { diff --git a/code/core/src/manager/utils/status.tsx b/code/core/src/manager/utils/status.tsx index e53d5c67bfa4..aec17ce2f653 100644 --- a/code/core/src/manager/utils/status.tsx +++ b/code/core/src/manager/utils/status.tsx @@ -1,8 +1,11 @@ import type { ReactElement } from 'react'; import React from 'react'; -import type { StatusValue } from 'storybook/internal/types'; -import { type API_HashEntry, type StatusesByStoryIdAndTypeId } from 'storybook/internal/types'; +import { + type API_HashEntry, + type StatusValue, + type StatusesByStoryIdAndTypeId, +} from 'storybook/internal/types'; import { CircleIcon } from '@storybook/icons'; diff --git a/code/core/src/measure/box-model/labels.ts b/code/core/src/measure/box-model/labels.ts index f79662930852..578a93191058 100644 --- a/code/core/src/measure/box-model/labels.ts +++ b/code/core/src/measure/box-model/labels.ts @@ -98,7 +98,7 @@ function offset( labelPaddingSize: number, external: boolean ) { - let shift = (dir: Direction) => 0; + let shift = (_dir: Direction) => 0; let offsetX = 0; let offsetY = 0; diff --git a/code/core/src/node-logger/prompts/prompt-functions.ts b/code/core/src/node-logger/prompts/prompt-functions.ts index b1f559b31a58..283dc0c8fd3c 100644 --- a/code/core/src/node-logger/prompts/prompt-functions.ts +++ b/code/core/src/node-logger/prompts/prompt-functions.ts @@ -13,7 +13,6 @@ import type { TaskLogOptions, TextPromptOptions, } from './prompt-provider-base'; -import { asyncLocalStorage } from './storage'; // Re-export types for convenience export type { 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 1341774121e9..c9876e8ae19d 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 @@ -69,7 +69,7 @@ export const importFn: Mocked = vi.fn( ); export const docsRenderer = { - render: vi.fn().mockImplementation((context, parameters, element) => Promise.resolve()), + render: vi.fn().mockImplementation(() => Promise.resolve()), unmount: vi.fn(), }; export const teardownrenderToCanvas: Mock<(teardown: TeardownRenderToCanvas) => void> = vi.fn(); 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 577160c56cf6..8629c684900b 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 @@ -1093,7 +1093,7 @@ describe('PreviewWeb', () => { const [blockLoadersGate, openBlockLoadersGate] = createGate(); document.location.search = '?id=component-one--a'; - componentOneExports.default.loaders[0].mockImplementationOnce(async (input) => { + componentOneExports.default.loaders[0].mockImplementationOnce(async () => { openLoadersRanGate(); return blockLoadersGate; }); @@ -3223,7 +3223,7 @@ describe('PreviewWeb', () => { }); describe('when the current story changes importPath', () => { - const newImportFn = vi.fn(async (path) => ({ ...componentOneExports })); + const newImportFn = vi.fn(async () => ({ ...componentOneExports })); const newStoryIndex = { v: 5, 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 f8304c36b08d..d712289acfd5 100644 --- a/code/core/src/preview-api/modules/preview-web/PreviewWeb.tsx +++ b/code/core/src/preview-api/modules/preview-web/PreviewWeb.tsx @@ -1,5 +1,4 @@ -import type { ModuleImportFn, ProjectAnnotations } from 'storybook/internal/types'; -import type { Renderer } from 'storybook/internal/types'; +import type { ModuleImportFn, ProjectAnnotations, Renderer } from 'storybook/internal/types'; import { global } from '@storybook/global'; 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 2036afd75ab3..f0aedf8b3f05 100644 --- a/code/core/src/preview-api/modules/preview-web/PreviewWithSelection.tsx +++ b/code/core/src/preview-api/modules/preview-web/PreviewWithSelection.tsx @@ -22,9 +22,17 @@ import { MdxFileWithNoCsfReferencesError, NoStoryMatchError, } from 'storybook/internal/preview-errors'; -import type { DocsIndexEntry, StoryIndex } from 'storybook/internal/types'; -import type { Args, Globals, Renderer, StoryId, ViewMode } from 'storybook/internal/types'; -import type { ModuleImportFn, ProjectAnnotations } from 'storybook/internal/types'; +import type { + Args, + DocsIndexEntry, + Globals, + ModuleImportFn, + ProjectAnnotations, + Renderer, + StoryId, + StoryIndex, + ViewMode, +} from 'storybook/internal/types'; import invariant from 'tiny-invariant'; 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 232118f38afc..7725d2ffa670 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 @@ -46,7 +46,7 @@ export class DocsContext implements DocsContextProps this.nameToStoryId = new Map(); this.attachedCSFFiles = new Set(); - csfFiles.forEach((csfFile, index) => { + csfFiles.forEach((csfFile) => { this.referenceCSFFile(csfFile); }); } 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 9a373f0535b4..04c6391c2d3d 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,9 +1,13 @@ import type { Channel } from 'storybook/internal/channels'; import { DOCS_RENDERED } from 'storybook/internal/core-events'; -import type { Renderer, StoryId } from 'storybook/internal/types'; -import type { CSFFile, PreparedStory } from 'storybook/internal/types'; -import type { IndexEntry } from 'storybook/internal/types'; -import type { RenderContextCallbacks } from 'storybook/internal/types'; +import type { + CSFFile, + IndexEntry, + PreparedStory, + RenderContextCallbacks, + Renderer, + StoryId, +} from 'storybook/internal/types'; import type { StoryStore } from '../../../store'; import { DocsContext } from '../docs-context/DocsContext'; 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 809f8c19fe71..7feebcafc6e3 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,9 +1,13 @@ import type { Channel } from 'storybook/internal/channels'; import { DOCS_RENDERED } from 'storybook/internal/core-events'; -import type { Renderer, StoryId } from 'storybook/internal/types'; -import type { CSFFile, ModuleExports } from 'storybook/internal/types'; -import type { IndexEntry } from 'storybook/internal/types'; -import type { RenderContextCallbacks } from 'storybook/internal/types'; +import type { + CSFFile, + IndexEntry, + ModuleExports, + RenderContextCallbacks, + Renderer, + StoryId, +} from 'storybook/internal/types'; import type { StoryStore } from '../../store'; import { DocsContext } from '../docs-context/DocsContext'; diff --git a/code/core/src/preview-api/modules/preview-web/render/Render.ts b/code/core/src/preview-api/modules/preview-web/render/Render.ts index 18c77fbb108b..3fba12aa076f 100644 --- a/code/core/src/preview-api/modules/preview-web/render/Render.ts +++ b/code/core/src/preview-api/modules/preview-web/render/Render.ts @@ -1,5 +1,4 @@ -import type { Renderer, StoryId } from 'storybook/internal/types'; -import type { StoryRenderOptions } from 'storybook/internal/types'; +import type { Renderer, StoryId, StoryRenderOptions } from 'storybook/internal/types'; export type RenderType = 'story' | 'docs'; 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 3c8d85712b6c..d18972978a88 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 @@ -12,7 +12,7 @@ import type { import { ReporterAPI, type StoryStore } from '../../store'; import { PREPARE_ABORTED } from './Render'; -import { StoryRender, serializeError } from './StoryRender'; +import { StoryRender } from './StoryRender'; const entry = { type: 'story', @@ -213,6 +213,7 @@ describe('StoryRender', () => { it('errors if play function destructures mount but does not call it', async () => { const story = buildStory({ usesMount: true, + // eslint-disable-next-line @typescript-eslint/no-unused-vars playFunction: async ({ mount }) => { // forget to call mount }, 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 80c1a56211b1..7a114d91bf43 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,3 +1,4 @@ +/* eslint-disable @typescript-eslint/no-unused-vars */ import { expect, test } from 'vitest'; import { getUsedProps } from './mount-utils'; diff --git a/code/core/src/preview-api/modules/store/ArgsStore.ts b/code/core/src/preview-api/modules/store/ArgsStore.ts index c4b353431e80..f41fd47c62a2 100644 --- a/code/core/src/preview-api/modules/store/ArgsStore.ts +++ b/code/core/src/preview-api/modules/store/ArgsStore.ts @@ -1,5 +1,4 @@ -import type { PreparedStory } from 'storybook/internal/types'; -import type { Args, StoryId } from 'storybook/internal/types'; +import type { Args, PreparedStory, StoryId } from 'storybook/internal/types'; import { DEEPLY_EQUAL, combineArgs, deepDiff, mapArgsToTypes, validateOptions } from './args'; diff --git a/code/core/src/preview-api/modules/store/StoryIndexStore.ts b/code/core/src/preview-api/modules/store/StoryIndexStore.ts index d9dfa82c4716..d517327bd75a 100644 --- a/code/core/src/preview-api/modules/store/StoryIndexStore.ts +++ b/code/core/src/preview-api/modules/store/StoryIndexStore.ts @@ -1,6 +1,12 @@ import { MissingStoryAfterHmrError } from 'storybook/internal/preview-errors'; -import type { ComponentTitle, Path, StoryId, StoryName } from 'storybook/internal/types'; -import type { IndexEntry, StoryIndex } from 'storybook/internal/types'; +import type { + ComponentTitle, + IndexEntry, + Path, + StoryId, + StoryIndex, + StoryName, +} from 'storybook/internal/types'; import memoize from 'memoizerific'; 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 1c5deac9b8c3..d8518d7ed0a2 100644 --- a/code/core/src/preview-api/modules/store/autoTitle.test.ts +++ b/code/core/src/preview-api/modules/store/autoTitle.test.ts @@ -6,7 +6,7 @@ import { userOrAutoTitleFromSpecifier as userOrAuto } from './autoTitle'; expect.addSnapshotSerializer({ print: (val: any) => val, - test: (val: any) => true, + test: () => true, }); // Make these two the same so `normalizeStoriesEntry` doesn't change anything 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 606fed2d8e05..569cf89b2d39 100644 --- a/code/core/src/preview-api/modules/store/csf/composeConfigs.ts +++ b/code/core/src/preview-api/modules/store/csf/composeConfigs.ts @@ -1,5 +1,8 @@ -import type { ModuleExports, NormalizedProjectAnnotations } from 'storybook/internal/types'; -import type { Renderer } from 'storybook/internal/types'; +import type { + ModuleExports, + NormalizedProjectAnnotations, + Renderer, +} from 'storybook/internal/types'; import { global } from '@storybook/global'; 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 7e83b55950d6..f2d0addb4531 100644 --- a/code/core/src/preview-api/modules/store/csf/normalizeComponentAnnotations.ts +++ b/code/core/src/preview-api/modules/store/csf/normalizeComponentAnnotations.ts @@ -1,6 +1,9 @@ import { sanitize } from 'storybook/internal/csf'; -import type { ModuleExports, NormalizedComponentAnnotations } from 'storybook/internal/types'; -import type { Renderer } from 'storybook/internal/types'; +import type { + ModuleExports, + NormalizedComponentAnnotations, + Renderer, +} from 'storybook/internal/types'; import { normalizeInputTypes } from './normalizeInputTypes'; 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 63b42fa8f36a..08a6efcdff23 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 @@ -153,7 +153,7 @@ describe('prepareStory', () => { const { parameters } = prepareStory( { id, name, moduleExport }, { id, title }, - { render: (args: any) => {} } + { render: (_args: any) => {} } ); expect(parameters).toEqual(expect.objectContaining({ __isArgsStory: true })); 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 be45c366a0b4..82559bd593d7 100644 --- a/code/core/src/preview-api/modules/store/csf/prepareStory.ts +++ b/code/core/src/preview-api/modules/store/csf/prepareStory.ts @@ -2,7 +2,6 @@ import { type CleanupCallback, combineTags, includeConditionalArg } from 'storyb import { NoRenderFunctionError } from 'storybook/internal/preview-errors'; import type { Args, - ArgsStoryFn, Globals, ModuleExport, NormalizedComponentAnnotations, @@ -19,7 +18,6 @@ import type { } from 'storybook/internal/types'; import { global } from '@storybook/global'; -import { global as globalThis } from '@storybook/global'; import { applyHooks } from '../../addons'; import { mountDestructured } from '../../preview-web/render/mount-utils'; @@ -188,7 +186,7 @@ function preparePartialAnnotations( // will have a limited cost. If this proves misguided, we can refactor it. const defaultTags = ['dev', 'test']; - const extraTags = globalThis.DOCS_OPTIONS?.autodocs === true ? ['autodocs'] : []; + const extraTags = global.DOCS_OPTIONS?.autodocs === true ? ['autodocs'] : []; /** * DISCLAIMER: This feels like a hack but seems like it's the only way to override the autodocs * tag for test-fn stories. That's because the Story index does not include negated tags e.g. 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 c9b4dcec177a..a63e4e158221 100644 --- a/code/core/src/preview-api/modules/store/csf/processCSFFile.ts +++ b/code/core/src/preview-api/modules/store/csf/processCSFFile.ts @@ -1,11 +1,14 @@ import { logger } from 'storybook/internal/client-logger'; import type { Story } from 'storybook/internal/csf'; import { getStoryChildren, isExportStory, isStory, toTestId } from 'storybook/internal/csf'; -import type { ComponentTitle, Parameters, Path, Renderer } from 'storybook/internal/types'; import type { CSFFile, + ComponentTitle, ModuleExports, NormalizedComponentAnnotations, + Parameters, + Path, + Renderer, } from 'storybook/internal/types'; import { normalizeComponentAnnotations } from './normalizeComponentAnnotations'; 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 2252d1972ba8..77effca40f81 100644 --- a/code/core/src/preview-api/modules/store/decorators.test.ts +++ b/code/core/src/preview-api/modules/store/decorators.test.ts @@ -74,7 +74,7 @@ describe('client-api.decorators', () => { const decoratedStories = []; const decorators = [ // @ts-expect-error (not defined) - (s, c) => { + (s) => { // @ts-expect-error (not defined) decoratedStories.push = s; return s(); @@ -99,7 +99,7 @@ describe('client-api.decorators', () => { }); const decorators = [ // @ts-expect-error (not defined) - async (s, c) => { + async (s) => { // The fence here simulates async-ness in react rendering an element (`` doesn't run `S()` straight away) await fence; s(); diff --git a/code/core/src/preview-api/modules/store/sortStories.ts b/code/core/src/preview-api/modules/store/sortStories.ts index 72bc4b2f58ec..7eb44f95e1e0 100644 --- a/code/core/src/preview-api/modules/store/sortStories.ts +++ b/code/core/src/preview-api/modules/store/sortStories.ts @@ -4,10 +4,12 @@ import type { Addon_StorySortParameterV7, IndexEntry, IndexEntryLegacy, + Parameters, + Path, + PreparedStory, + Renderer, StoryIndexEntry, } from 'storybook/internal/types'; -import type { Parameters, Path, Renderer } from 'storybook/internal/types'; -import type { PreparedStory } from 'storybook/internal/types'; import { dedent } from 'ts-dedent'; diff --git a/code/core/src/preview-api/modules/store/storySort.ts b/code/core/src/preview-api/modules/store/storySort.ts index e5700124df12..feb0cb93f1af 100644 --- a/code/core/src/preview-api/modules/store/storySort.ts +++ b/code/core/src/preview-api/modules/store/storySort.ts @@ -1,8 +1,8 @@ import type { Addon_StorySortComparatorV7, Addon_StorySortObjectParameter, + IndexEntry, } from 'storybook/internal/types'; -import type { IndexEntry } from 'storybook/internal/types'; const STORY_KIND_PATH_SEPARATOR = /\s*\/\s*/; diff --git a/code/core/src/preview-errors.ts b/code/core/src/preview-errors.ts index 7abb4ea12ccd..a21ec316aa3b 100644 --- a/code/core/src/preview-errors.ts +++ b/code/core/src/preview-errors.ts @@ -1,7 +1,6 @@ import { dedent } from 'ts-dedent'; -import type { Status } from './shared/status-store'; -import type { StatusTypeId } from './shared/status-store'; +import type { Status, StatusTypeId } from './shared/status-store'; import { StorybookError } from './storybook-error'; /** diff --git a/code/core/src/preview/preview-navigator.stories.tsx b/code/core/src/preview/preview-navigator.stories.tsx index 1d6e083cfa14..3b4ca9569d39 100644 --- a/code/core/src/preview/preview-navigator.stories.tsx +++ b/code/core/src/preview/preview-navigator.stories.tsx @@ -10,7 +10,7 @@ const meta: Meta = { parameters: { layout: 'fullscreen', }, - render: (args) => { + render: () => { return
This is the story content
; }, args: { diff --git a/code/core/src/router/utils.ts b/code/core/src/router/utils.ts index a21a2c5eae07..a340713802f3 100644 --- a/code/core/src/router/utils.ts +++ b/code/core/src/router/utils.ts @@ -2,7 +2,6 @@ import { once } from 'storybook/internal/client-logger'; import { isEqual as deepEqual, isPlainObject } from 'es-toolkit/predicate'; import memoize from 'memoizerific'; -import type { Options as QueryOptions } from 'picoquery'; import { parse, stringify } from 'picoquery'; import { dedent } from 'ts-dedent'; diff --git a/code/core/src/server-errors.ts b/code/core/src/server-errors.ts index a69ab949bd04..9b3bf7a38069 100644 --- a/code/core/src/server-errors.ts +++ b/code/core/src/server-errors.ts @@ -1,8 +1,7 @@ import picocolors from 'picocolors'; import { dedent } from 'ts-dedent'; -import type { Status } from './shared/status-store'; -import type { StatusTypeId } from './shared/status-store'; +import type { Status, StatusTypeId } from './shared/status-store'; import { StorybookError } from './storybook-error'; /** diff --git a/code/core/src/shared/status-store/index.test.ts b/code/core/src/shared/status-store/index.test.ts index 0373f78ff26e..4526699cbd8e 100644 --- a/code/core/src/shared/status-store/index.test.ts +++ b/code/core/src/shared/status-store/index.test.ts @@ -7,7 +7,6 @@ import { useUniversalStore } from '../universal-store/use-universal-store-manage import { type Status, type StatusStoreEvent, - StatusValue, type StatusesByStoryIdAndTypeId, createStatusStore, } from './index'; @@ -390,7 +389,7 @@ describe('statusStore', () => { it('should update existing statuses and add new ones in a single operation', () => { // Arrange - create a status store - const { getStatusStoreByTypeId, fullStatusStore } = createStatusStore({ + const { getStatusStoreByTypeId } = createStatusStore({ universalStatusStore: new MockUniversalStore({ ...UNIVERSAL_STATUS_STORE_OPTIONS, initialState, @@ -428,7 +427,7 @@ describe('statusStore', () => { it('should error when setting statuses with wrong typeId', () => { // Arrange - create a status store - const { getStatusStoreByTypeId, fullStatusStore } = createStatusStore({ + const { getStatusStoreByTypeId } = createStatusStore({ universalStatusStore: new MockUniversalStore(UNIVERSAL_STATUS_STORE_OPTIONS), environment: 'manager', }); diff --git a/code/core/src/shared/test-provider-store/index.test.ts b/code/core/src/shared/test-provider-store/index.test.ts index b8946e49a6da..c9fad06fdbf9 100644 --- a/code/core/src/shared/test-provider-store/index.test.ts +++ b/code/core/src/shared/test-provider-store/index.test.ts @@ -77,7 +77,7 @@ describe('testProviderStore', () => { describe('getState', () => { it('should initially return pending state for new provider', () => { // Arrange - create empty test provider store - const { getTestProviderStoreById, fullTestProviderStore } = createTestProviderStore({ + const { getTestProviderStoreById } = createTestProviderStore({ universalTestProviderStore: new MockUniversalStore< TestProviderStateByProviderId, TestProviderStoreEvent diff --git a/code/core/src/shared/universal-store/index.test.ts b/code/core/src/shared/universal-store/index.test.ts index 4bb03a1a0589..b9268ec33659 100644 --- a/code/core/src/shared/universal-store/index.test.ts +++ b/code/core/src/shared/universal-store/index.test.ts @@ -13,7 +13,7 @@ const mockChannelListeners = new Map void>>(); const mockChannel = { on: vi.fn((eventType: string, listener: (...args: any[]) => void) => { - const [universalStorePrefix, environmentId, universalStoreId] = eventType.split(':'); + const [_universalStorePrefix, _environmentId, universalStoreId] = eventType.split(':'); if (!mockChannelListeners.has(universalStoreId)) { mockChannelListeners.set(universalStoreId, new Set()); } @@ -29,7 +29,7 @@ const mockChannel = { listeners.delete(listener); }), emit: vi.fn((eventType: string, channelEvent: ChannelEvent) => { - const [universalStorePrefix, environmentId, universalStoreId] = eventType.split(':'); + const [_universalStorePrefix, _environmentId, universalStoreId] = eventType.split(':'); if (!mockChannelListeners.has(universalStoreId)) { return; } @@ -930,7 +930,7 @@ You should reuse the existing instance instead of trying to create a new one.`); it('should throw when trying to set state before the store is ready', async () => { // Arrange - create a leader and a follower - const leader = UniversalStore.create({ + UniversalStore.create({ id: 'env1:test', leader: true, initialState: { count: 0 }, @@ -1115,7 +1115,7 @@ You should reuse the existing instance instead of trying to create a new one.`); it('should throw when trying to send an event before the store is ready', async () => { // Arrange - create a leader and a follower - const leader = UniversalStore.create({ + UniversalStore.create({ id: 'env1:test', leader: true, initialState: { count: 0 }, diff --git a/code/core/src/shared/universal-store/use-universal-store-manager.test.ts b/code/core/src/shared/universal-store/use-universal-store-manager.test.ts index c16ff4d201cb..2ec95d6a29c6 100644 --- a/code/core/src/shared/universal-store/use-universal-store-manager.test.ts +++ b/code/core/src/shared/universal-store/use-universal-store-manager.test.ts @@ -13,7 +13,7 @@ const mockChannelListeners = new Map void>>(); const mockChannel = { on: vi.fn((eventType: string, listener: (...args: any[]) => void) => { - const [universalStorePrefix, environmentId, universalStoreId] = eventType.split(':'); + const [_universalStorePrefix, _environmentId, universalStoreId] = eventType.split(':'); if (!mockChannelListeners.has(universalStoreId)) { mockChannelListeners.set(universalStoreId, new Set()); } @@ -29,7 +29,7 @@ const mockChannel = { listeners.delete(listener); }), emit: vi.fn((eventType: string, channelEvent: ChannelEvent) => { - const [universalStorePrefix, environmentId, universalStoreId] = eventType.split(':'); + const [_universalStorePrefix, _environmentId, universalStoreId] = eventType.split(':'); if (!mockChannelListeners.has(universalStoreId)) { return; } diff --git a/code/core/src/shared/utils/module.ts b/code/core/src/shared/utils/module.ts index e4aa51f84e35..606e5f09dbab 100644 --- a/code/core/src/shared/utils/module.ts +++ b/code/core/src/shared/utils/module.ts @@ -76,7 +76,7 @@ export async function importModule( delete require.cache[require.resolve(path)]; } mod = require(path); - } catch (requireError) { + } catch { /* If everything fails, throw the original import error, as the require error won't be helpful in Node 20 requireError will always be "Error [ERR_REQUIRE_CYCLE_MODULE]: Cannot require() ES Module" diff --git a/code/core/src/telemetry/anonymous-id.ts b/code/core/src/telemetry/anonymous-id.ts index 8ed5b641f306..46bc10a95ada 100644 --- a/code/core/src/telemetry/anonymous-id.ts +++ b/code/core/src/telemetry/anonymous-id.ts @@ -46,7 +46,7 @@ export const getAnonymousProjectId = () => { }); anonymousProjectId = oneWayHash(unhashedProjectId(String(originBuffer), projectRootPath)); - } catch (_) { + } catch { // } diff --git a/code/core/src/telemetry/exec-command-count-lines.test.ts b/code/core/src/telemetry/exec-command-count-lines.test.ts index eacfe9f72952..7b117c6174a1 100644 --- a/code/core/src/telemetry/exec-command-count-lines.test.ts +++ b/code/core/src/telemetry/exec-command-count-lines.test.ts @@ -22,7 +22,7 @@ type ExecaStreamer = typeof Promise & { function createExecaStreamer() { let resolver: () => void; - const promiseLike: ExecaStreamer = new Promise((aResolver, aRejecter) => { + const promiseLike: ExecaStreamer = new Promise((aResolver) => { resolver = aResolver; }) as any; diff --git a/code/core/src/telemetry/telemetry.ts b/code/core/src/telemetry/telemetry.ts index 064596a84a75..4fd4fa96db5e 100644 --- a/code/core/src/telemetry/telemetry.ts +++ b/code/core/src/telemetry/telemetry.ts @@ -41,7 +41,7 @@ const getOperatingSystem = (): 'Windows' | 'macOS' | 'Linux' | `Other: ${string} } return `Other: ${platform}`; - } catch (_err) { + } catch { return 'Unknown'; } }; diff --git a/code/core/src/test/spy.ts b/code/core/src/test/spy.ts index 8e9537e5f091..e09f4d760b63 100644 --- a/code/core/src/test/spy.ts +++ b/code/core/src/test/spy.ts @@ -1,9 +1,10 @@ -import type { Mock, MockInstance } from '@vitest/spy'; import { type MaybeMocked, type MaybeMockedDeep, type MaybePartiallyMocked, type MaybePartiallyMockedDeep, + type Mock, + type MockInstance, isMockFunction, mocks, fn as vitestFn, diff --git a/code/core/src/test/utils.ts b/code/core/src/test/utils.ts index f7afc4a69277..f5fdf243fa95 100644 --- a/code/core/src/test/utils.ts +++ b/code/core/src/test/utils.ts @@ -1,5 +1,5 @@ -export type Promisify = Fn extends { (...args: infer Args): infer Return } - ? { (...args: Args): Return extends Promise ? Return : Promise } +export type Promisify = Fn extends { <_T>(..._args: infer Args): infer Return } + ? { <_T>(...args: Args): Return extends Promise ? Return : Promise } : Fn extends { (...args: infer Args): infer Return } ? { (...args: Args): Return extends Promise ? Return : Promise } : Fn; diff --git a/code/core/src/types/modules/addons.ts b/code/core/src/types/modules/addons.ts index 01f56adc965f..91cef734d8b5 100644 --- a/code/core/src/types/modules/addons.ts +++ b/code/core/src/types/modules/addons.ts @@ -1,6 +1,5 @@ import type { FC, PropsWithChildren, ReactElement, ReactNode } from 'react'; -import type { State } from '../../manager-api'; import type { RenderData as RouterData } from '../../router/types'; import type { ThemeVars } from '../../theming/types'; import type { API_LayoutCustomisations, API_SidebarOptions } from './api'; @@ -155,7 +154,7 @@ export interface Addon_StoryApi { [k: string]: string | Addon_ClientApiReturnFn; } -export interface Addon_ClientStoryApi {} +export interface Addon_ClientStoryApi<_StoryFnReturnType = unknown> {} export type Addon_LoadFn = () => any; export type Addon_RequireContext = any; // FIXME @@ -302,7 +301,7 @@ export interface Addon_BaseMeta { subcomponents?: Record; } -export type Addon_BaseStoryObject = { +export type Addon_BaseStoryObject<_TArgs, _StoryFnReturnType> = { /** Override the display name in the UI */ storyName?: string; }; diff --git a/code/core/template/__mocks__/lodash-es/add.js b/code/core/template/__mocks__/lodash-es/add.js index d12fc6f83033..77704d6bc8a7 100644 --- a/code/core/template/__mocks__/lodash-es/add.js +++ b/code/core/template/__mocks__/lodash-es/add.js @@ -1,4 +1,4 @@ -function add(a, b) { +function add() { return 'mocked 3'; } diff --git a/code/core/template/stories/component-test.unhandled-errors.stories.ts b/code/core/template/stories/component-test.unhandled-errors.stories.ts index 01103f88847c..01a00af8c787 100644 --- a/code/core/template/stories/component-test.unhandled-errors.stories.ts +++ b/code/core/template/stories/component-test.unhandled-errors.stories.ts @@ -20,7 +20,7 @@ export default { export const Default = { play: async (context) => { - const { args, canvasElement } = context; + const { canvasElement } = context; const canvas = within(canvasElement); await userEvent.click(canvas.getByRole('button')); }, diff --git a/code/core/template/stories/decorators.stories.ts b/code/core/template/stories/decorators.stories.ts index 4581d1c2ed1b..21b97e8b9926 100644 --- a/code/core/template/stories/decorators.stories.ts +++ b/code/core/template/stories/decorators.stories.ts @@ -57,7 +57,7 @@ export const Hooks = { text: 'text', condition: true, }, - play: async ({ id, args }: PlayFunctionContext) => { + play: async ({ id }: PlayFunctionContext) => { const channel = globalThis.__STORYBOOK_ADDONS_CHANNEL__; await channel.emit(RESET_STORY_ARGS, { storyId: id }); await new Promise((resolve) => channel.once(STORY_ARGS_UPDATED, resolve)); diff --git a/code/core/template/stories/expect.stories.tsx b/code/core/template/stories/expect.stories.tsx index 5b75502586e9..3f3cb57bd827 100644 --- a/code/core/template/stories/expect.stories.tsx +++ b/code/core/template/stories/expect.stories.tsx @@ -1,5 +1,3 @@ -import React from 'react'; - import type { Meta, StoryObj } from '@storybook/react'; import { expect } from 'storybook/test'; diff --git a/code/core/template/stories/test/ModuleAutoMocking.stories.ts b/code/core/template/stories/test/ModuleAutoMocking.stories.ts index 4d9c750437aa..587d6ab63a1c 100644 --- a/code/core/template/stories/test/ModuleAutoMocking.stories.ts +++ b/code/core/template/stories/test/ModuleAutoMocking.stories.ts @@ -1,7 +1,6 @@ import { global as globalThis } from '@storybook/global'; import { expect } from 'storybook/test'; -import { v4 } from 'uuid'; import { fn } from './ModuleAutoMocking.utils'; diff --git a/code/e2e-tests/addon-backgrounds.spec.ts b/code/e2e-tests/addon-backgrounds.spec.ts index 70cb2424ef19..34817a359475 100644 --- a/code/e2e-tests/addon-backgrounds.spec.ts +++ b/code/e2e-tests/addon-backgrounds.spec.ts @@ -4,7 +4,6 @@ import process from 'process'; import { SbPage } from './util'; const storybookUrl = process.env.STORYBOOK_URL || 'http://localhost:8001'; -const templateName = process.env.STORYBOOK_TEMPLATE_NAME || ''; test.describe('addon-backgrounds', () => { test.beforeEach(async ({ page }) => { diff --git a/code/e2e-tests/storybook-hooks.spec.ts b/code/e2e-tests/storybook-hooks.spec.ts index b41ad86b030d..d410fd61464f 100644 --- a/code/e2e-tests/storybook-hooks.spec.ts +++ b/code/e2e-tests/storybook-hooks.spec.ts @@ -32,7 +32,7 @@ test.describe('Storybook hooks', () => { await new SbPage(page, expect).waitUntilLoaded(); }); - test('should call beforeAll upon loading Storybook', async ({ page }, { titlePath }) => { + test('should call beforeAll upon loading Storybook', async ({ page }) => { const sbPage = new SbPage(page, expect); await sbPage.navigateToStory('example/button', 'primary'); 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 758ac2d93d72..2eec617cd71e 100644 --- a/code/frameworks/angular/src/client/angular-beta/ComputesTemplateFromComponent.test.ts +++ b/code/frameworks/angular/src/client/angular-beta/ComputesTemplateFromComponent.test.ts @@ -1,5 +1,4 @@ import { Component } from '@angular/core'; -import type { ArgTypes } from 'storybook/internal/types'; import { describe, it, expect } from 'vitest'; import { computesTemplateFromComponent, @@ -29,8 +28,8 @@ describe('angular template decorator', () => { const props = { isDisabled: true, label: 'Hello world', - onClick: ($event: any) => {}, - 'dash-out': ($event: any) => {}, + onClick: () => {}, + 'dash-out': () => {}, }; const source = computesTemplateFromComponent(component, props); expect(source).toEqual( @@ -290,7 +289,7 @@ describe('angular template decorator', () => { const props = { isDisabled: true, label: 'Hello world', - onClick: ($event: any) => {}, + onClick: () => {}, }; const source = computesTemplateFromComponent(component, props); expect(source).toEqual( @@ -312,8 +311,7 @@ describe('angular source decorator', () => { it('with no props should generate simple tag', () => { const component = InputComponent; const props = {}; - const argTypes: ArgTypes = {}; - const source = computesTemplateSourceFromComponent(component, props, argTypes); + const source = computesTemplateSourceFromComponent(component, props); expect(source).toEqual(''); }); @@ -326,8 +324,8 @@ describe('angular source decorator', () => { it('should add component ng-container', async () => { const component = WithoutSelectorComponent; const props = {}; - const argTypes: ArgTypes = {}; - const source = computesTemplateSourceFromComponent(component, props, argTypes); + + const source = computesTemplateSourceFromComponent(component, props); expect(source).toEqual( `` ); @@ -344,8 +342,8 @@ describe('angular source decorator', () => { it('should add attribute to template', async () => { const component = WithAttributeComponent; const props = {}; - const argTypes: ArgTypes = {}; - const source = computesTemplateSourceFromComponent(component, props, argTypes); + + const source = computesTemplateSourceFromComponent(component, props); expect(source).toEqual(``); }); }); @@ -360,8 +358,8 @@ describe('angular source decorator', () => { it('should add attribute to template', async () => { const component = WithAttributeValueComponent; const props = {}; - const argTypes: ArgTypes = {}; - const source = computesTemplateSourceFromComponent(component, props, argTypes); + + const source = computesTemplateSourceFromComponent(component, props); expect(source).toEqual(``); }); }); @@ -376,8 +374,8 @@ describe('angular source decorator', () => { it('should create a div and add attribute to template', async () => { const component = WithAttributeOnlyComponent; const props = {}; - const argTypes: ArgTypes = {}; - const source = computesTemplateSourceFromComponent(component, props, argTypes); + + const source = computesTemplateSourceFromComponent(component, props); expect(source).toEqual(`
`); }); }); @@ -392,8 +390,8 @@ describe('angular source decorator', () => { it('should create without separate closing tag', async () => { const component = VoidElementWithAttributeComponent; const props = {}; - const argTypes: ArgTypes = {}; - const source = computesTemplateSourceFromComponent(component, props, argTypes); + + const source = computesTemplateSourceFromComponent(component, props); expect(source).toEqual(``); }); }); @@ -408,8 +406,8 @@ describe('angular source decorator', () => { it('should create a div and add attribute to template', async () => { const component = WithAttributeOnlyComponent; const props = {}; - const argTypes: ArgTypes = {}; - const source = computesTemplateSourceFromComponent(component, props, argTypes); + + const source = computesTemplateSourceFromComponent(component, props); expect(source).toEqual(`
`); }); }); @@ -424,8 +422,8 @@ describe('angular source decorator', () => { it('should create and add attribute to template without separate closing tag', async () => { const component = VoidElementWithAttributeComponent; const props = {}; - const argTypes: ArgTypes = {}; - const source = computesTemplateSourceFromComponent(component, props, argTypes); + + const source = computesTemplateSourceFromComponent(component, props); expect(source).toEqual(``); }); }); @@ -440,8 +438,8 @@ describe('angular source decorator', () => { it('should add class to template', async () => { const component = WithClassComponent; const props = {}; - const argTypes: ArgTypes = {}; - const source = computesTemplateSourceFromComponent(component, props, argTypes); + + const source = computesTemplateSourceFromComponent(component, props); expect(source).toEqual(``); }); }); @@ -456,8 +454,8 @@ describe('angular source decorator', () => { it('should create a div and add attribute to template', async () => { const component = WithClassComponent; const props = {}; - const argTypes: ArgTypes = {}; - const source = computesTemplateSourceFromComponent(component, props, argTypes); + + const source = computesTemplateSourceFromComponent(component, props); expect(source).toEqual(`
`); }); }); @@ -472,8 +470,8 @@ describe('angular source decorator', () => { it('should use the first selector', async () => { const component = WithMultipleSelectorsComponent; const props = {}; - const argTypes: ArgTypes = {}; - const source = computesTemplateSourceFromComponent(component, props, argTypes); + + const source = computesTemplateSourceFromComponent(component, props); expect(source).toEqual(``); }); }); @@ -488,8 +486,8 @@ describe('angular source decorator', () => { it('should use the first selector', async () => { const component = WithMultipleSelectorsComponent; const props = {}; - const argTypes: ArgTypes = {}; - const source = computesTemplateSourceFromComponent(component, props, argTypes); + + const source = computesTemplateSourceFromComponent(component, props); expect(source).toEqual(``); }); }); @@ -504,8 +502,8 @@ describe('angular source decorator', () => { it('should use the first selector', async () => { const component = WithMultipleSelectorsComponent; const props = {}; - const argTypes: ArgTypes = {}; - const source = computesTemplateSourceFromComponent(component, props, argTypes); + + const source = computesTemplateSourceFromComponent(component, props); expect(source).toEqual(``); }); }); @@ -520,8 +518,8 @@ describe('angular source decorator', () => { it('should use the first selector', async () => { const component = WithMultipleSelectorsComponent; const props = {}; - const argTypes: ArgTypes = {}; - const source = computesTemplateSourceFromComponent(component, props, argTypes); + + const source = computesTemplateSourceFromComponent(component, props); expect(source).toEqual(``); }); }); @@ -537,8 +535,8 @@ describe('angular source decorator', () => { it('should use the first selector', async () => { const component = WithMultipleSelectorsComponent; const props = {}; - const argTypes: ArgTypes = {}; - const source = computesTemplateSourceFromComponent(component, props, argTypes); + + const source = computesTemplateSourceFromComponent(component, props); expect(source).toEqual(``); }); }); @@ -554,8 +552,8 @@ describe('angular source decorator', () => { it('should use the first selector', async () => { const component = WithMultipleSelectorsComponent; const props = {}; - const argTypes: ArgTypes = {}; - const source = computesTemplateSourceFromComponent(component, props, argTypes); + + const source = computesTemplateSourceFromComponent(component, props); expect(source).toEqual(`
`); }); }); @@ -564,8 +562,8 @@ describe('angular source decorator', () => { it('should generate tag-only template with no props', () => { const component = InputComponent; const props = {}; - const argTypes: ArgTypes = {}; - const source = computesTemplateSourceFromComponent(component, props, argTypes); + + const source = computesTemplateSourceFromComponent(component, props); expect(source).toEqual(``); }); it('with props should generate tag with properties', () => { @@ -577,8 +575,8 @@ describe('angular source decorator', () => { counter: 4, 'aria-label': 'Hello world', }; - const argTypes: ArgTypes = {}; - const source = computesTemplateSourceFromComponent(component, props, argTypes); + + const source = computesTemplateSourceFromComponent(component, props); expect(source).toEqual( `` ); @@ -589,11 +587,11 @@ describe('angular source decorator', () => { const props = { isDisabled: true, label: 'Hello world', - onClick: ($event: any) => {}, - 'dash-out': ($event: any) => {}, + onClick: () => {}, + 'dash-out': () => {}, }; - const argTypes: ArgTypes = {}; - const source = computesTemplateSourceFromComponent(component, props, argTypes); + + const source = computesTemplateSourceFromComponent(component, props); expect(source).toEqual( `` ); @@ -604,8 +602,8 @@ describe('angular source decorator', () => { const props = { color: '#ffffff', }; - const argTypes: ArgTypes = {}; - const source = computesTemplateSourceFromComponent(component, props, argTypes); + + const source = computesTemplateSourceFromComponent(component, props); expect(source).toEqual(``); }); }); @@ -618,24 +616,7 @@ describe('angular source decorator', () => { label: 'Hello world', accent: ButtonAccent.High, }; - const argTypes: ArgTypes = { - accent: { - control: { - options: ['Normal', 'High'], - type: 'radio', - }, - defaultValue: undefined, - table: { - category: 'inputs', - }, - type: { - name: 'enum', - required: true, - value: [], - }, - }, - }; - const source = computesTemplateSourceFromComponent(component, props, argTypes); + const source = computesTemplateSourceFromComponent(component, props); expect(source).toEqual( `` ); @@ -648,24 +629,7 @@ describe('angular source decorator', () => { label: 'Hello world', accent: ButtonAccent.High, }; - const argTypes: ArgTypes = { - accent: { - control: { - options: ['Normal', 'High'], - type: 'radio', - }, - defaultValue: undefined, - table: { - category: 'inputs', - }, - type: { - name: 'object', - required: true, - value: {}, - }, - }, - }; - const source = computesTemplateSourceFromComponent(component, props, argTypes); + const source = computesTemplateSourceFromComponent(component, props); expect(source).toEqual( `` ); @@ -699,7 +663,7 @@ describe('angular source decorator', () => { someDataObject, }; - const source = computesTemplateSourceFromComponent(component, props, null); + const source = computesTemplateSourceFromComponent(component, props); // Ideally we should stringify the object, but that could cause the story to break because of unescaped values in the JSON object. // This will have to do for now expect(source).toEqual( @@ -736,7 +700,7 @@ describe('angular source decorator', () => { someDataObject, }; - const source = computesTemplateSourceFromComponent(component, props, null); + const source = computesTemplateSourceFromComponent(component, props); // Ideally we should stringify the object, but that could cause the story to break because of unescaped values in the JSON object. // This will have to do for now expect(source).toEqual( diff --git a/code/frameworks/angular/src/client/angular-beta/ComputesTemplateFromComponent.ts b/code/frameworks/angular/src/client/angular-beta/ComputesTemplateFromComponent.ts index 523bb6c338e5..e4cac7e8bf15 100644 --- a/code/frameworks/angular/src/client/angular-beta/ComputesTemplateFromComponent.ts +++ b/code/frameworks/angular/src/client/angular-beta/ComputesTemplateFromComponent.ts @@ -1,5 +1,3 @@ -import type { ArgTypes } from 'storybook/internal/types'; - import type { Type } from '@angular/core'; import type { ICollection } from '../types'; @@ -99,11 +97,9 @@ function stringifyCircular(obj: any) { const createAngularInputProperty = ({ propertyName, value, - argType, }: { propertyName: string; value: any; - argType?: ArgTypes[string]; }) => { let templateValue; switch (typeof value) { @@ -137,8 +133,7 @@ const createAngularInputProperty = ({ */ export const computesTemplateSourceFromComponent = ( component: Type, - initialProps?: ICollection, - argTypes?: ArgTypes + initialProps?: ICollection ) => { const ngComponentMetadata = getComponentDecoratorMetadata(component); if (!ngComponentMetadata) { @@ -163,7 +158,6 @@ export const computesTemplateSourceFromComponent = ( createAngularInputProperty({ propertyName, value: initialProps[propertyName], - argType: argTypes?.[propertyName], }) ) .join(' ')}` diff --git a/code/frameworks/angular/src/client/angular-beta/__testfixtures__/input.component.ts b/code/frameworks/angular/src/client/angular-beta/__testfixtures__/input.component.ts index b0ae93c94b99..c6d8aa3ca4b7 100644 --- a/code/frameworks/angular/src/client/angular-beta/__testfixtures__/input.component.ts +++ b/code/frameworks/angular/src/client/angular-beta/__testfixtures__/input.component.ts @@ -18,7 +18,7 @@ export interface ISomeInterface { selector: 'doc-button', template: '', }) -export class InputComponent { +export class InputComponent<_T> { /** Appearance style of the button. */ @Input() public appearance: 'primary' | 'secondary' = 'secondary'; diff --git a/code/frameworks/angular/src/client/docs/sourceDecorator.ts b/code/frameworks/angular/src/client/docs/sourceDecorator.ts index d5315f8dff99..4e4e2911ccb3 100644 --- a/code/frameworks/angular/src/client/docs/sourceDecorator.ts +++ b/code/frameworks/angular/src/client/docs/sourceDecorator.ts @@ -36,13 +36,13 @@ export const sourceDecorator = ( } const { props, userDefinedTemplate } = story; - const { component, argTypes, parameters } = context; + const { component, parameters } = context; const template: string = parameters.docs?.source?.excludeDecorators ? (context.originalStoryFn as ArgsStoryFn)(context.args, context).template : story.template; if (component && !userDefinedTemplate) { - const sourceFromComponent = computesTemplateSourceFromComponent(component, props, argTypes); + const sourceFromComponent = computesTemplateSourceFromComponent(component, props); // We might have a story with a Directive or Service defined as the component // In these cases there might exist a template, even if we aren't able to create source from component diff --git a/code/frameworks/angular/src/client/public-types.ts b/code/frameworks/angular/src/client/public-types.ts index 2c32a1b8ec52..31119a43992b 100644 --- a/code/frameworks/angular/src/client/public-types.ts +++ b/code/frameworks/angular/src/client/public-types.ts @@ -64,8 +64,8 @@ type AngularInputSignalWithTransform = AngularCore.InputSignalWithTransfor // @ts-ignore Angular < 17.3 doesn't export AngularOutputEmitterRef type AngularOutputEmitterRef = AngularCore.OutputEmitterRef; -type AngularHasInputSignal = typeof AngularCore extends { input: infer U } ? true : false; -type AngularHasOutputSignal = typeof AngularCore extends { output: infer U } ? true : false; +type AngularHasInputSignal = typeof AngularCore extends { input: infer _U } ? true : false; +type AngularHasOutputSignal = typeof AngularCore extends { output: infer _U } ? true : false; type InputSignal = AngularHasInputSignal extends true ? AngularInputSignal : never; type InputSignalWithTransform = AngularHasInputSignal extends true diff --git a/code/frameworks/angular/src/server/framework-preset-angular-cli.test.ts b/code/frameworks/angular/src/server/framework-preset-angular-cli.test.ts index 89cdf948e543..f0c875f5441f 100644 --- a/code/frameworks/angular/src/server/framework-preset-angular-cli.test.ts +++ b/code/frameworks/angular/src/server/framework-preset-angular-cli.test.ts @@ -220,7 +220,7 @@ describe('framework-preset-angular-cli', () => { angularBrowserTarget: 'test-project:build', }; - const result = await getBuilderOptions(options, mockBuilderContext); + await getBuilderOptions(options, mockBuilderContext); expect(mockedLogger.info).toHaveBeenCalledWith( '=> Using angular browser target options from "test-project:build"' @@ -240,7 +240,7 @@ describe('framework-preset-angular-cli', () => { angularBrowserTarget: 'test-project:build:production', }; - const result = await getBuilderOptions(options, mockBuilderContext); + await getBuilderOptions(options, mockBuilderContext); expect(mockedLogger.info).toHaveBeenCalledWith( '=> Using angular browser target options from "test-project:build:production"' 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 ffcf562390ea..db5fdd62fd21 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,5 @@ import type { Meta, StoryObj } from '@storybook/angular'; -import { StoryFn, moduleMetadata } from '@storybook/angular'; +import { moduleMetadata } from '@storybook/angular'; import { FormsModule } from '@angular/forms'; diff --git a/code/frameworks/angular/template/stories/basics/component-with-pipe/custom.pipe.ts b/code/frameworks/angular/template/stories/basics/component-with-pipe/custom.pipe.ts index d8865dc3af2e..e3a0e9df4990 100644 --- a/code/frameworks/angular/template/stories/basics/component-with-pipe/custom.pipe.ts +++ b/code/frameworks/angular/template/stories/basics/component-with-pipe/custom.pipe.ts @@ -6,7 +6,7 @@ import { Pipe } from '@angular/core'; name: 'customPipe', }) export class CustomPipePipe implements PipeTransform { - transform(value: any, args?: any): any { + transform(value: any): any { return `CustomPipe: ${value}`; } } diff --git a/code/frameworks/angular/template/stories/basics/ng-module/import-module-chip.stories.ts b/code/frameworks/angular/template/stories/basics/ng-module/import-module-chip.stories.ts index 95d9e49a2f83..a01b9b924096 100644 --- a/code/frameworks/angular/template/stories/basics/ng-module/import-module-chip.stories.ts +++ b/code/frameworks/angular/template/stories/basics/ng-module/import-module-chip.stories.ts @@ -1,5 +1,5 @@ import type { Meta, StoryObj } from '@storybook/angular'; -import { StoryFn, moduleMetadata } from '@storybook/angular'; +import { moduleMetadata } from '@storybook/angular'; import { ChipComponent } from './angular-src/chip.component'; import { ChipsModule } from './angular-src/chips.module'; diff --git a/code/frameworks/angular/template/stories/basics/ng-module/import-module-for-root.stories.ts b/code/frameworks/angular/template/stories/basics/ng-module/import-module-for-root.stories.ts index 65a73849c9b6..cb6c334e756a 100644 --- a/code/frameworks/angular/template/stories/basics/ng-module/import-module-for-root.stories.ts +++ b/code/frameworks/angular/template/stories/basics/ng-module/import-module-for-root.stories.ts @@ -1,5 +1,5 @@ import type { Meta, StoryObj } from '@storybook/angular'; -import { StoryFn, moduleMetadata } from '@storybook/angular'; +import { moduleMetadata } from '@storybook/angular'; import { CHIP_COLOR } from './angular-src/chip-color.token'; import { ChipsGroupComponent } from './angular-src/chips-group.component'; diff --git a/code/frameworks/angular/template/stories/basics/ng-module/import-module.stories.ts b/code/frameworks/angular/template/stories/basics/ng-module/import-module.stories.ts index 4865dfb2f9f4..8692a3fd0b65 100644 --- a/code/frameworks/angular/template/stories/basics/ng-module/import-module.stories.ts +++ b/code/frameworks/angular/template/stories/basics/ng-module/import-module.stories.ts @@ -1,5 +1,5 @@ import type { Meta, StoryObj } from '@storybook/angular'; -import { StoryFn, moduleMetadata } from '@storybook/angular'; +import { moduleMetadata } from '@storybook/angular'; import { ChipsGroupComponent } from './angular-src/chips-group.component'; import { ChipsModule } from './angular-src/chips.module'; diff --git a/code/frameworks/angular/template/stories/core/moduleMetadata/angular-src/custom.pipe.ts b/code/frameworks/angular/template/stories/core/moduleMetadata/angular-src/custom.pipe.ts index d8865dc3af2e..e3a0e9df4990 100644 --- a/code/frameworks/angular/template/stories/core/moduleMetadata/angular-src/custom.pipe.ts +++ b/code/frameworks/angular/template/stories/core/moduleMetadata/angular-src/custom.pipe.ts @@ -6,7 +6,7 @@ import { Pipe } from '@angular/core'; name: 'customPipe', }) export class CustomPipePipe implements PipeTransform { - transform(value: any, args?: any): any { + transform(value: any): any { return `CustomPipe: ${value}`; } } diff --git a/code/frameworks/nextjs-vite/src/index.ts b/code/frameworks/nextjs-vite/src/index.ts index b0d1de86853d..98f7c418c052 100644 --- a/code/frameworks/nextjs-vite/src/index.ts +++ b/code/frameworks/nextjs-vite/src/index.ts @@ -1,9 +1,8 @@ import type { AddonTypes, InferTypes, PreviewAddon } from 'storybook/internal/csf'; import type { ProjectAnnotations } from 'storybook/internal/types'; -import type { ReactPreview } from '@storybook/react'; +import type { ReactPreview, ReactTypes } from '@storybook/react'; import { __definePreview } from '@storybook/react'; -import type { ReactTypes } from '@storybook/react'; import type vitePluginStorybookNextJs from 'vite-plugin-storybook-nextjs'; diff --git a/code/frameworks/nextjs-vite/src/routing/app-router-provider.tsx b/code/frameworks/nextjs-vite/src/routing/app-router-provider.tsx index c01226bbd440..75e269ee8747 100644 --- a/code/frameworks/nextjs-vite/src/routing/app-router-provider.tsx +++ b/code/frameworks/nextjs-vite/src/routing/app-router-provider.tsx @@ -18,7 +18,6 @@ import { PathnameContext, SearchParamsContext, } from 'next/dist/shared/lib/hooks-client-context.shared-runtime'; -import { PAGE_SEGMENT_KEY } from 'next/dist/shared/lib/segment'; import type { RouteParams } from './types'; @@ -30,35 +29,6 @@ type AppRouterProviderProps = { routeParams: RouteParams; }; -// Since Next 14.2.x -// https://github.com/vercel/next.js/pull/60708/files#diff-7b6239af735eba0c401e1a0db1a04dd4575c19a031934f02d128cf3ac813757bR106 -function getSelectedParams(currentTree: FlightRouterState, params: Params = {}): Params { - const parallelRoutes = currentTree[1]; - - for (const parallelRoute of Object.values(parallelRoutes)) { - const segment = parallelRoute[0]; - const isDynamicParameter = Array.isArray(segment); - const segmentValue = isDynamicParameter ? segment[1] : segment; - - if (!segmentValue || segmentValue.startsWith(PAGE_SEGMENT_KEY)) { - continue; - } - - // Ensure catchAll and optional catchall are turned into an array - const isCatchAll = isDynamicParameter && (segment[2] === 'c' || segment[2] === 'oc'); - - if (isCatchAll) { - params[segment[0]] = Array.isArray(segment[1]) ? segment[1] : segment[1].split('/'); - } else if (isDynamicParameter) { - params[segment[0]] = segment[1]; - } - - params = getSelectedParams(parallelRoute, params); - } - - return params; -} - const getParallelRoutes = (segmentsList: Array): FlightRouterState => { const segment = segmentsList.shift(); diff --git a/code/frameworks/nextjs-vite/template/stories/Head.stories.tsx b/code/frameworks/nextjs-vite/template/stories/Head.stories.tsx index 0bcd1a71ef83..fc4545594f8d 100644 --- a/code/frameworks/nextjs-vite/template/stories/Head.stories.tsx +++ b/code/frameworks/nextjs-vite/template/stories/Head.stories.tsx @@ -1,7 +1,6 @@ import React from 'react'; -import type { Meta } from '@storybook/nextjs-vite'; -import type { StoryObj } from '@storybook/nextjs-vite'; +import type { Meta, StoryObj } from '@storybook/nextjs-vite'; import Head from 'next/head'; import { expect, waitFor } from 'storybook/test'; diff --git a/code/frameworks/nextjs-vite/template/stories/Image.stories.tsx b/code/frameworks/nextjs-vite/template/stories/Image.stories.tsx index 79b3cc027bcf..853ed1036c3c 100644 --- a/code/frameworks/nextjs-vite/template/stories/Image.stories.tsx +++ b/code/frameworks/nextjs-vite/template/stories/Image.stories.tsx @@ -1,4 +1,4 @@ -import React, { useRef, useState } from 'react'; +import React, { useState } from 'react'; import type { Meta, StoryObj } from '@storybook/nextjs-vite'; diff --git a/code/frameworks/nextjs-vite/template/stories/ImageLegacy.stories.tsx b/code/frameworks/nextjs-vite/template/stories/ImageLegacy.stories.tsx index 6d1b55094f7b..35f4c80f5a46 100644 --- a/code/frameworks/nextjs-vite/template/stories/ImageLegacy.stories.tsx +++ b/code/frameworks/nextjs-vite/template/stories/ImageLegacy.stories.tsx @@ -1,5 +1,3 @@ -import React from 'react'; - import type { Meta, StoryObj } from '@storybook/nextjs-vite'; import Image from 'next/legacy/image'; diff --git a/code/frameworks/nextjs-vite/template/stories/Link.stories.tsx b/code/frameworks/nextjs-vite/template/stories/Link.stories.tsx index d6752d273df6..173306a86dba 100644 --- a/code/frameworks/nextjs-vite/template/stories/Link.stories.tsx +++ b/code/frameworks/nextjs-vite/template/stories/Link.stories.tsx @@ -6,19 +6,6 @@ import Link from 'next/link'; import style from './Link.stories.module.css'; -// `onClick`, `href`, and `ref` need to be passed to the DOM element -// for proper handling -const MyButton = React.forwardRef< - HTMLAnchorElement, - React.DetailedHTMLProps, HTMLAnchorElement> ->(function Button({ onClick, href, children }, ref) { - return ( -
- {children} - - ); -}); - const Component = () => (
  • diff --git a/code/frameworks/nextjs-vite/template/stories/NextHeader.stories.tsx b/code/frameworks/nextjs-vite/template/stories/NextHeader.stories.tsx index 40cb3dd52b1e..52703478de19 100644 --- a/code/frameworks/nextjs-vite/template/stories/NextHeader.stories.tsx +++ b/code/frameworks/nextjs-vite/template/stories/NextHeader.stories.tsx @@ -1,5 +1,4 @@ -import type { Meta } from '@storybook/nextjs-vite'; -import type { StoryObj } from '@storybook/nextjs-vite'; +import type { Meta, StoryObj } from '@storybook/nextjs-vite'; import { cookies, headers } from '@storybook/nextjs-vite/headers.mock'; import { expect, userEvent, within } from 'storybook/test'; diff --git a/code/frameworks/nextjs-vite/template/stories/Redirect.stories.tsx b/code/frameworks/nextjs-vite/template/stories/Redirect.stories.tsx index 6d8db6afa4cc..37866b63be11 100644 --- a/code/frameworks/nextjs-vite/template/stories/Redirect.stories.tsx +++ b/code/frameworks/nextjs-vite/template/stories/Redirect.stories.tsx @@ -50,7 +50,7 @@ export default { } as Meta; export const SingletonStateGetsInvalidatedAfterRedirecting: StoryObj = { - play: async ({ canvasElement, step }) => { + play: async ({ canvasElement }) => { const canvas = within(canvasElement); await userEvent.click(canvas.getByRole('button')); }, diff --git a/code/frameworks/nextjs/src/index.ts b/code/frameworks/nextjs/src/index.ts index 8bb41e89c3f7..90c059b7206b 100644 --- a/code/frameworks/nextjs/src/index.ts +++ b/code/frameworks/nextjs/src/index.ts @@ -1,9 +1,8 @@ import type { AddonTypes, InferTypes, PreviewAddon } from 'storybook/internal/csf'; import type { ProjectAnnotations } from 'storybook/internal/types'; -import type { ReactPreview } from '@storybook/react'; +import type { ReactPreview, ReactTypes } from '@storybook/react'; import { __definePreview } from '@storybook/react'; -import type { ReactTypes } from '@storybook/react'; import * as nextPreview from './preview'; import type { NextJsTypes } from './types'; diff --git a/code/frameworks/nextjs/src/routing/app-router-provider.tsx b/code/frameworks/nextjs/src/routing/app-router-provider.tsx index 082548ec7df6..20a2d35a0d35 100644 --- a/code/frameworks/nextjs/src/routing/app-router-provider.tsx +++ b/code/frameworks/nextjs/src/routing/app-router-provider.tsx @@ -18,7 +18,6 @@ import { PathnameContext, SearchParamsContext, } from 'next/dist/shared/lib/hooks-client-context.shared-runtime'; -import { PAGE_SEGMENT_KEY } from 'next/dist/shared/lib/segment'; import type { RouteParams } from './types'; @@ -30,35 +29,6 @@ type AppRouterProviderProps = { routeParams: RouteParams; }; -// Since Next 14.2.x -// https://github.com/vercel/next.js/pull/60708/files#diff-7b6239af735eba0c401e1a0db1a04dd4575c19a031934f02d128cf3ac813757bR106 -function getSelectedParams(currentTree: FlightRouterState, params: Params = {}): Params { - const parallelRoutes = currentTree[1]; - - for (const parallelRoute of Object.values(parallelRoutes)) { - const segment = parallelRoute[0]; - const isDynamicParameter = Array.isArray(segment); - const segmentValue = isDynamicParameter ? segment[1] : segment; - - if (!segmentValue || segmentValue.startsWith(PAGE_SEGMENT_KEY)) { - continue; - } - - // Ensure catchAll and optional catchall are turned into an array - const isCatchAll = isDynamicParameter && (segment[2] === 'c' || segment[2] === 'oc'); - - if (isCatchAll) { - params[segment[0]] = Array.isArray(segment[1]) ? segment[1] : segment[1].split('/'); - } else if (isDynamicParameter) { - params[segment[0]] = segment[1]; - } - - params = getSelectedParams(parallelRoute, params); - } - - return params; -} - const getParallelRoutes = (segmentsList: Array): FlightRouterState => { const segment = segmentsList.shift(); diff --git a/code/frameworks/nextjs/src/swc/next-swc-loader-patch.ts b/code/frameworks/nextjs/src/swc/next-swc-loader-patch.ts index ec4ec7b35141..1b11b4d61d1c 100644 --- a/code/frameworks/nextjs/src/swc/next-swc-loader-patch.ts +++ b/code/frameworks/nextjs/src/swc/next-swc-loader-patch.ts @@ -48,7 +48,7 @@ export interface SWCLoaderOptions { } const mockCurrentTraceSpan = { - traceChild: (name: string) => mockCurrentTraceSpan, + traceChild: () => mockCurrentTraceSpan, traceAsyncFn: async (fn: any) => fn(), }; @@ -161,7 +161,7 @@ export function pitch(this: any) { isAbsolute(this.resourcePath) && !(await isWasm()) ) { - const loaderSpan = mockCurrentTraceSpan.traceChild('next-swc-loader'); + const loaderSpan = mockCurrentTraceSpan.traceChild(); this.addDependency(this.resourcePath); return loaderSpan.traceAsyncFn(() => loaderTransform.call(this, loaderSpan)); } @@ -177,7 +177,7 @@ export function pitch(this: any) { } export default function swcLoader(this: any, inputSource: string, inputSourceMap: any) { - const loaderSpan = mockCurrentTraceSpan.traceChild('next-swc-loader'); + const loaderSpan = mockCurrentTraceSpan.traceChild(); const callback = this.async(); loaderSpan .traceAsyncFn(() => loaderTransform.call(this, loaderSpan, inputSource, inputSourceMap)) diff --git a/code/frameworks/nextjs/template/stories/Link.stories.tsx b/code/frameworks/nextjs/template/stories/Link.stories.tsx index 23fd174dd010..325cd32cee98 100644 --- a/code/frameworks/nextjs/template/stories/Link.stories.tsx +++ b/code/frameworks/nextjs/template/stories/Link.stories.tsx @@ -6,19 +6,6 @@ import Link from 'next/link'; import style from './Link.stories.module.css'; -// `onClick`, `href`, and `ref` need to be passed to the DOM element -// for proper handling -const MyButton = React.forwardRef< - HTMLAnchorElement, - React.DetailedHTMLProps, HTMLAnchorElement> ->(function Button({ onClick, href, children }, ref) { - return ( - - {children} - - ); -}); - const Component = () => (
    • diff --git a/code/frameworks/nextjs/template/stories_nextjs-default-ts/Redirect.stories.tsx b/code/frameworks/nextjs/template/stories_nextjs-default-ts/Redirect.stories.tsx index 6cf56ede2f13..cf6bc993229e 100644 --- a/code/frameworks/nextjs/template/stories_nextjs-default-ts/Redirect.stories.tsx +++ b/code/frameworks/nextjs/template/stories_nextjs-default-ts/Redirect.stories.tsx @@ -50,7 +50,7 @@ export default { } as Meta; export const SingletonStateGetsInvalidatedAfterRedirecting: StoryObj = { - play: async ({ canvasElement, step }) => { + play: async ({ canvasElement }) => { const canvas = within(canvasElement); await userEvent.click(canvas.getByRole('button')); }, diff --git a/code/frameworks/nextjs/template/stories_nextjs-prerelease/Redirect.stories.tsx b/code/frameworks/nextjs/template/stories_nextjs-prerelease/Redirect.stories.tsx index 6cf56ede2f13..cf6bc993229e 100644 --- a/code/frameworks/nextjs/template/stories_nextjs-prerelease/Redirect.stories.tsx +++ b/code/frameworks/nextjs/template/stories_nextjs-prerelease/Redirect.stories.tsx @@ -50,7 +50,7 @@ export default { } as Meta; export const SingletonStateGetsInvalidatedAfterRedirecting: StoryObj = { - play: async ({ canvasElement, step }) => { + play: async ({ canvasElement }) => { const canvas = within(canvasElement); await userEvent.click(canvas.getByRole('button')); }, diff --git a/code/frameworks/react-vite/src/plugins/react-docgen.ts b/code/frameworks/react-vite/src/plugins/react-docgen.ts index bbac579c379f..7db20f0a7456 100644 --- a/code/frameworks/react-vite/src/plugins/react-docgen.ts +++ b/code/frameworks/react-vite/src/plugins/react-docgen.ts @@ -2,7 +2,6 @@ import { existsSync } from 'node:fs'; import { relative, sep } from 'node:path'; import { getProjectRoot } from 'storybook/internal/common'; -import { logger } from 'storybook/internal/node-logger'; import { createFilter } from '@rollup/pluginutils'; import * as find from 'empathic/find'; diff --git a/code/frameworks/svelte-vite/src/plugins/generateDocgen.ts b/code/frameworks/svelte-vite/src/plugins/generateDocgen.ts index 496f3651be57..001dcdf5ea99 100644 --- a/code/frameworks/svelte-vite/src/plugins/generateDocgen.ts +++ b/code/frameworks/svelte-vite/src/plugins/generateDocgen.ts @@ -305,7 +305,7 @@ export function generateDocgen(targetFileName: string, cache: DocgenCache): Docg return false; }, - getSourceFile(fileName, languageVersion, onError) { + getSourceFile(fileName, languageVersion) { if (fileName.endsWith('.svelte.tsx') || fileName.endsWith('.svelte.jsx')) { // .svelte file (`import ... from './path/to/file.svelte'`) diff --git a/code/lib/cli-storybook/build-config.ts b/code/lib/cli-storybook/build-config.ts index 403def7e5b32..40ae1cf07f25 100644 --- a/code/lib/cli-storybook/build-config.ts +++ b/code/lib/cli-storybook/build-config.ts @@ -1,5 +1,3 @@ -import { join } from 'node:path'; - import type { BuildEntries } from '../../../scripts/build/utils/entry-utils'; const config: BuildEntries = { diff --git a/code/lib/cli-storybook/src/add.test.ts b/code/lib/cli-storybook/src/add.test.ts index 1bd09a624feb..e6b74c2661dd 100644 --- a/code/lib/cli-storybook/src/add.test.ts +++ b/code/lib/cli-storybook/src/add.test.ts @@ -91,7 +91,7 @@ vi.mock('storybook/internal/common', () => { }; }); -describe('getVersionSpecifier', (it) => { +describe('getVersionSpecifier', () => { test.each([ ['@storybook/addon-docs', ['@storybook/addon-docs', undefined]], ['@storybook/addon-docs@7.0.1', ['@storybook/addon-docs', '7.0.1']], diff --git a/code/lib/cli-storybook/src/autoblock/utils.ts b/code/lib/cli-storybook/src/autoblock/utils.ts index 60e33b253017..79d7e5a595dc 100644 --- a/code/lib/cli-storybook/src/autoblock/utils.ts +++ b/code/lib/cli-storybook/src/autoblock/utils.ts @@ -1,7 +1,6 @@ import type { JsPackageManager } from 'storybook/internal/common'; import { CLI_COLORS } from 'storybook/internal/node-logger'; -import picocolors from 'picocolors'; import { lt } from 'semver'; import { shortenPath } from '../util'; diff --git a/code/lib/cli-storybook/src/automigrate/fixes/addon-a11y-addon-test.test.ts b/code/lib/cli-storybook/src/automigrate/fixes/addon-a11y-addon-test.test.ts index 9795c2cfe32f..eb054f701d8a 100644 --- a/code/lib/cli-storybook/src/automigrate/fixes/addon-a11y-addon-test.test.ts +++ b/code/lib/cli-storybook/src/automigrate/fixes/addon-a11y-addon-test.test.ts @@ -46,7 +46,7 @@ vi.mock('picocolors', async (importOriginal) => { }; }); -const loggerMock = vi.mocked(logger); +vi.mocked(logger); describe('addonA11yAddonTest', () => { const configDir = '/path/to/config'; diff --git a/code/lib/cli-storybook/src/automigrate/fixes/addon-mdx-gfm-remove.test.ts b/code/lib/cli-storybook/src/automigrate/fixes/addon-mdx-gfm-remove.test.ts index 32d2b7a96638..eacc6a1c6973 100644 --- a/code/lib/cli-storybook/src/automigrate/fixes/addon-mdx-gfm-remove.test.ts +++ b/code/lib/cli-storybook/src/automigrate/fixes/addon-mdx-gfm-remove.test.ts @@ -63,10 +63,6 @@ const baseCheckOptions: CheckOptions = { storiesPaths: [], }; -interface AddonMdxGfmOptions { - hasMdxGfm: boolean; -} - // Add type for migration object interface Migration { check: (options: CheckOptions) => Promise; diff --git a/code/lib/cli-storybook/src/automigrate/fixes/addon-storysource-code-panel.ts b/code/lib/cli-storybook/src/automigrate/fixes/addon-storysource-code-panel.ts index ca3793d9dd7f..ce8de11002ed 100644 --- a/code/lib/cli-storybook/src/automigrate/fixes/addon-storysource-code-panel.ts +++ b/code/lib/cli-storybook/src/automigrate/fixes/addon-storysource-code-panel.ts @@ -1,7 +1,6 @@ import { getAddonNames, removeAddon } from 'storybook/internal/common'; import { logger } from 'storybook/internal/node-logger'; -import picocolors from 'picocolors'; import { dedent } from 'ts-dedent'; import { add } from '../../add'; diff --git a/code/lib/cli-storybook/src/automigrate/fixes/fix-faux-esm-require.ts b/code/lib/cli-storybook/src/automigrate/fixes/fix-faux-esm-require.ts index 04ffd79fa464..6e593e27b026 100644 --- a/code/lib/cli-storybook/src/automigrate/fixes/fix-faux-esm-require.ts +++ b/code/lib/cli-storybook/src/automigrate/fixes/fix-faux-esm-require.ts @@ -147,7 +147,6 @@ export const fixFauxEsmRequire = { // Add __filename and __dirname if used and not already declared if (hasUnderscoreFilename || hasUnderscoreDirname) { const declarationsToInsert: t.Statement[] = []; - let insertOffset = 0; // Add __filename declaration if needed and not already exists // Note: __filename is always needed if __dirname is used, since __dirname depends on __filename @@ -164,7 +163,6 @@ export const fixFauxEsmRequire = { ), ]); declarationsToInsert.push(filenameDeclaration); - insertOffset++; } // Add __dirname declaration if needed and not already exists @@ -176,7 +174,6 @@ export const fixFauxEsmRequire = { ), ]); declarationsToInsert.push(dirnameDeclaration); - insertOffset++; } // Insert declarations after imports diff --git a/code/lib/cli-storybook/src/automigrate/fixes/remove-essentials.ts b/code/lib/cli-storybook/src/automigrate/fixes/remove-essentials.ts index 77948f6d458b..9e1151065a42 100644 --- a/code/lib/cli-storybook/src/automigrate/fixes/remove-essentials.ts +++ b/code/lib/cli-storybook/src/automigrate/fixes/remove-essentials.ts @@ -131,18 +131,11 @@ export const removeEssentials: Fix = { dryRun, packageManager, configDir, - storybookVersion, storiesPaths, mainConfigPath, previewConfigPath, }) { - const { - hasEssentials, - hasDocsDisabled, - hasDocsAddon, - additionalAddonsToRemove, - essentialsOptions, - } = result; + const { hasEssentials, hasDocsDisabled, additionalAddonsToRemove, essentialsOptions } = result; if (!hasEssentials && additionalAddonsToRemove.length === 0) { return; diff --git a/code/lib/cli-storybook/src/automigrate/fixes/renderer-to-framework.test.ts b/code/lib/cli-storybook/src/automigrate/fixes/renderer-to-framework.test.ts index 584fecf9c3bc..15c1596f28e1 100644 --- a/code/lib/cli-storybook/src/automigrate/fixes/renderer-to-framework.test.ts +++ b/code/lib/cli-storybook/src/automigrate/fixes/renderer-to-framework.test.ts @@ -5,8 +5,11 @@ import { beforeEach, describe, expect, it, vi } from 'vitest'; import { dedent } from 'ts-dedent'; -import { removeRendererInPackageJson, transformSourceFiles } from './renderer-to-framework'; -import { rendererToFramework } from './renderer-to-framework'; +import { + removeRendererInPackageJson, + rendererToFramework, + transformSourceFiles, +} from './renderer-to-framework'; vi.mock('node:fs/promises'); vi.mock('globby', () => ({ diff --git a/code/lib/cli-storybook/src/automigrate/fixes/rnstorybook-config.ts b/code/lib/cli-storybook/src/automigrate/fixes/rnstorybook-config.ts index 3dd704f59656..11306e966584 100644 --- a/code/lib/cli-storybook/src/automigrate/fixes/rnstorybook-config.ts +++ b/code/lib/cli-storybook/src/automigrate/fixes/rnstorybook-config.ts @@ -44,7 +44,7 @@ const getDotStorybookReferences = async (searchDir: string) => { if (content.includes('.storybook')) { referencedFiles.push(file); } - } catch (readError) { + } catch { // Skip files that can't be read (e.g., binary files) } }) diff --git a/code/lib/cli-storybook/src/automigrate/fixes/upgrade-storybook-related-dependencies.ts b/code/lib/cli-storybook/src/automigrate/fixes/upgrade-storybook-related-dependencies.ts index 6b09bfb6c26e..04ba57788a6d 100644 --- a/code/lib/cli-storybook/src/automigrate/fixes/upgrade-storybook-related-dependencies.ts +++ b/code/lib/cli-storybook/src/automigrate/fixes/upgrade-storybook-related-dependencies.ts @@ -1,8 +1,7 @@ import { readFileSync } from 'node:fs'; import { dirname } from 'node:path'; -import type { PackageJson } from 'storybook/internal/common'; -import type { JsPackageManager } from 'storybook/internal/common'; +import type { JsPackageManager, PackageJson } from 'storybook/internal/common'; import { isCorePackage, isSatelliteAddon } from 'storybook/internal/common'; import { logger } from 'storybook/internal/node-logger'; diff --git a/code/lib/cli-storybook/src/automigrate/helpers/addon-a11y-parameters.ts b/code/lib/cli-storybook/src/automigrate/helpers/addon-a11y-parameters.ts index d7751fe9be53..33943c548fdd 100644 --- a/code/lib/cli-storybook/src/automigrate/helpers/addon-a11y-parameters.ts +++ b/code/lib/cli-storybook/src/automigrate/helpers/addon-a11y-parameters.ts @@ -36,7 +36,7 @@ export function transformStoryA11yParameters(code: string): CsfFile | null { const parsed = loadCsf(code, { makeTitle: (title?: string) => title || 'default' }).parse(); // Use the story transformer utility to handle all story iteration - let hasChanges = transformStories(parsed, (storyObject, storyName, csf) => { + let hasChanges = transformStories(parsed, (storyObject) => { return migrateA11yParameters(storyObject); }); diff --git a/code/lib/cli-storybook/src/automigrate/helpers/mainConfigFile.ts b/code/lib/cli-storybook/src/automigrate/helpers/mainConfigFile.ts index 343cdccf1129..ab1197035a30 100644 --- a/code/lib/cli-storybook/src/automigrate/helpers/mainConfigFile.ts +++ b/code/lib/cli-storybook/src/automigrate/helpers/mainConfigFile.ts @@ -5,12 +5,13 @@ import { builderPackages, extractProperFrameworkName, frameworkPackages, + frameworkToRenderer, + getCoercedStorybookVersion, getStorybookInfo, loadMainConfig, rendererPackages, } from 'storybook/internal/common'; import type { PackageManagerName } from 'storybook/internal/common'; -import { frameworkToRenderer, getCoercedStorybookVersion } from 'storybook/internal/common'; import type { ConfigFile } from 'storybook/internal/csf-tools'; import { readConfig, writeConfig as writeConfigFile } from 'storybook/internal/csf-tools'; import { logger } from 'storybook/internal/node-logger'; diff --git a/code/lib/cli-storybook/src/codemod/helpers/csf-factories-utils.test.ts b/code/lib/cli-storybook/src/codemod/helpers/csf-factories-utils.test.ts index 999c6c325f5b..a8522849fd1a 100644 --- a/code/lib/cli-storybook/src/codemod/helpers/csf-factories-utils.test.ts +++ b/code/lib/cli-storybook/src/codemod/helpers/csf-factories-utils.test.ts @@ -1,7 +1,6 @@ import { describe, expect, it } from 'vitest'; -import { types as t } from 'storybook/internal/babel'; -import { generate, parser } from 'storybook/internal/babel'; +import { generate, parser, types as t } from 'storybook/internal/babel'; import { cleanupTypeImports, diff --git a/code/lib/cli-storybook/src/upgrade.test.ts b/code/lib/cli-storybook/src/upgrade.test.ts index 961abaf4060b..07b7fd0b9e25 100644 --- a/code/lib/cli-storybook/src/upgrade.test.ts +++ b/code/lib/cli-storybook/src/upgrade.test.ts @@ -1,7 +1,6 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'; import type * as sbcc from 'storybook/internal/common'; -import type { JsPackageManager } from 'storybook/internal/common'; import { getStorybookVersion } from './upgrade'; import { generateUpgradeSpecs } from './util'; @@ -52,12 +51,12 @@ describe.each([ }); describe('toUpgradedDependencies', () => { - let mockPackageManager: JsPackageManager; + let mockPackageManager: sbcc.JsPackageManager; beforeEach(() => { mockPackageManager = { latestVersion: vi.fn(), - } as unknown as JsPackageManager; + } as unknown as sbcc.JsPackageManager; vi.mocked(mockPackageManager.latestVersion).mockImplementation(async (packageName: string) => { if (packageName === '@storybook/addon-designs@next') { diff --git a/code/lib/cli-storybook/src/upgrade.ts b/code/lib/cli-storybook/src/upgrade.ts index 0209de238178..6868ba79f104 100644 --- a/code/lib/cli-storybook/src/upgrade.ts +++ b/code/lib/cli-storybook/src/upgrade.ts @@ -1,6 +1,10 @@ import type { PackageManagerName } from 'storybook/internal/common'; -import { versions } from 'storybook/internal/common'; -import { HandledError, JsPackageManagerFactory, isCorePackage } from 'storybook/internal/common'; +import { + HandledError, + JsPackageManagerFactory, + isCorePackage, + versions, +} from 'storybook/internal/common'; import { withTelemetry } from 'storybook/internal/core-server'; import { CLI_COLORS, diff --git a/code/lib/cli-storybook/src/util.ts b/code/lib/cli-storybook/src/util.ts index c12e9c8128f8..19db33957aad 100644 --- a/code/lib/cli-storybook/src/util.ts +++ b/code/lib/cli-storybook/src/util.ts @@ -1,6 +1,12 @@ import type { PackageJsonWithDepsAndDevDeps } from 'storybook/internal/common'; -import { HandledError, JsPackageManager, normalizeStories } from 'storybook/internal/common'; -import { getProjectRoot, isSatelliteAddon, versions } from 'storybook/internal/common'; +import { + HandledError, + JsPackageManager, + getProjectRoot, + isSatelliteAddon, + normalizeStories, + versions, +} from 'storybook/internal/common'; import { StoryIndexGenerator, experimental_loadStorybook } from 'storybook/internal/core-server'; import { logTracker, logger, prompt } from 'storybook/internal/node-logger'; import { @@ -82,9 +88,6 @@ const DEFAULT_BOXEN_STYLE: Options = { /** Glob pattern for finding Storybook directories */ const STORYBOOK_DIR_PATTERN = ['**/.storybook', '**/.rnstorybook']; -/** Default fallback version when none is found */ -const DEFAULT_FALLBACK_VERSION = '0.0.0'; - // ============================================================================ // UTILITY FUNCTIONS // ============================================================================ diff --git a/code/lib/codemod/src/transforms/csf-2-to-3.ts b/code/lib/codemod/src/transforms/csf-2-to-3.ts index c3c79e9a19c0..b7e988fa9702 100644 --- a/code/lib/codemod/src/transforms/csf-2-to-3.ts +++ b/code/lib/codemod/src/transforms/csf-2-to-3.ts @@ -112,7 +112,7 @@ function removeUnusedTemplates(csf: CsfFile) { }); } -export default async function transform(info: FileInfo, api: API, options: { parser?: string }) { +export default async function transform(info: FileInfo, _api: API, _options: { parser?: string }) { const makeTitle = (userTitle?: string) => { return userTitle || 'FIXME'; }; @@ -222,7 +222,7 @@ export default async function transform(info: FileInfo, api: API, options: { par } class StorybookImportHelper { - constructor(file: BabelFile, info: FileInfo) { + constructor(file: BabelFile, _info: FileInfo) { this.sbImportDeclarations = this.getAllSbImportDeclarations(file); } diff --git a/code/lib/codemod/src/transforms/upgrade-deprecated-types.ts b/code/lib/codemod/src/transforms/upgrade-deprecated-types.ts index 00736b90f39c..31c120973195 100644 --- a/code/lib/codemod/src/transforms/upgrade-deprecated-types.ts +++ b/code/lib/codemod/src/transforms/upgrade-deprecated-types.ts @@ -20,7 +20,7 @@ function migrateType(oldType: string) { return oldType.replace('Component', ''); } -export default async function transform(info: FileInfo, api: API, options: { parser?: string }) { +export default async function transform(info: FileInfo, _api: API, _options: { parser?: string }) { // TODO what do I need to with the title? const csf = loadCsf(info.source, { makeTitle: (title) => title }); const fileNode = csf._ast; diff --git a/code/lib/codemod/src/transforms/upgrade-hierarchy-separators.js b/code/lib/codemod/src/transforms/upgrade-hierarchy-separators.js index 76f9ecc5635d..80e4415c2118 100644 --- a/code/lib/codemod/src/transforms/upgrade-hierarchy-separators.js +++ b/code/lib/codemod/src/transforms/upgrade-hierarchy-separators.js @@ -2,7 +2,7 @@ function upgradeSeparator(path) { return path.replace(/[|.]/g, '/'); } -export default function transformer(file, api, options) { +export default function transformer(file, api) { const j = api.jscodeshift; const root = j(file.source); diff --git a/code/lib/create-storybook/src/ink/steps/checks/configDir.tsx b/code/lib/create-storybook/src/ink/steps/checks/configDir.tsx index b4c92ade4e82..4e17b4f1fc2f 100644 --- a/code/lib/create-storybook/src/ink/steps/checks/configDir.tsx +++ b/code/lib/create-storybook/src/ink/steps/checks/configDir.tsx @@ -12,7 +12,6 @@ const configPath = '.storybook'; * - Yes -> overwrite (delete) * - No -> exit */ -const name = '.storybook directory'; export const configDir: Check = { condition: async (context, state) => { return fs diff --git a/code/lib/create-storybook/src/ink/steps/checks/frameworkPackage.tsx b/code/lib/create-storybook/src/ink/steps/checks/frameworkPackage.tsx index b27ad60fc397..e14bcc65cc8f 100644 --- a/code/lib/create-storybook/src/ink/steps/checks/frameworkPackage.tsx +++ b/code/lib/create-storybook/src/ink/steps/checks/frameworkPackage.tsx @@ -7,7 +7,6 @@ import { CompatibilityType } from './CompatibilityType'; * - Yes -> continue * - No -> exit */ -const name = 'Framework package'; export const frameworkPackage: Check = { condition: async (context, state) => { if (state.framework !== 'nextjs') { diff --git a/code/lib/create-storybook/src/ink/steps/checks/frameworkTest.tsx b/code/lib/create-storybook/src/ink/steps/checks/frameworkTest.tsx index 72acfe44a540..0d4fab48bdf4 100644 --- a/code/lib/create-storybook/src/ink/steps/checks/frameworkTest.tsx +++ b/code/lib/create-storybook/src/ink/steps/checks/frameworkTest.tsx @@ -21,7 +21,6 @@ export const SUPPORTED_FRAMEWORKS: Framework[] = [ * When selecting framework nextjs & intent includes test, prompt for nextjs-vite. When selecting * another framework that doesn't support test addon, prompt for ignoring test intent. */ -const name = 'Framework test compatibility'; export const frameworkTest: Check = { condition: async (context, state) => { if ( diff --git a/code/lib/create-storybook/src/ink/steps/checks/packageVersions.tsx b/code/lib/create-storybook/src/ink/steps/checks/packageVersions.tsx index 18b85477b0da..998ea47d3c21 100644 --- a/code/lib/create-storybook/src/ink/steps/checks/packageVersions.tsx +++ b/code/lib/create-storybook/src/ink/steps/checks/packageVersions.tsx @@ -9,7 +9,6 @@ import { CompatibilityType } from './CompatibilityType'; * - Yes -> ignore test intent * - No -> exit */ -const name = 'Vitest and MSW compatibility'; export const packageVersions: Check = { condition: async (context) => { if (context.packageManager) { diff --git a/code/lib/react-dom-shim/src/react-18.tsx b/code/lib/react-dom-shim/src/react-18.tsx index f3398fc65ff0..acfcfef85c95 100644 --- a/code/lib/react-dom-shim/src/react-18.tsx +++ b/code/lib/react-dom-shim/src/react-18.tsx @@ -59,7 +59,7 @@ export const renderElement = async (node: ReactElement, el: Element, rootOptions return promise; }; -export const unmountElement = (el: Element, shouldUseNewRootApi?: boolean) => { +export const unmountElement = (el: Element) => { const root = nodes.get(el); if (root) { diff --git a/code/renderers/html/src/docs/sourceDecorator.test.ts b/code/renderers/html/src/docs/sourceDecorator.test.ts index 3c380fb3e269..f01899c28c11 100644 --- a/code/renderers/html/src/docs/sourceDecorator.test.ts +++ b/code/renderers/html/src/docs/sourceDecorator.test.ts @@ -1,9 +1,9 @@ /** @vitest-environment happy-dom */ import { beforeEach, describe, expect, it, vi } from 'vitest'; -import { SNIPPET_RENDERED, SourceType } from 'storybook/internal/docs-tools'; +import { SourceType } from 'storybook/internal/docs-tools'; -import { addons, emitTransformCode, useEffect, useRef, useState } from 'storybook/preview-api'; +import { addons, emitTransformCode, useRef } from 'storybook/preview-api'; import { sourceDecorator } from './sourceDecorator'; diff --git a/code/renderers/preact/src/render.tsx b/code/renderers/preact/src/render.tsx index b413306a2f63..caf172aa56e6 100644 --- a/code/renderers/preact/src/render.tsx +++ b/code/renderers/preact/src/render.tsx @@ -37,7 +37,7 @@ const StoryHarness: preact.FunctionalComponent<{ showError: RenderContext['showError']; storyFn: () => any; canvasElement: PreactRenderer['canvasElement']; -}> = ({ showError, name, title, storyFn, canvasElement }) => { +}> = ({ showError, name, title, storyFn }) => { const content = preact.h(storyFn as any, null); if (!content) { showError({ diff --git a/code/renderers/react/src/__test__/portable-stories-factory.test.tsx b/code/renderers/react/src/__test__/portable-stories-factory.test.tsx index a338bcd7b755..f42ef50f6543 100644 --- a/code/renderers/react/src/__test__/portable-stories-factory.test.tsx +++ b/code/renderers/react/src/__test__/portable-stories-factory.test.tsx @@ -5,15 +5,16 @@ import { afterEach, describe, expect, it, vi } from 'vitest'; import React from 'react'; import { + CSF2Secondary, CSF2StoryWithLocale, CSF3Button, CSF3ButtonWithRender, CSF3InputFieldFilled, CSF3Primary, + HooksStory, MountInPlayFunction, MountInPlayFunctionThrow, } from './Button.csf4.stories'; -import { CSF2Secondary, HooksStory } from './Button.csf4.stories'; afterEach(() => { cleanup(); diff --git a/code/renderers/react/src/componentManifest/reactDocgen.ts b/code/renderers/react/src/componentManifest/reactDocgen.ts index 7ade97fade6a..31177286154b 100644 --- a/code/renderers/react/src/componentManifest/reactDocgen.ts +++ b/code/renderers/react/src/componentManifest/reactDocgen.ts @@ -99,7 +99,7 @@ const getExportPaths = cached( let ast; try { ast = babelParse(code); - } catch (_) { + } catch { return []; } diff --git a/code/renderers/react/src/csf-factories.test.tsx b/code/renderers/react/src/csf-factories.test.tsx index 03b0de64da0a..6b90bbcdf810 100644 --- a/code/renderers/react/src/csf-factories.test.tsx +++ b/code/renderers/react/src/csf-factories.test.tsx @@ -1,7 +1,7 @@ +/* eslint-disable @typescript-eslint/no-unused-vars */ // @vitest-environment happy-dom // this file tests Typescript types that's why there are no assertions -import { describe, it } from 'vitest'; -import { expect, test } from 'vitest'; +import { describe, expect, it, test } from 'vitest'; import type { ComponentType, KeyboardEventHandler, ReactElement, ReactNode } from 'react'; import React from 'react'; @@ -66,8 +66,8 @@ describe('Args can be provided in multiple ways', () => { it('❌ The combined shape of meta args and story args must match the required args.', () => { { const meta = preview.meta({ component: Button }); - // @ts-expect-error disabled not provided ❌ const Basic = meta.story({ + // @ts-expect-error disabled not provided ❌ args: { label: 'good' }, }); } @@ -81,8 +81,8 @@ describe('Args can be provided in multiple ways', () => { } { const meta = preview.meta({ component: Button }); - // @ts-expect-error disabled not provided ❌ const Basic = meta.story({ + // @ts-expect-error disabled not provided ❌ args: { label: 'good' }, }); } @@ -105,8 +105,8 @@ describe('Args can be provided in multiple ways', () => { component: Button, args: { label: 'good' }, }); - // @ts-expect-error disabled not provided ❌ const Basic = meta.story({ + // @ts-expect-error disabled not provided ❌ args: { label: 'good', }, diff --git a/code/renderers/react/src/docs/jsxDecorator.tsx b/code/renderers/react/src/docs/jsxDecorator.tsx index 1d1048c2e624..9a20de2cd7f1 100644 --- a/code/renderers/react/src/docs/jsxDecorator.tsx +++ b/code/renderers/react/src/docs/jsxDecorator.tsx @@ -161,7 +161,7 @@ export const renderJsx = (code: React.ReactElement, options?: JSXOptions) => { } const filterDefaults = { - filterProps: (value: any, key: string): boolean => value !== undefined, + filterProps: (value: any): boolean => value !== undefined, }; const opts = { diff --git a/code/renderers/react/src/enrichCsf.ts b/code/renderers/react/src/enrichCsf.ts index a804ce7e2479..209f0c3ada8b 100644 --- a/code/renderers/react/src/enrichCsf.ts +++ b/code/renderers/react/src/enrichCsf.ts @@ -1,4 +1,4 @@ -import { type NodePath, recast, types as t } from 'storybook/internal/babel'; +import { recast, types as t } from 'storybook/internal/babel'; import { getPrettier } from 'storybook/internal/common'; import { type CsfFile } from 'storybook/internal/csf-tools'; import type { PresetPropertyFn } from 'storybook/internal/types'; diff --git a/code/renderers/react/src/preview.tsx b/code/renderers/react/src/preview.tsx index ebcb0ffb960e..b82ad43cdd6d 100644 --- a/code/renderers/react/src/preview.tsx +++ b/code/renderers/react/src/preview.tsx @@ -1,8 +1,14 @@ import type { ComponentType } from 'react'; import { definePreview as definePreviewBase } from 'storybook/internal/csf'; -import type { AddonTypes, InferTypes, Meta, Preview, Story } from 'storybook/internal/csf'; -import type { PreviewAddon } from 'storybook/internal/csf'; +import type { + AddonTypes, + InferTypes, + Meta, + Preview, + PreviewAddon, + Story, +} from 'storybook/internal/csf'; import type { Args, ArgsStoryFn, diff --git a/code/renderers/react/src/public-types.test.tsx b/code/renderers/react/src/public-types.test.tsx index 45a36ab1d015..181ac173fc6e 100644 --- a/code/renderers/react/src/public-types.test.tsx +++ b/code/renderers/react/src/public-types.test.tsx @@ -24,12 +24,12 @@ const Button: (props: ButtonProps) => ReactElement = () => <>; describe('Args can be provided in multiple ways', () => { it('✅ All required args may be provided in meta', () => { - const meta = satisfies>()({ + const _meta = satisfies>()({ component: Button, args: { label: 'good', disabled: false }, }); - type Story = StoryObj; + type Story = StoryObj; const Basic: Story = {}; expectTypeOf(Basic).toEqualTypeOf< @@ -38,11 +38,11 @@ describe('Args can be provided in multiple ways', () => { }); it('✅ Required args may be provided partial in meta and the story', () => { - const meta = satisfies>()({ + const _meta = satisfies>()({ component: Button, args: { label: 'good' }, }); - const Basic: StoryObj = { + const Basic: StoryObj = { args: { disabled: false }, }; @@ -52,8 +52,8 @@ describe('Args can be provided in multiple ways', () => { it('❌ The combined shape of meta args and story args must match the required args.', () => { { - const meta = satisfies>()({ component: Button }); - const Basic: StoryObj = { + const _meta = satisfies>()({ component: Button }); + const Basic: StoryObj = { // @ts-expect-error disabled not provided ❌ args: { label: 'good' }, }; @@ -62,19 +62,19 @@ describe('Args can be provided in multiple ways', () => { expectTypeOf(Basic).toEqualTypeOf(); } { - const meta = satisfies>()({ + const _meta = satisfies>()({ component: Button, args: { label: 'good' }, }); // @ts-expect-error disabled not provided ❌ - const Basic: StoryObj = {}; + const Basic: StoryObj = {}; type Expected = ReactStory>; expectTypeOf(Basic).toEqualTypeOf(); } { - const meta = satisfies>()({ component: Button }); - const Basic: StoryObj = { + const _meta = satisfies>()({ component: Button }); + const Basic: StoryObj = { // @ts-expect-error disabled not provided ❌ args: { label: 'good' }, }; @@ -102,12 +102,12 @@ it('✅ Void functions are not changed', () => { const Cmp: (props: CmpProps) => ReactElement = () => <>; - const meta = satisfies>()({ + const _meta = satisfies>()({ component: Cmp, args: { label: 'good' }, }); - const Basic: StoryObj = { + const Basic: StoryObj = { args: { disabled: false, onLoading: () =>
      Loading...
      , @@ -128,7 +128,7 @@ describe('Story args can be inferred', () => { it('Correct args are inferred when type is widened for render function', () => { type Props = ButtonProps & { theme: ThemeData }; - const meta = satisfies>()({ + const _meta = satisfies>()({ component: Button, args: { disabled: false }, render: (args, { component }) => { @@ -143,7 +143,7 @@ describe('Story args can be inferred', () => { }, }); - const Basic: StoryObj = { args: { theme: 'light', label: 'good' } }; + const Basic: StoryObj = { args: { theme: 'light', label: 'good' } }; type Expected = ReactStory>; expectTypeOf(Basic).toEqualTypeOf(); @@ -159,13 +159,13 @@ describe('Story args can be inferred', () => { it('Correct args are inferred when type is widened for decorators', () => { type Props = ButtonProps & { decoratorArg: number }; - const meta = satisfies>()({ + const _meta = satisfies>()({ component: Button, args: { disabled: false }, decorators: [withDecorator], }); - const Basic: StoryObj = { args: { decoratorArg: 0, label: 'good' } }; + const Basic: StoryObj = { args: { decoratorArg: 0, label: 'good' } }; type Expected = ReactStory>; expectTypeOf(Basic).toEqualTypeOf(); @@ -195,13 +195,13 @@ describe('Story args can be inferred', () => { ); - const meta = satisfies>()({ + const _meta = satisfies>()({ component: Button, args: { disabled: false }, decorators: [withDecorator, secondDecorator, thirdDecorator, fourthDecorator], }); - const Basic: StoryObj = { + const Basic: StoryObj = { args: { decoratorArg: 0, decoratorArg2: '', label: 'good' }, }; @@ -210,19 +210,19 @@ describe('Story args can be inferred', () => { }); }); -it('StoryObj is allowed when meta is upcasted to Meta', () => { +it('StoryObj is allowed when meta is upcasted to Meta', () => { expectTypeOf>>().toEqualTypeOf< ReactStory> >(); }); -it('StoryObj is allowed when meta is upcasted to Meta', () => { +it('StoryObj is allowed when meta is upcasted to Meta', () => { expectTypeOf>>().toEqualTypeOf< ReactStory> >(); }); -it('StoryObj is allowed when all arguments are optional', () => { +it('StoryObj is allowed when all arguments are optional', () => { expectTypeOf>>().toEqualTypeOf< ReactStory<{ label?: string }, { label?: string }> >(); @@ -245,7 +245,7 @@ it('Props can be defined as interfaces, issue #21768', () => { ); - const meta = { + const _meta = { component: Component, args: { label: 'label', @@ -253,7 +253,7 @@ it('Props can be defined as interfaces, issue #21768', () => { decorators: [withDecorator], } satisfies Meta; - const Basic: StoryObj = {}; + const Basic: StoryObj = {}; type Expected = ReactStory>; expectTypeOf(Basic).toEqualTypeOf(); @@ -267,12 +267,12 @@ it('Components without Props can be used, issue #21768', () => { ); - const meta = { + const _meta = { component: Component, decorators: [withDecorator], } satisfies Meta; - const Basic: StoryObj = {}; + const Basic: StoryObj = {}; type Expected = ReactStory<{}, {}>; expectTypeOf(Basic).toEqualTypeOf(); @@ -306,14 +306,14 @@ it('Meta is broken when using discriminating types, issue #23629', () => { it('Infer mock function given to args in meta.', () => { type Props = { label: string; onClick: () => void; onRender: () => JSX.Element }; - const TestButton = (props: Props) => <>; + const TestButton = (_props: Props) => <>; - const meta = { + const _meta = { component: TestButton, args: { label: 'label', onClick: fn(), onRender: () => <>some jsx }, } satisfies Meta; - type Story = StoryObj; + type Story = StoryObj; const Basic: Story = { play: async ({ args, mount }) => { diff --git a/code/renderers/react/template/stories/docgen-components/8143-ts-react-fc-generics/docgen.snapshot b/code/renderers/react/template/stories/docgen-components/8143-ts-react-fc-generics/docgen.snapshot index 769a757e1873..a0a2f7543b76 100644 --- a/code/renderers/react/template/stories/docgen-components/8143-ts-react-fc-generics/docgen.snapshot +++ b/code/renderers/react/template/stories/docgen-components/8143-ts-react-fc-generics/docgen.snapshot @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/no-unused-vars */ import React from 'react'; export const Text = ({ padding = '0', diff --git a/code/renderers/react/template/stories/docgen-components/8143-ts-react-fc-generics/input.tsx b/code/renderers/react/template/stories/docgen-components/8143-ts-react-fc-generics/input.tsx index 9116328f1937..960917c14111 100644 --- a/code/renderers/react/template/stories/docgen-components/8143-ts-react-fc-generics/input.tsx +++ b/code/renderers/react/template/stories/docgen-components/8143-ts-react-fc-generics/input.tsx @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/no-unused-vars */ import React from 'react'; interface Props { diff --git a/code/renderers/react/template/stories/docgen-components/9023-js-hoc/docgen.snapshot b/code/renderers/react/template/stories/docgen-components/9023-js-hoc/docgen.snapshot index 8ce2304c42ca..c2d3a5dc7476 100644 --- a/code/renderers/react/template/stories/docgen-components/9023-js-hoc/docgen.snapshot +++ b/code/renderers/react/template/stories/docgen-components/9023-js-hoc/docgen.snapshot @@ -2,7 +2,7 @@ import React from 'react'; import PropTypes from 'prop-types'; // deepscan-disable-next-line -const withStyles = themeFn => Comp => Comp; +const withStyles = () => Comp => Comp; class Alert extends React.Component { render() { return /*#__PURE__*/React.createElement(React.Fragment, null, "Alert"); diff --git a/code/renderers/react/template/stories/docgen-components/9023-js-hoc/input.jsx b/code/renderers/react/template/stories/docgen-components/9023-js-hoc/input.jsx index db2f342342ab..c7525b601a76 100644 --- a/code/renderers/react/template/stories/docgen-components/9023-js-hoc/input.jsx +++ b/code/renderers/react/template/stories/docgen-components/9023-js-hoc/input.jsx @@ -3,7 +3,7 @@ import React from 'react'; import PropTypes from 'prop-types'; // deepscan-disable-next-line -const withStyles = (themeFn) => (Comp) => Comp; +const withStyles = () => (Comp) => Comp; class Alert extends React.Component { render() { diff --git a/code/renderers/react/template/stories/docgen-components/js-proptypes/input.jsx b/code/renderers/react/template/stories/docgen-components/js-proptypes/input.jsx index 565285865bc2..3ab09d8bcd9d 100644 --- a/code/renderers/react/template/stories/docgen-components/js-proptypes/input.jsx +++ b/code/renderers/react/template/stories/docgen-components/js-proptypes/input.jsx @@ -354,8 +354,6 @@ PropTypesProps.defaultProps = { string: 'Default string', func: () => {}, funcWithJsDoc: (foo, bar) => { - const yo = window.document; - return { foo, bar }; }, namedDefaultFunc: concat, diff --git a/code/renderers/server/src/render.ts b/code/renderers/server/src/render.ts index 5dab3c998ef8..e2f82c667899 100644 --- a/code/renderers/server/src/render.ts +++ b/code/renderers/server/src/render.ts @@ -43,7 +43,7 @@ const buildStoryArgs = (args: Args, argTypes: ArgTypes) => { return storyArgs; }; -export const render: StoryFn = (args: Args) => {}; +export const render: StoryFn = () => {}; export async function renderToCanvas( { diff --git a/code/renderers/svelte/src/public-types.test.ts b/code/renderers/svelte/src/public-types.test.ts index 9f51b2626486..5aa63aaddeea 100644 --- a/code/renderers/svelte/src/public-types.test.ts +++ b/code/renderers/svelte/src/public-types.test.ts @@ -52,12 +52,12 @@ describe('Meta', () => { describe('StoryObj', () => { it('✅ Required args may be provided partial in meta and the story', () => { - const meta = satisfies>()({ + const _meta = satisfies>()({ component: Button, args: { label: 'good' }, }); - type Actual = StoryObj; + type Actual = StoryObj; type Expected = SvelteStory< typeof Button, { disabled: boolean; label: string }, @@ -68,22 +68,22 @@ describe('StoryObj', () => { it('❌ The combined shape of meta args and story args must match the required args.', () => { { - const meta = satisfies>()({ component: Button }); + const _meta = satisfies>()({ component: Button }); type Expected = SvelteStory< typeof Button, { disabled: boolean; label: string }, { disabled: boolean; label: string } >; - expectTypeOf>().toExtend(); + expectTypeOf>().toExtend(); } { - const meta = satisfies>()({ + const _meta = satisfies>()({ component: Button, args: { label: 'good' }, }); // @ts-expect-error disabled not provided ❌ - const Basic: StoryObj = {}; + const Basic: StoryObj = {}; type Expected = SvelteStory< typeof Button, @@ -93,8 +93,8 @@ describe('StoryObj', () => { expectTypeOf(Basic).toExtend(); } { - const meta = satisfies>()({ component: Button }); - const Basic: StoryObj = { + const _meta = satisfies>()({ component: Button }); + const Basic: StoryObj = { // @ts-expect-error disabled not provided ❌ args: { label: 'good' }, }; @@ -123,7 +123,7 @@ type ThemeData = 'light' | 'dark'; describe('Story args can be inferred', () => { it('Correct args are inferred when type is widened for render function', () => { - const meta = satisfies & { theme: ThemeData }>>()({ + const _meta = satisfies & { theme: ThemeData }>>()({ component: Button, args: { disabled: false }, render: (args, { component }) => { @@ -134,7 +134,7 @@ describe('Story args can be inferred', () => { }, }); - const Basic: StoryObj = { args: { theme: 'light', label: 'good' } }; + const Basic: StoryObj = { args: { theme: 'light', label: 'good' } }; type Expected = SvelteStory< typeof Button, @@ -155,13 +155,13 @@ describe('Story args can be inferred', () => { it('Correct args are inferred when type is widened for decorators', () => { type Props = ComponentProps & { decoratorArg: string }; - const meta = satisfies>()({ + const _meta = satisfies>()({ component: Button, args: { disabled: false }, decorators: [withDecorator], }); - const Basic: StoryObj = { args: { decoratorArg: 'title', label: 'good' } }; + const Basic: StoryObj = { args: { decoratorArg: 'title', label: 'good' } }; type Expected = SvelteStory< typeof Button, @@ -182,13 +182,13 @@ describe('Story args can be inferred', () => { props: { decoratorArg2 }, }); - const meta = satisfies>()({ + const _meta = satisfies>()({ component: Button, args: { disabled: false }, decorators: [withDecorator, secondDecorator], }); - const Basic: StoryObj = { + const Basic: StoryObj = { args: { decoratorArg: '', decoratorArg2: '', label: 'good' }, }; diff --git a/code/renderers/vue3/src/docs/sourceDecorator.test.ts b/code/renderers/vue3/src/docs/sourceDecorator.test.ts index f0a926b0a1ec..b8d81b2bc9b6 100644 --- a/code/renderers/vue3/src/docs/sourceDecorator.test.ts +++ b/code/renderers/vue3/src/docs/sourceDecorator.test.ts @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/no-unused-vars */ import { expect, test } from 'vitest'; import { h } from 'vue'; @@ -239,9 +240,12 @@ test.each([ test.each<{ fn: (...args: any[]) => unknown; expectedNames: string[] }>([ { fn: () => ({}), expectedNames: [] }, + { fn: (a) => ({}), expectedNames: ['a'] }, + { fn: (a, b) => ({}), expectedNames: ['a', 'b'] }, { fn: (a, b, { c }) => ({}), expectedNames: ['a', 'b', '{', 'c', '}'] }, + { fn: ({ a, b }) => ({}), expectedNames: ['{', 'a', 'b', '}'] }, { fn: { diff --git a/code/renderers/vue3/src/docs/sourceDecorator.ts b/code/renderers/vue3/src/docs/sourceDecorator.ts index cda393daa818..3408cbf98b97 100644 --- a/code/renderers/vue3/src/docs/sourceDecorator.ts +++ b/code/renderers/vue3/src/docs/sourceDecorator.ts @@ -1,6 +1,6 @@ import { SourceType } from 'storybook/internal/docs-tools'; -import { emitTransformCode, useEffect, useRef } from 'storybook/preview-api'; +import { emitTransformCode, useEffect } from 'storybook/preview-api'; import type { VNode } from 'vue'; import { isVNode } from 'vue'; diff --git a/code/renderers/vue3/src/extractArgTypes.ts b/code/renderers/vue3/src/extractArgTypes.ts index fc71e747dee4..87fd1708be8b 100644 --- a/code/renderers/vue3/src/extractArgTypes.ts +++ b/code/renderers/vue3/src/extractArgTypes.ts @@ -1,6 +1,6 @@ -import type { ExtractedProp } from 'storybook/internal/docs-tools'; import { type ArgTypesExtractor, + type ExtractedProp, convert, extractComponentProps, hasDocgen, diff --git a/code/renderers/vue3/src/public-types.test.ts b/code/renderers/vue3/src/public-types.test.ts index 740dedb525f4..1187e8b7ca89 100644 --- a/code/renderers/vue3/src/public-types.test.ts +++ b/code/renderers/vue3/src/public-types.test.ts @@ -19,27 +19,27 @@ type ButtonProps = ComponentPropsAndSlots; describe('Meta', () => { it('Generic parameter of Meta can be a component', () => { - const meta: Meta = { + const _meta: Meta = { component: Button, args: { label: 'good', disabled: false }, }; - expectTypeOf(meta).toMatchTypeOf>(); + expectTypeOf(_meta).toMatchTypeOf>(); }); it('Generic parameter of Meta can be the props of the component', () => { - const meta: Meta<{ disabled: boolean; label: string }> = { + const _meta: Meta<{ disabled: boolean; label: string }> = { component: Button, args: { label: 'good', disabled: false }, }; - expectTypeOf(meta).toMatchTypeOf< + expectTypeOf(_meta).toMatchTypeOf< ComponentAnnotations >(); }); it('Events are inferred from component', () => { - const meta: Meta = { + const _meta: Meta = { component: Button, args: { label: 'good', @@ -57,44 +57,42 @@ describe('Meta', () => { }); }, }; - expectTypeOf(meta).toMatchTypeOf>(); + expectTypeOf(_meta).toMatchTypeOf>(); }); }); describe('StoryObj', () => { it('✅ Required args may be provided partial in meta and the story', () => { - const meta = satisfies>()({ + const _meta = satisfies>()({ component: Button, args: { label: 'good' }, }); - type Actual = StoryObj; + type Actual = StoryObj; type Expected = StoryAnnotations>; expectTypeOf().toMatchTypeOf(); }); it('❌ The combined shape of meta args and story args must match the required args.', () => { { - const meta = satisfies>()({ component: Button }); + const _meta = satisfies>()({ component: Button }); type Expected = StoryAnnotations; - expectTypeOf>().toMatchTypeOf(); + expectTypeOf>().toMatchTypeOf(); } { - const meta = satisfies>()({ + const _meta = satisfies>()({ component: Button, args: { label: 'good' }, }); - // @ts-expect-error disabled not provided ❌ - const Basic: StoryObj = {}; + const Basic: StoryObj = {}; type Expected = StoryAnnotations>; expectTypeOf(Basic).toMatchTypeOf(); } { - const meta = satisfies>()({ component: Button }); - const Basic: StoryObj = { - // @ts-expect-error disabled not provided ❌ + const _meta = satisfies>()({ component: Button }); + const Basic: StoryObj = { args: { label: 'good' }, }; @@ -116,7 +114,7 @@ describe('Story args can be inferred', () => { it('Correct args are inferred when type is widened for render function', () => { type Props = ButtonProps & { theme: ThemeData }; - const meta = satisfies>()({ + const _meta = satisfies>()({ component: Button, args: { disabled: false }, render: (args) => { @@ -124,7 +122,7 @@ describe('Story args can be inferred', () => { }, }); - const Basic: StoryObj = { args: { theme: 'light', label: 'good' } }; + const Basic: StoryObj = { args: { theme: 'light', label: 'good' } }; type Expected = StoryAnnotations>; expectTypeOf(Basic).toMatchTypeOf(); @@ -138,13 +136,13 @@ describe('Story args can be inferred', () => { it('Correct args are inferred when type is widened for decorators', () => { type Props = ButtonProps & { decoratorArg: string }; - const meta = satisfies>()({ + const _meta = satisfies>()({ component: Button, args: { disabled: false }, decorators: [withDecorator], }); - const Basic: StoryObj = { args: { decoratorArg: 'title', label: 'good' } }; + const Basic: StoryObj = { args: { decoratorArg: 'title', label: 'good' } }; type Expected = StoryAnnotations>; expectTypeOf(Basic).toMatchTypeOf(); @@ -161,13 +159,13 @@ describe('Story args can be inferred', () => { { args: { decoratorArg2 } } ) => h(Decorator2TsVue, { decoratorArg2 }, h(storyFn())); - const meta = satisfies>()({ + const _meta = satisfies>()({ component: Button, args: { disabled: false }, decorators: [withDecorator, secondDecorator], }); - const Basic: StoryObj = { + const Basic: StoryObj = { args: { decoratorArg: '', decoratorArg2: '', label: 'good' }, }; @@ -177,11 +175,11 @@ describe('Story args can be inferred', () => { }); it('Infer type of slots', () => { - const meta = { + const _meta = { component: BaseLayout, } satisfies Meta; - const Basic: StoryObj = { + const Basic: StoryObj = { args: { otherProp: true, header: ({ title }) => diff --git a/code/renderers/vue3/src/render.ts b/code/renderers/vue3/src/render.ts index e5ba9b363516..5d06379cf7e3 100644 --- a/code/renderers/vue3/src/render.ts +++ b/code/renderers/vue3/src/render.ts @@ -86,7 +86,7 @@ export async function renderToCanvas( }, }); - vueApp.config.errorHandler = (e: unknown, instance, info) => { + vueApp.config.errorHandler = (e: unknown) => { const preview = (window as Record) .__STORYBOOK_PREVIEW__ as PreviewWeb; const isPlaying = preview?.storyRenders.some( diff --git a/code/renderers/vue3/template/stories/preview.js b/code/renderers/vue3/template/stories/preview.js index 1c0783717426..e8fd904daccc 100644 --- a/code/renderers/vue3/template/stories/preview.js +++ b/code/renderers/vue3/template/stories/preview.js @@ -32,6 +32,6 @@ setup((app, context) => { }); // additonal setup to provide some propriety to the app -setup((app, context) => { +setup((app) => { app.provide(someColor, 'green'); }); diff --git a/code/renderers/vue3/template/stories_vue3-vite-default-ts/CustomRenderOptionsArgsFromData.stories.ts b/code/renderers/vue3/template/stories_vue3-vite-default-ts/CustomRenderOptionsArgsFromData.stories.ts index 427ec3602e43..06ef1254c734 100644 --- a/code/renderers/vue3/template/stories_vue3-vite-default-ts/CustomRenderOptionsArgsFromData.stories.ts +++ b/code/renderers/vue3/template/stories_vue3-vite-default-ts/CustomRenderOptionsArgsFromData.stories.ts @@ -15,7 +15,7 @@ const state = shallowReactive<{ header: any; default: any; footer: any }>({ const meta = { ...ReactiveDecorators.default, component: Reactivity, - render: (args, { argTypes }) => { + render: (args) => { state.header = args.header; state.default = args.default; state.footer = args.footer; diff --git a/code/renderers/vue3/template/stories_vue3-vite-default-ts/GlobalSetup.stories.ts b/code/renderers/vue3/template/stories_vue3-vite-default-ts/GlobalSetup.stories.ts index 3a54b1cc7aa1..db1baa30b678 100644 --- a/code/renderers/vue3/template/stories_vue3-vite-default-ts/GlobalSetup.stories.ts +++ b/code/renderers/vue3/template/stories_vue3-vite-default-ts/GlobalSetup.stories.ts @@ -29,7 +29,7 @@ export const Primary: Story = { primary: true, label: 'someColor injected from .storybook/preview.ts', }, - play: async ({ canvasElement, id }) => { + play: async ({ canvasElement }) => { const canvas = within(canvasElement); const button = await canvas.getByRole('button'); diff --git a/code/renderers/vue3/template/stories_vue3-vite-default-ts/ReactiveDecorators.stories.ts b/code/renderers/vue3/template/stories_vue3-vite-default-ts/ReactiveDecorators.stories.ts index 5feacc400eba..a7885cdcaa15 100644 --- a/code/renderers/vue3/template/stories_vue3-vite-default-ts/ReactiveDecorators.stories.ts +++ b/code/renderers/vue3/template/stories_vue3-vite-default-ts/ReactiveDecorators.stories.ts @@ -25,7 +25,7 @@ const meta = { header: 'If you see this, the header slot was not reactive.', // this can be useless if you have custom render function that overrides the slot footer: 'If you see this, the footer slot was not reactive.', }, - play: async ({ canvasElement, id, args }) => { + play: async ({ canvasElement, id }) => { const channel = (globalThis as any).__STORYBOOK_ADDONS_CHANNEL__; const canvas = within(canvasElement); @@ -57,7 +57,7 @@ export const NoDecorators: Story = {}; export const DecoratorFunctionalComponent: Story = { decorators: [ - (storyFn, context) => { + (storyFn) => { const story = storyFn(); return () => h('div', [h('h2', ['Decorator not using args']), [h(story)]]); }, @@ -76,7 +76,7 @@ export const DecoratorFunctionalComponentArgsFromContext: Story = { export const DecoratorComponentOptions: Story = { decorators: [ - (storyFn, context) => { + () => { return { template: '

      Decorator not using args

      ', }; diff --git a/code/renderers/vue3/template/stories_vue3-vite-default-ts/component-meta/reference-type-props/my-props.ts b/code/renderers/vue3/template/stories_vue3-vite-default-ts/component-meta/reference-type-props/my-props.ts index eee9aaaf5aa6..4d1974e2ac78 100644 --- a/code/renderers/vue3/template/stories_vue3-vite-default-ts/component-meta/reference-type-props/my-props.ts +++ b/code/renderers/vue3/template/stories_vue3-vite-default-ts/component-meta/reference-type-props/my-props.ts @@ -17,7 +17,7 @@ enum MyEnum { Large, } -const categories = [ +const _categories = [ 'Uncategorized', 'Content', 'Interaction', @@ -26,7 +26,7 @@ const categories = [ 'Addons', ] as const; -type MyCategories = (typeof categories)[number]; +type MyCategories = (typeof _categories)[number]; export interface MyProps { /** diff --git a/scripts/.eslintrc.cjs b/scripts/.eslintrc.cjs index 2f89276518c1..5ac18c7ffa51 100644 --- a/scripts/.eslintrc.cjs +++ b/scripts/.eslintrc.cjs @@ -58,10 +58,22 @@ module.exports = { '@typescript-eslint/no-wrapper-object-types': 'warn', '@typescript-eslint/no-empty-object-type': 'warn', '@typescript-eslint/ban-ts-comment': 'error', - '@typescript-eslint/no-unused-vars': 'warn', + 'import/no-duplicates': 'error', // merge duplicate imports from the same module + '@typescript-eslint/no-unused-vars': [ + 'error', + { + argsIgnorePattern: '^_', + varsIgnorePattern: '^_', + caughtErrorsIgnorePattern: '^e', + ignoreRestSiblings: true, + }, + ], '@typescript-eslint/no-redeclare': 'off', '@typescript-eslint/no-unsafe-function-type': 'warn', - '@typescript-eslint/consistent-type-imports': ['error', { disallowTypeAnnotations: false }], + '@typescript-eslint/consistent-type-imports': [ + 'error', + { disallowTypeAnnotations: false, fixStyle: 'inline-type-imports' }, + ], 'no-use-before-define': 'off', 'eslint-comments/disable-enable-pair': ['error', { allowWholeFile: true }], 'depend/ban-dependencies': [ diff --git a/scripts/eslint-plugin-local-rules/storybook-monorepo-imports.js b/scripts/eslint-plugin-local-rules/storybook-monorepo-imports.js index 9ca40f1bb843..2d6f499b3cb8 100644 --- a/scripts/eslint-plugin-local-rules/storybook-monorepo-imports.js +++ b/scripts/eslint-plugin-local-rules/storybook-monorepo-imports.js @@ -1,5 +1,4 @@ const path = require('path'); -const cache = {}; module.exports = { meta: { diff --git a/scripts/reset.js b/scripts/reset.js index 2586ececf6dd..4c3676d8abb7 100644 --- a/scripts/reset.js +++ b/scripts/reset.js @@ -1,8 +1,5 @@ import { spawn } from 'node:child_process'; import { appendFile, writeFileSync } from 'node:fs'; -import { rm } from 'node:fs/promises'; - -import trash from 'trash'; const logger = console; @@ -17,39 +14,6 @@ const cleaningProcess = spawn('git', [ ]); cleaningProcess.stdout.on('data', (data) => { - if (data && data.toString()) { - const l = data - .toString() - .split(/\n/) - .forEach((i) => { - const [, uri] = i.match(/Would remove (.*)$/) || []; - - if (uri) { - if ( - uri.match(/node_modules/) || - uri.match(/dist/) || - uri.match(/ts3\.4/) || - uri.match(/\.cache/) || - uri.match(/dll/) - ) { - rm(uri, { force: true, recursive: true }).then(() => { - logger.log(`deleted ${uri}`); - }); - } else { - trash(uri) - .then(() => { - logger.log(`trashed ${uri}`); - }) - .catch((e) => { - logger.log('failed to trash, will try permanent delete'); - rm(uri, { force: true, recursive: true }).then(() => { - logger.log(`deleted ${uri}`); - }); - }); - } - } - }); - } appendFile('reset.log', data, (err) => { if (err) { throw err; diff --git a/scripts/sandbox/generate.ts b/scripts/sandbox/generate.ts index 0ccff9a23327..b97ddf8b46bc 100755 --- a/scripts/sandbox/generate.ts +++ b/scripts/sandbox/generate.ts @@ -1,5 +1,4 @@ -import { cp, mkdir, readdir, rename, rm, writeFile } from 'node:fs/promises'; -import { readFile } from 'node:fs/promises'; +import { cp, mkdir, readFile, readdir, rename, rm, writeFile } from 'node:fs/promises'; import { join, relative } from 'node:path'; import * as ghActions from '@actions/core'; diff --git a/scripts/snippets/codemod.ts b/scripts/snippets/codemod.ts index 7467a8fc6853..75f9b6e7d231 100644 --- a/scripts/snippets/codemod.ts +++ b/scripts/snippets/codemod.ts @@ -6,10 +6,6 @@ * to test codemods as it helps detect many bugs very quickly. It also will be used once we decide * to add extra snippets to more renderers. */ - -/* eslint-disable @typescript-eslint/no-loop-func */ - -/* eslint-disable @typescript-eslint/default-param-last */ import os from 'node:os'; import { join } from 'node:path'; diff --git a/scripts/utils/tools.ts b/scripts/utils/tools.ts index 47ed8559228e..006a96818454 100644 --- a/scripts/utils/tools.ts +++ b/scripts/utils/tools.ts @@ -18,7 +18,6 @@ import sortPackageJson from 'sort-package-json'; import { dedent } from 'ts-dedent'; import type * as typefest from 'type-fest'; import typescript from 'typescript'; -import ts from 'typescript'; import { CODE_DIRECTORY } from './constants'; @@ -46,7 +45,7 @@ export const dts = async (entry: string, externals: string[], tsconfig: string) compilerOptions: { esModuleInterop: true, baseUrl: '.', - jsx: ts.JsxEmit.React, + jsx: typescript.JsxEmit.React, declaration: true, noEmit: false, emitDeclarationOnly: true, @@ -55,7 +54,7 @@ export const dts = async (entry: string, externals: string[], tsconfig: string) declarationMap: false, skipLibCheck: true, preserveSymlinks: false, - target: ts.ScriptTarget.ESNext, + target: typescript.ScriptTarget.ESNext, }, }), ],