Skip to content

Bug: Type incompatibility with fixupPluginRules() from @eslint/compat #9115

Closed as not planned
@karlhorky

Description

@karlhorky

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.
  • I have searched for related issues and found none that matched my issue.
  • I have read the FAQ and my problem is not listed.

Relevant Package

utils

Playground Link

No response

Repro Code

import { fixupPluginRules } from '@eslint/compat';
import react from 'eslint-plugin-react';

/** @type {import('@typescript-eslint/utils/ts-eslint').FlatConfig.ConfigArray} */
const configArray = [
  {
    plugins: {
      react: fixupPluginRules(react), // 💥 Type 'FixupPluginDefinition' is not assignable to type 'Omit<Plugin, "configs">'.
                                      //   Types of property 'rules' are incompatible.
                                      //    Type 'Record<string, FixupRuleDefinition> | undefined' is not assignable to type 'Record<string, LooseRuleDefinition> | undefined'.
                                      //      Type 'Record<string, FixupRuleDefinition>' is not assignable to type 'Record<string, LooseRuleDefinition>'.
                                      //        'string' index signatures are incompatible.
                                      //          Type 'FixupRuleDefinition' is not assignable to type 'LooseRuleDefinition'.ts(2322)
    },
  },
];

ESLint Config

See above

tsconfig

n/a

Expected Result

The types for SharedConfig.RuleEntry match the return type for fixupPluginRules() from @eslint/compat

Actual Result

The types do not match:

Type 'FixupPluginDefinition' is not assignable to type 'Omit<Plugin, "configs">'.
  Types of property 'rules' are incompatible.
    Type 'Record<string, FixupRuleDefinition> | undefined' is not assignable to type 'Record<string, LooseRuleDefinition> | undefined'.
      Type 'Record<string, FixupRuleDefinition>' is not assignable to type 'Record<string, LooseRuleDefinition>'.
        'string' index signatures are incompatible.
          Type 'FixupRuleDefinition' is not assignable to type 'LooseRuleDefinition'.ts(2322)

Additional Info

No response

Versions

package version
@typescript-eslint/eslint-plugin 7.9.1-alpha.6
@typescript-eslint/parser 7.9.1-alpha.6
@typescript-eslint/rule-tester 7.9.1-alpha.6
@typescript-eslint/scope-manager 7.9.1-alpha.6
@typescript-eslint/typescript-estree 7.9.1-alpha.6
@typescript-eslint/type-utils 7.9.1-alpha.6
@typescript-eslint/utils 7.9.1-alpha.6
TypeScript 5.4.5
ESLint 9.3.0
node 20.13.1

I also tried the latest v8 alpha (@typescript-eslint/eslint-plugin@8.0.0-alpha.13), which should be compatible with ESLint v9, but this also results in the same error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingexternalThis issue is with another package, not typescript-eslint itselflocked due to agePlease open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing.working as intendedIssues that are closed as they are working as intended

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions