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

[jsx-sort-props] consider className as reserved props #3175

Closed
zhoudaxia2016 opened this issue Jan 12, 2022 · 8 comments
Closed

[jsx-sort-props] consider className as reserved props #3175

zhoudaxia2016 opened this issue Jan 12, 2022 · 8 comments

Comments

@zhoudaxia2016
Copy link

Hello

Can we support this?

@ljharb
Copy link
Member

ljharb commented Jan 12, 2022

Why? It's not a special prop.

@zhoudaxia2016
Copy link
Author

My team has a rule: className must be placed before all other props
Or can I have other way to achieve the rule

@ljharb
Copy link
Member

ljharb commented Jan 13, 2022

@zhoudaxia2016
Copy link
Author

Oh, it works.Thanks
Perhaps I misconfigured before

@saimonkat
Copy link

@ljharb it's not working now

@ljharb
Copy link
Member

ljharb commented Nov 10, 2024

@saimonkat y9ull need to elaborate; the OP fixed it by fixing their config.

@saimonkat
Copy link

@ljharb sorry, what do you mean? How can I use className in the reservedFirst prop at jsx-sort-props if it not allows it?

'react/jsx-sort-props': [
      'error',
      {
        noSortAlphabetically: true,
        shorthandLast: true,
        callbacksLast: true,
        reservedFirst: ['className'],
      },
    ],
const RESERVED_PROPS_LIST = [
  'children',
  'dangerouslySetInnerHTML',
  'key',
  'ref',
];

@ljharb
Copy link
Member

ljharb commented Nov 10, 2024

You're right, only those 4 can be in reservedFirst. The rule doesn't actually support arbitrary orders beyond what's configurable, by design.

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

No branches or pull requests

3 participants