Skip to content

Bug: Type inference error when using tseslint.config() with eslint-plugin-react #8522

Closed
@printfn

Description

@printfn

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.

Issue Description

Using eslint-plugin-react inside of the tseslint.config() function in eslint.config.js causes the following type error in VS Code:

Argument of type '{ plugins: { react: { deprecatedRules: { [x: string]: any; [x: number]: any; [x: symbol]: any; }; rules: any; }; }; rules: { [x: string]: number; [x: number]: number; [x: symbol]: number; }; readonly languageOptions: any; } & { ...; }' is not assignable to parameter of type 'ConfigWithExtends'.
  Types of property 'plugins' are incompatible.
    Type '{ react: { deprecatedRules: { [x: string]: any; [x: number]: any; [x: symbol]: any; }; rules: any; }; }' is not assignable to type 'Plugins'.
      Property 'react' is incompatible with index signature.
        Object literal may only specify known properties, and 'deprecatedRules' does not exist in type 'Omit<Plugin, "configs">'.

eslint.config.js:

// @ts-check

import eslint from '@eslint/js';
import tseslint from 'typescript-eslint';
import eslintReact from 'eslint-plugin-react/configs/recommended.js';
import jsxRuntime from 'eslint-plugin-react/configs/jsx-runtime.js';

export default tseslint.config(
	eslint.configs.recommended,
	...tseslint.configs.recommended,
	eslintReact, // type error is on this line
	jsxRuntime,
	{
		settings: {
			react: {
				version: 'detect',
			},
		},
		languageOptions: {
			parserOptions: {
				project: ['./tsconfig.json', './tsconfig.node.json'],
			},
		},
	},
);

I'm not sure if this is a bug in eslint-plugin-react or typescript-eslint, but given that eslint still works correctly and this is purely a type error I opened an issue here.

Reproduction Repository Link

https://github.com/printfn/tseslint-react-repro

Repro Steps

  1. Clone the repo
  2. npm install
  3. Open the repository in VS Code and open the eslint.config.js file
  4. Notice that the line eslintReact has a type error

Versions

package version
@typescript-eslint/eslint-plugin 7.0.2
@typescript-eslint/parser 7.0.2
@typescript-eslint/scope-manager 7.0.2
@typescript-eslint/typescript-estree 7.0.2
@typescript-eslint/type-utils 7.0.2
@typescript-eslint/utils 7.0.2
TypeScript 5.3.3
ESLint 8.56.0
node 21.6.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingexternalThis issue is with another package, not typescript-eslint itself

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy