Skip to content

[Bug]: Autofix removes generic type parameter from components when using react/jsx-first-prop-new-line #3546

Closed

Description

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

Generic components have their generic parameter removed when auto fixing.

Screen.Recording.2023-03-07.at.14.36.22.mov

It should not remove the generic argument.

I setup vscode to format on save. Alternatively eslint . --ext .tsx,.ts produces the same result.

My eslint config.

module.exports = {
  parser: "@typescript-eslint/parser",
  extends: [
    "plugin:compat/recommended",
    "plugin:react/recommended",
  ],
  env: {
    browser: true,
  },
  plugins: [
    "@typescript-eslint",
  ],
  parserOptions: {
    ecmaVersion: 2018,
    sourceType: "module",
    tsconfigRootDir: __dirname,
    project: "./tsconfig.json",
    ecmaFeatures: {
      jsx: true,
    },
  },
  rules: {
    "react/jsx-first-prop-new-line": ["error", "multiline"],
  },
  settings: {
    react: {
      version: "detect", // Tells eslint-plugin-react to automatically detect the version of React to use
    },
    "import/internal-regex": "^components/|^lib/",
    polyfills: ["fetch", "Promise"],
  },
};

Expected Behavior

It should keep the generic argument. E.g.

<DataTable<Items> fullscreen keyField="id" items={items}  />

Should become

<DataTable<Items> 
  fullscreen
  keyField="id"
  items={items}
/>

eslint-plugin-react version

v7.32.2

eslint version

v8.35.0

node version

v16.15.1

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

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