Skip to content

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

New issue

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

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

Already on GitHub? Sign in to your account

Open
Garrett-R opened this issue May 4, 2025 · 3 comments
Open

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

Garrett-R opened this issue May 4, 2025 · 3 comments

Comments

@Garrett-R
Copy link

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

@ljharb
Copy link
Member

ljharb commented May 4, 2025

Why, exactly?

@Garrett-R
Copy link
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
Copy link
Member

ljharb commented May 5, 2025

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
Development

No branches or pull requests

2 participants