-
Notifications
You must be signed in to change notification settings - Fork 76
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
chore: custom ESLint rule to disable sorting for ref
attribute to keep it as last property in JSX to ensure it is up-to-date
#7669
chore: custom ESLint rule to disable sorting for ref
attribute to keep it as last property in JSX to ensure it is up-to-date
#7669
Conversation
…p it as last property in JSX to ensure it is up-to-date
It doesn't look like jsx-eslint/eslint-plugin-react has kept their docs up to date. There is a prop called reservedList available for the eslint react/jsx-sort-props that should allow "ref" to be at the bottom of a multiline list of attributes. "react/jsx-sort-props": [
"error",
{
reservedList: ["ref"],
},
], |
I would rather not use an undocumented prop, it doesn't feel like a good practice. |
I ran quick test on my local branch before I made the comment. However, after opening a clean branch off of Main and running some additional tests, I don’t think it’s working the way I thought. That said, I think it would be better to open an issue and PR to eslint-jsx/eslint-react with a "reservedLast" prop (or something) rather than making (and then having to maintain) a new eslint plugin. |
Agreed.
Agreed. We should open an issue/PR but in the meantime we could do our own thing with a custom plugin. Who knows if they would add or accept the feature we are requesting. |
This PR has been automatically marked as stale because it has not had recent activity. Please close your PR if it is no longer relevant. Thank you for your contributions. |
This PR has been automatically marked as stale because it has not had recent activity. Please close your PR if it is no longer relevant. Thank you for your contributions. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Maybe the wording could be cleaned up a little.
packages/eslint-plugin-calcite-components/src/rules/enforce-ref-last-prop.ts
Outdated
Show resolved
Hide resolved
packages/eslint-plugin-calcite-components/src/rules/enforce-ref-last-prop.ts
Outdated
Show resolved
Hide resolved
packages/eslint-plugin-calcite-components/src/rules/enforce-ref-last-prop.ts
Outdated
Show resolved
Hide resolved
packages/eslint-plugin-calcite-components/src/rules/enforce-ref-last-prop.ts
Outdated
Show resolved
Hide resolved
This PR has been automatically marked as stale because it has not had recent activity. Please close your PR if it is no longer relevant. Thank you for your contributions. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🕶️🕶️🕶️🕶️🕶️🕶️🕶️🕶️🕶️🕶️🕶️🕶️🕶️🕶️🕶️🕶️🕶️🕶️🕶️🕶️🕶️🕶️🕶️🕶️🕶️🕶️🕶️🕶️🕶️🕶️🕶️🕶️🕶️🕶️🕶️🕶️🕶️🕶️🕶️🕶️🕶️🕶️
🕶️😎😎😎😎🕶️😎🕶️🕶️🕶️🕶️🕶️😎🕶️😎😎😎😎🕶️🕶️😎😎😎🕶️🕶️😎😎🕶️🕶️😎🕶️🕶️🕶️😎🕶️😎😎😎😎🕶️😎🕶️
🕶️😎🕶️🕶️😎🕶️😎🕶️🕶️🕶️🕶️🕶️😎🕶️😎🕶️🕶️🕶️🕶️😎🕶️🕶️🕶️🕶️😎🕶️🕶️😎🕶️😎😎🕶️😎😎🕶️😎🕶️🕶️🕶️🕶️😎🕶️
🕶️😎😎😎😎🕶️😎🕶️🕶️😎🕶️🕶️😎🕶️😎😎😎🕶️🕶️🕶️😎😎🕶️🕶️😎🕶️🕶️😎🕶️😎🕶️😎🕶️😎🕶️😎😎😎🕶️🕶️😎🕶️
🕶️😎🕶️🕶️😎🕶️😎🕶️😎🕶️😎🕶️😎🕶️😎🕶️🕶️🕶️🕶️🕶️🕶️🕶️😎🕶️😎🕶️🕶️😎🕶️😎🕶️🕶️🕶️😎🕶️😎🕶️🕶️🕶️🕶️🕶️🕶️
🕶️😎🕶️🕶️😎🕶️🕶️😎🕶️🕶️🕶️😎🕶️🕶️😎😎😎😎🕶️😎😎😎🕶️🕶️🕶️😎😎🕶️🕶️😎🕶️🕶️🕶️😎🕶️😎😎😎😎🕶️😎🕶️
🕶️🕶️🕶️🕶️🕶️🕶️🕶️🕶️🕶️🕶️🕶️🕶️🕶️🕶️🕶️🕶️🕶️🕶️🕶️🕶️🕶️🕶️🕶️🕶️🕶️🕶️🕶️🕶️🕶️🕶️🕶️🕶️🕶️🕶️🕶️🕶️🕶️🕶️🕶️🕶️🕶️🕶️
packages/eslint-plugin-calcite-components/src/rules/enforce-ref-last-prop.ts
Outdated
Show resolved
Hide resolved
...ugin-calcite-components/tests/lib/rules/enforce-ref-last-prop/enforce-ref-last-prop.good.tsx
Show resolved
Hide resolved
…sage. Some minor corrections.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be good to merge once the last comments are addressed. 🚀
id={`${guid}-element`} | ||
onClick={() => { | ||
/* click! */ | ||
}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tabIndex
should go here to match the good case.
**Related Issue:** #7669, #7659 ## Summary Refactor to improve on `enforce-ref-last-prop` ESLint rule docs. --------- Co-authored-by: JC Franco <[email protected]>
**Related Issue:** #7669, #7659 ## Summary Refactor to improve on `enforce-ref-last-prop` ESLint rule docs. --------- Co-authored-by: JC Franco <[email protected]>
Related Issue: #7659
Summary
Custom ESLint rule to provide a more granular prop ordering mechanism by forcing the
ref
attribute to be kept as the last property so we can ensure it is up-to-date.Added a test file for the new custom rules: the file references different use cases, which are 1 good and 1 bad usage files.