Skip to content

jsx-sort-props rule is not working as it should #1692

Closed
@zalishchuk

Description

@zalishchuk

Rule configuration:

'react/jsx-sort-props': [
  'error',
  {
    noSortAlphabetically: false,
    ignoreCase: true,
    callbacksLast: false,
    shorthandLast: true,
    reservedFirst: true,
  },
],

As a result callbacksLast, shorthandLast options are overridden by noSortAlphabetically, so props are sorting only by alphabet ignoring shorthands at the end. Also, how can I reach this sort order:

  • object spread props
  • reserved props
  • common props (html attributes, etc.)
  • callback props
  • shorthand/boolean props

Example:

<button
  {...rest}
  key={1}
  type="button"
  onClick={() => {}}
  disabled
/>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions