Button: Add lint rule for 40px size prop usage#64835
Conversation
| <VStack spacing="5"> | ||
| <Text> | ||
| { `Are you sure you want to delete "${ item.title }"?` } | ||
| { `Are you sure you want to delete "${ item?.title }"?` } |
There was a problem hiding this comment.
Thanks for the report! I've prepared a fix at #64901
| <form onSubmit={ close }> | ||
| <input type="url" value={ url } onChange={ setUrl } /> | ||
| <Button | ||
| __next40pxDefaultSize |
There was a problem hiding this comment.
😞 we could try to propose a fix if it's a quick one
There was a problem hiding this comment.
Doesn't seem quick, but maybe something that can be fixed in conjunction with #64709.
| }; | ||
| } )( ( props ) => <Button onClick={ props.increment } /> ); | ||
| } )( ( props ) => ( | ||
| <Button __next40pxDefaultSize onClick={ props.increment } /> |
There was a problem hiding this comment.
Doesn't matter because this is a test.
|
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: +363 B (+0.02%) Total Size: 1.78 MB
ℹ️ View Unchanged
|
ciampo
left a comment
There was a problem hiding this comment.
LGTM 🚀
This PR is a reminder about why we're so cautious when dealing with Button 😅 So many usages!
* Fix in URLPopover story * Fix in Dataviews story * Fix in WithDispatch test * Add todo comments * Add lint rule Co-authored-by: mirka <0mirka00@git.wordpress.org> Co-authored-by: ciampo <mciampini@git.wordpress.org>
|
It seems like the lint rule would ideally except buttons that have I suppose that because gutenberg/packages/edit-site/src/components/site-hub/index.js Lines 80 to 82 in f073488 |
Right, the lint rule doesn't cover that. For what it's worth, the actual console warning will take the variant into account. |


Part of #63871
What?
Add a lint rule to prevent people from introducing new usages of Button that do not adhere to the new default size, while adding a TODO note on existing violations.
I also went ahead and fixed the three straightforward ones (tests and stories).
Why?
Some components have a large number of existing violations, and it would take some time to safely switch them all. 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 Button with no
__next40pxDefaultSizeorsizeprop.