Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

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

Closed
2 tasks done
Stekmo opened this issue Mar 7, 2023 · 2 comments

Comments

@Stekmo
Copy link

Stekmo commented Mar 7, 2023

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

@Stekmo Stekmo added the bug label Mar 7, 2023
@Stekmo Stekmo changed the title [Bug]: [Bug]: Autofix removes generic type parameter from components when using react/jsx-first-prop-new-line Mar 8, 2023
@ljharb
Copy link
Member

ljharb commented Mar 14, 2023

I'm not seeing it autofix at all - the code you provided passes. The code in the image is different, though, I'll try that.

@ljharb
Copy link
Member

ljharb commented Mar 14, 2023

ok yeah thanks, i was able to repro it.

@ljharb ljharb closed this as completed in e1cf8c5 Mar 14, 2023
# for free to join this conversation on GitHub. Already have an account? # to comment
Development

No branches or pull requests

2 participants