-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Closed
Labels
Description
Is there any interest in including a rule like the following in this plugin?
https://github.com/ericmatthys/eslint-plugin-jsx-grouped-sort-props
This is a rule that allows sorting of jsx props in groups without requiring an alphabetical sort. My motivation was wanting specific props sorted first (e.g. key and ref), then all other non-callback props in any order, then all callback props in any order at the end. The rule allows specific prop names in an array or various pre-configured groups (e.g. html, reserved, callback). If there is a spread, it validates the prop order before and after the spread independently. For the use case above, the configuration would look like:
[
'key',
'ref',
{ group: 'other' },
{ group: 'callback' }
]Valid:
<Button
ref="btn"
isLoading={true}
onClick={onClick}
/><Button
ref="btn"
onClick={onClick}
{...props}
isLoading={true}
/>Invalid:
<Button
isLoading={true}
ref="btn"
onClick={onClick}
/><Button
ref="btn"
onClick={onClick}
isLoading={true}
/><Button
ref="btn"
{...props}
onClick={onClick}
isLoading={true}
/>