Skip to content

[Bug]: sort-prop-types's autofix doesn't move the semicolon, producing broken code, on single-line Props types #3783

Closed
@tylerlaprade

Description

@tylerlaprade

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

sort-prop-types, with checkTypes: true, breaks the code when run on single-line Props with autofix due to the semicolon staying at the end instead of moving.

image

The props were rearranged without the semicolon dividing them

eslint --fix

Expected Behavior

Semicolon be moved along with the moved prop when running autofix

type CustomProps = { onChange: (event: { target: { name: string; value: string } }) => void; name: string };

should become

type CustomProps = { name: string; onChange: (event: { target: { name: string; value: string } }) => void };

Instead, it is fixing to

type CustomProps = { name: string onChange: (event: { target: { name: string; value: string } }) => void; };

eslint-plugin-react version

v7.34.4

eslint version

v8.57.0

node version

v20.14.10

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