Skip to content

jsx-sort-props: minimum number of props #3922

Open
@Garrett-R

Description

@Garrett-R

Similar to how ESLint's sort-keys has a configuration option of minKeys, it would be nice to have a minProps option.

Activity

ljharb

ljharb commented on May 4, 2025

@ljharb
Member

Why, exactly?

Garrett-R

Garrett-R commented on May 5, 2025

@Garrett-R
Author

Ah sorry, should have added context. Two reasons:

  1. for components with only a couple props, like say 2, the ordering isn't too important and the rule might be more annoying than helpful to the devs.
  2. devs may want the option to order "semantically" for reasonable number of props, for example:
<MyButton
    type="submit"
    color="blue"
    variant="solid"
    onBlur={onBlur}
    onClick={onClick}
/>

while if a component has like 10+ props, then I think it should definitely be ordered.

It seems (1) was the motivation for the analogue sort-keys being added to ESLint (see convo here).

ljharb

ljharb commented on May 5, 2025

@ljharb
Member

I guess it's fine, altho I'm not sure it's a good thing to be tacitly encouraging reduced enforcement.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @ljharb@Garrett-R

        Issue actions

          `jsx-sort-props`: minimum number of props · Issue #3922 · jsx-eslint/eslint-plugin-react