Skip to content

[Bug]: Config is not assignable to type when using defineConfig #34468

@SalahAdDin

Description

@SalahAdDin

Describe the bug

We are using defineConfig in our project for setting up ESLint:

export default defineConfig([
  globalIgnores([
    "coverage",
    "dist",
    "node_modules",
    ".astro/**",
    ".github",
    ".vscode",
    "!.storybook",
  ]),
  {
...
  },
  ...storybook.configs["flat/recommended"],
]);

When linting it with it, we get:

Type '{ name: string; plugins: { readonly storybook: { configs: any; rules: { 'await-interactions': RuleModule<"interactionShouldBeAwaited" | "fixSuggestion", never[], unknown, RuleListener>; ... 14 more ...; 'use-storybook-testing-library': RuleModule<...>; }; }; }; files?: undefined; rules?: undefined; } | { ...; } | { ...' is not assignable to type 'InfiniteArray<ConfigWithExtends>'.
  Type '{ name: string; plugins: { readonly storybook: { configs: any; rules: { 'await-interactions': RuleModule<"interactionShouldBeAwaited" | "fixSuggestion", never[], unknown, RuleListener>; ... 14 more ...; 'use-storybook-testing-library': RuleModule<...>; }; }; }; files?: undefined; rules?: undefined; }' is not assignable to type 'InfiniteArray<ConfigWithExtends>'.
    Type '{ name: string; plugins: { readonly storybook: { configs: any; rules: { 'await-interactions': RuleModule<"interactionShouldBeAwaited" | "fixSuggestion", never[], unknown, RuleListener>; ... 14 more ...; 'use-storybook-testing-library': RuleModule<...>; }; }; }; files?: undefined; rules?: undefined; }' is not assignable to type 'ConfigWithExtends'.
      Types of property 'plugins' are incompatible.
        Type '{ readonly storybook: { configs: any; rules: { 'await-interactions': RuleModule<"interactionShouldBeAwaited" | "fixSuggestion", never[], unknown, RuleListener>; 'context-in-play-function': RuleModule<...>; ... 13 more ...; 'use-storybook-testing-library': RuleModule<...>; }; }; }' is not assignable to type 'Record<string, Plugin>'.
          Property 'storybook' is incompatible with index signature.
            Type '{ configs: any; rules: { 'await-interactions': RuleModule<"interactionShouldBeAwaited" | "fixSuggestion", never[], unknown, RuleListener>; 'context-in-play-function': RuleModule<...>; ... 13 more ...; 'use-storybook-testing-library': RuleModule<...>; }; }' is not assignable to type 'Plugin'.
              Types of property 'rules' are incompatible.
                Type '{ 'await-interactions': RuleModule<"interactionShouldBeAwaited" | "fixSuggestion", never[], unknown, RuleListener>; 'context-in-play-function': RuleModule<"passContextToPlayFunction", never[], unknown, RuleListener>; ... 13 more ...; 'use-storybook-testing-library': RuleModule<...>; }' is not assignable to type 'Record<string, RuleDefinition<RuleDefinitionTypeOptions>>'.
                  Property ''await-interactions'' is incompatible with index signature.
                    Type 'RuleModule<"interactionShouldBeAwaited" | "fixSuggestion", never[], unknown, RuleListener>' is not assignable to type 'RuleDefinition<RuleDefinitionTypeOptions>'.
                      Types of property 'create' are incompatible.
                        Type '(context: Readonly<RuleContext<"interactionShouldBeAwaited" | "fixSuggestion", never[]>>) => RuleListener' is not assignable to type '(context: RuleContext<{ LangOptions: LanguageOptions; Code: SourceCode<{ LangOptions: LanguageOptions; RootNode: unknown; SyntaxElementWithLoc: unknown; ConfigNode: unknown; }>; RuleOptions: unknown[]; Node: unknown; MessageIds: string; }>) => RuleVisitor'.
                          Types of parameters 'context' and 'context' are incompatible.
                            Type 'RuleContext<{ LangOptions: LanguageOptions; Code: SourceCode<{ LangOptions: LanguageOptions; RootNode: unknown; SyntaxElementWithLoc: unknown; ConfigNode: unknown; }>; RuleOptions: unknown[]; Node: unknown; MessageIds: string; }>' is missing the following properties from type 'Readonly<RuleContext<"interactionShouldBeAwaited" | "fixSuggestion", never[]>>': parserOptions, parserPath, getAncestors, getDeclaredVariables, and 6 more.

Reproduction link

https://github.com/SalahAdDin/central-mosque-bogota/tree/main/frontend

Reproduction steps

  1. Go to the eslint.config.ts.
  2. Run the linter.
  3. See the error.

System

│  Storybook Environment Info:
│

│  System:
│  OS: Linux 6.12 Deepin 25 25
│  CPU: (32) x64 Intel(R) Core(TM) i9-14900HX
│  Shell: 5.9 - /usr/bin/zsh
│  Binaries:
│  Node: 24.14.1 - /run/user/1001/fnm_multishells/34205_1775444517610/bin/node
│  Yarn: 1.22.22 - /usr/local/bin/yarn
│  npm: 11.11.0 - /run/user/1001/fnm_multishells/34205_1775444517610/bin/npm
│  pnpm: 10.33.0 - /run/user/1001/fnm_multishells/34205_1775444517610/bin/pnpm
│  <----- active
│  npmPackages:
│  @storybook/addon-a11y: 10.3.4 => 10.3.4
│  @storybook/addon-designs: 11.1.3 => 11.1.3
│  @storybook/addon-docs: 10.3.4 => 10.3.4
│  @storybook/addon-themes: 10.3.4 => 10.3.4
│  @storybook/addon-vitest: 10.3.4 => 10.3.4
│  @storybook/builder-vite: 10.3.4 => 10.3.4
│  eslint-plugin-storybook: 10.3.4 => 10.3.4
│  storybook: 10.3.4 => 10.3.4
│  storybook-addon-rtl: 3.0.1 => 3.0.1
│  storybook-addon-tag-badges: 3.1.0 => 3.1.0

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions