Skip to content

[enhancement]: flat configs are possibly undefined #3878

@CHC383

Description

@CHC383

Is there an existing issue for this?

  • I have searched the existing issues and my issue is unique
    My issue appears in the command-line and not only in the text editor

Description Overview

This is a follow up of #3874, since flat is Record<string, ReactFlatConfig>, flat.xxx or flat["xxx"] could be undefined. The fix might be explicitly list recommended, all and jsx-runtime as the key of the Record instead of using string.

Image
import tseslint from 'typescript-eslint'
import reactPlugin from 'eslint-plugin-react'

export default tseslint.config(
  reactPlugin.configs.flat.recommended
)
Argument of type 'ReactFlatConfig | undefined' is not assignable to parameter of type 'InfiniteDepthConfigWithExtends'.

Expected Behavior

No type error

eslint-plugin-react version

v7.37.4

eslint version

9.17.0

node version

v22.13.0

Activity

added a commit that references this issue on Jan 14, 2025
063db21
linked a pull request that will close this issue on Jan 14, 2025
ljharb

ljharb commented on Jan 14, 2025

@ljharb
Member

To be clear, this is not a bug - the types are correct - but you're right they could be more helpful.

changed the title [-][Bug]: flat configs are possibly undefined[/-] [+][enhancement]: flat configs are possibly undefined[/+] on Jan 14, 2025
added 4 commits that reference this issue on Jan 14, 2025
38fb151
cd30752
b7ad705
c51432e
CHC383

CHC383 commented on Jan 14, 2025

@CHC383
Author

Just to share a workaround for Typescript users until we figure out how to type the configs properly

// @ts-expect-error https://github.com/jsx-eslint/eslint-plugin-react/issues/3878
reactPlugin.configs.flat.recommended,
added a commit that references this issue on Jan 25, 2025
cd3665a
linked a pull request that will close this issue on Jan 25, 2025

6 remaining items

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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

      [enhancement]: flat configs are possibly undefined · Issue #3878 · jsx-eslint/eslint-plugin-react