Skip to content

svelte.configs.recommended type compatibility #1412

@hyunbinseo

Description

@hyunbinseo

Before You File a Bug Report Please Confirm You Have Done The Following...

  • I have tried restarting my IDE and the issue persists.
  • I have updated to the latest version of the packages.

What version of ESLint are you using?

9.38.0

What version of eslint-plugin-svelte are you using?

3.12.5

What did you do?

Configuration
import { includeIgnoreFile } from '@eslint/compat';
import js from '@eslint/js';
import svelte from 'eslint-plugin-svelte';
import { defineConfig } from 'eslint/config';
import globals from 'globals';
import { fileURLToPath } from 'node:url';
import ts from 'typescript-eslint';
import svelteConfig from './svelte.config.js';

const gitignorePath = fileURLToPath(new URL('./.gitignore', import.meta.url));

export default defineConfig(
  includeIgnoreFile(gitignorePath),
  js.configs.recommended,
  ...ts.configs.recommended,
  ...svelte.configs.recommended,
  {
    languageOptions: {
      globals: { ...globals.browser, ...globals.node },
    },
    rules: {
      // typescript-eslint strongly recommend that you do not use the no-undef lint rule on TypeScript projects.
      // see: https://typescript-eslint.io/troubleshooting/faqs/eslint/#i-get-errors-from-the-no-undef-rule-about-global-variables-not-being-defined-even-though-there-are-no-typescript-errors
      'no-undef': 'off',
    },
  },
  {
    files: ['**/*.svelte', '**/*.svelte.ts', '**/*.svelte.js'],
    languageOptions: {
      parserOptions: {
        projectService: true,
        extraFileExtensions: ['.svelte'],
        parser: ts.parser,
        svelteConfig,
      },
    },
  },
);

Initialize a SvelteKit project using the Svelte CLI (v0.9.9)

What did you expect to happen?

It used to work flawlessly, but is broken after recent package installation(update).

Downgrading @eslint/compat to @1.4.0 fixed the type error in existing repositories.

"@eslint/compat": "^1.4.1",
"@eslint/js": "^9.38.0",
"eslint": "^9.38.0",
"eslint-plugin-svelte": "^3.12.5",
"typescript-eslint": "^8.46.2",

What actually happened?

The default SvelteKit config shows TypeScript error in the following line:

...svelte.configs.recommended
Argument of type 'Config<RulesConfig>' is not assignable to parameter of type 'InfiniteArray<ConfigWithExtends>'.
  Type 'ConfigObject<RulesConfig>' is not assignable to type 'ConfigWithExtends'.
    Types of property 'plugins' are incompatible.
      Type 'Record<string, import("D:/_/node_modules/.pnpm/@eslint+core@0.16.0/node_modules/@eslint/core/dist/cjs/types").Plugin> | undefined' is not assignable to type 'Record<string, import("D:/_/node_modules/.pnpm/@eslint+core@0.17.0/node_modules/@eslint/core/dist/cjs/types").Plugin> | undefined'.
        Type 'Record<string, import("D:/_/node_modules/.pnpm/@eslint+core@0.16.0/node_modules/@eslint/core/dist/cjs/types").Plugin>' is not assignable to type 'Record<string, import("D:/_/node_modules/.pnpm/@eslint+core@0.17.0/node_modules/@eslint/core/dist/cjs/types").Plugin>'.
          'string' index signatures are incompatible.
            Type 'import("D:/_/node_modules/.pnpm/@eslint+core@0.16.0/node_modules/@eslint/core/dist/cjs/types").Plugin' is not assignable to type 'import("D:/_/node_modules/.pnpm/@eslint+core@0.17.0/node_modules/@eslint/core/dist/cjs/types").Plugin'.
              Types of property 'configs' are incompatible.
                Type 'Record<string, import("D:/_/node_modules/.pnpm/@eslint+core@0.16.0/node_modules/@eslint/core/dist/cjs/types").ConfigObject<import("D:/_/node_modules/.pnpm/@eslint+core@0.16.0/node_modules/@eslint/core/dist/cjs/types").RulesConfig> | import("D:/_/node_modules/.pnpm/@eslint+core@0.16.0/node_modules/@eslint/core/dist/c...' is not assignable to type 'Record<string, import("D:/_/node_modules/.pnpm/@eslint+core@0.17.0/node_modules/@eslint/core/dist/cjs/types").ConfigObject<import("D:/_/node_modules/.pnpm/@eslint+core@0.17.0/node_modules/@eslint/core/dist/cjs/types").RulesConfig> | import("D:/_/node_modules/.pnpm/@eslint+core@0.17.0/node_modules/@eslint/core/dist/c...'.
                  Type 'Record<string, import("D:/_/node_modules/.pnpm/@eslint+core@0.16.0/node_modules/@eslint/core/dist/cjs/types").ConfigObject<import("D:/_/node_modules/.pnpm/@eslint+core@0.16.0/node_modules/@eslint/core/dist/cjs/types").RulesConfig> | import("D:/_/node_modules/.pnpm/@eslint+core@0.16.0/node_modules/@eslint/core/dist/c...' is not assignable to type 'Record<string, import("D:/_/node_modules/.pnpm/@eslint+core@0.17.0/node_modules/@eslint/core/dist/cjs/types").ConfigObject<import("D:/_/node_modules/.pnpm/@eslint+core@0.17.0/node_modules/@eslint/core/dist/cjs/types").RulesConfig> | import("D:/_/node_modules/.pnpm/@eslint+core@0.17.0/node_modules/@eslint/core/dist/c...'.
                    'string' index signatures are incompatible.
                      Type 'import("D:/_/node_modules/.pnpm/@eslint+core@0.16.0/node_modules/@eslint/core/dist/cjs/types").ConfigObject<import("D:/_/node_modules/.pnpm/@eslint+core@0.16.0/node_modules/@eslint/core/dist/cjs/types").RulesConfig> | import("D:/_/node_modules/.pnpm/@eslint+core@0.16.0/node_modules/@eslint/core/dist/cjs/types").Lega...' is not assignable to type 'import("D:/_/node_modules/.pnpm/@eslint+core@0.17.0/node_modules/@eslint/core/dist/cjs/types").ConfigObject<import("D:/_/node_modules/.pnpm/@eslint+core@0.17.0/node_modules/@eslint/core/dist/cjs/types").RulesConfig> | import("D:/_/node_modules/.pnpm/@eslint+core@0.17.0/node_modules/@eslint/core/dist/cjs/types").Lega...'.
                        Type 'ConfigObject<RulesConfig>' is not assignable to type 'ConfigObject<RulesConfig> | LegacyConfigObject<RulesConfig, RulesConfig> | ConfigObject<RulesConfig>[]'.ts(2345)

Link to GitHub Repo with Minimal Reproducible Example

https://github.com/hyunbinseo/eslint-plugin-svelte-1412

Generated using the Svelte CLI (v0.9.9)

Additional comments

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions