-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
TextControl: Add lint rule for 40px size prop usage #64455
Conversation
// Temporary rules until all existing components have the `__next40pxDefaultSize` prop. | ||
...[ 'TextControl' ].map( ( componentName ) => ( { | ||
// Not strict. Allows pre-existing __next40pxDefaultSize={ false } usage until they are all manually updated. | ||
selector: `JSXOpeningElement[name.name="${ componentName }"]:not(:has(JSXAttribute[name.name="__next40pxDefaultSize"])):not(:has(JSXAttribute[name.name="size"]))`, | ||
message: | ||
componentName + | ||
' should have the `__next40pxDefaultSize` prop to opt-in to the new default size.', | ||
} ) ), |
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 is less strict than the rules that will be placed on components with no more existing violations. The goal is to resolve all existing violations for a given component, and move them to the list with the stricter rules.
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Size Change: +93 B (+0.01%) Total Size: 1.77 MB
ℹ️ View Unchanged
|
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.
LGTM, thanks 👍 🚀
What's the plan for addressing the pre-existing violations?
Are you planning to document them in an issue, or do you feel like the ESLint rule is enough (maybe by also mentioning it in #63871)?
Good question! There will be an extra checklist item in #63871 for components that still have remaining violations. I will personally dedicate time to reducing the existing violations as long as I have time remaining in my sprint. We'll see how much I can get through, and we might need to create a separate tracking issue once my stab at it is over. |
* TextControl: Add lint rule for 40px size prop usage * Fixup * Fixup formatting Co-authored-by: mirka <[email protected]> Co-authored-by: tyxla <[email protected]>
Part of #63871
What?
Add a lint rule to prevent people from introducing new usages of TextControl that do not adhere to the new default size, while adding a TODO note on existing violations.
Why?
Some components like TextControl have a large number of existing violations, and it would take some time to safely switch them all. I realized that we can more efficiently move everything to the new 40px sizes if we immediately start preventing new violations from entering the codebase, as well as add TODO comments on the existing violations so people who come across that code are more likely to fix it on the spot.
How?
I codemod'ed all existing violations to:
Testing Instructions
The lint error should trigger if you add a TextControl with no
__next40pxDefaultSize
orsize
prop.