Skip to content

jsx-sort-props reservedFirst conflicts with callbacksLast #1632

@jakezatecky

Description

@jakezatecky

It appears that PR #1340 introduced a change when reservedFirst is enabled such that it conflicts with the option callbacksLast. When this option is enabled, ESLint wants callbacks to be sorted alphabetically with respect to the rest of the properties. The following will incorrectly generate an error:

eslintrc:

{
  "rules": {
    "react/jsx-sort-props": ["error", {
      "callbacksLast": true,
      "reservedFirst": true
    }]
  }
}
<button
  className={className}
  disabled={disabled}
  type="button"
  onClick={this.onClick}
>
  Submit
</button>

Notice that onClick occurs after type, which should be the case given the rule configuration. However, the change in this PR made it to where the React plugin wants onClick to appear before type, effectively disabling the entire callbacksLast rule.

I have confirmed that reverting jsx-sort-props.js fixes this bug, but obviously that is not ideal because the alphabetic sorting fix in that PR is also desirable.

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