Skip to content
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

Require JSX props to be alphabetically sorted (react/jsx-sort-props) and Require defaultProps declarations to be alphabetically sorted (react/jsx-sort-default-props) #1362

Open
feross opened this issue Aug 15, 2019 · 0 comments

Comments

@feross
Copy link
Member

commented Aug 15, 2019

Some developers prefer to sort props names alphabetically to be able to find necessary props easier at the later time.

https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-sort-props.md

This is the config I tested with and the results were reasonable:

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

Here's an example of a diff that applies this rule with the config from above: feross/bitmidi.com@a256ba3


And there's another related rule:

Some developers prefer to sort defaultProps declarations alphabetically to be able to find necessary declarations easier at a later time.

https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-sort-default-props.md

Here's the config I tested with:

"react/jsx-sort-default-props": ["error", { "ignoreCase": false }],

Feedback on these two rules very much welcome.

@feross feross added this to the standard 15 milestone Aug 15, 2019

@feross feross changed the title Require JSX props to be alphabetically sorted (react/jsx-sort-props) Require JSX props to be alphabetically sorted (react/jsx-sort-props) and Require defaultProps declarations to be alphabetically sorted (react/jsx-sort-default-props) Aug 15, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
1 participant
You can’t perform that action at this time.