-
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
SelectControl: Add lint rule for 40px size prop usage #64486
Conversation
Size Change: +300 B (+0.02%) Total Size: 1.77 MB
ℹ️ View Unchanged
|
@@ -71,9 +71,18 @@ The current font family value. | |||
|
|||
The rest of the props are passed down to the underlying `<SelectControl />` instance. | |||
|
|||
#### `__next40pxDefaultSize` |
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.
By the way this prop is not yet documented in any of the @wordpress/components
READMEs at the moment, just in Storybook. I'll do a PR soon to add them all.
@@ -50,6 +52,7 @@ export default function FontFamilyControl( { | |||
|
|||
return ( | |||
<SelectControl | |||
__next40pxDefaultSize={ __next40pxDefaultSize } |
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 was already passed through via rest props, but making it explicit here.
@@ -40,6 +40,7 @@ const renderTestDefaultControlComponent = ( labelComponent, device ) => { | |||
return ( | |||
<> | |||
<SelectControl | |||
__next40pxDefaultSize |
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.
Doesn't matter because this is a test.
@@ -51,6 +51,7 @@ export default function ArchivesEdit( { attributes, setAttributes } ) { | |||
} | |||
/> | |||
<SelectControl | |||
__next40pxDefaultSize |
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.
@@ -174,6 +174,7 @@ function AudioEdit( { | |||
checked={ loop } | |||
/> | |||
<SelectControl | |||
__next40pxDefaultSize |
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.
@@ -73,6 +73,7 @@ export default function FileBlockInspector( { | |||
) } | |||
<PanelBody title={ __( 'Settings' ) }> | |||
<SelectControl | |||
__next40pxDefaultSize |
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.
@@ -112,6 +112,7 @@ function PostAuthorEdit( { | |||
/> | |||
) ) || ( | |||
<SelectControl | |||
__next40pxDefaultSize |
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.
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. |
Disable the audio tag if the block is not selected | ||
so the user clicking on it won't play the | ||
file or change the position slider when the controls are enabled. | ||
*/ } |
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.
is this mix of spaces and tabs in the file expected?
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.
Weird, I reformatted it and it changed the spaces back to tabs, but it still doesn't match the original. Not sure why it isn't deterministic 🤷 892c9c1
@@ -130,6 +130,8 @@ const Edit = ( { attributes, setAttributes, clientId } ) => { | |||
{ submissionMethod !== 'email' && ( | |||
<InspectorControls group="advanced"> | |||
<SelectControl | |||
// TODO: Switch to `true` (40px size) if possible | |||
__next40pxDefaultSize={ false } |
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.
(excuses if this has already been asked) Do we have a place where we track all the occurrences that need updating and are exception to the lint rule?
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.
I'm assuming you're asking about discoverability. A few ways:
- I'm leaving a separate checklist item in Components: Add eslint rules to prevent usage without
__next40pxDefaultSize
prop #63871 so we know there are remaining violations. - We can search the TODO comment string.
- We can move this component to the stricter lint rule in the eslintrc, which doesn't allow
__next40pxDefaultSize={ false }
. That would surface all the remaining violations.
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.
Makes sense, thank you!
Another one down 🚀 |
Part of #63871
What?
Add a lint rule to prevent people from introducing new usages of SelectControl that do not adhere to the new default size, while adding a TODO note on existing violations.
I also went ahead and fixed the most straightforward ones.
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 SelectControl with no
__next40pxDefaultSize
orsize
prop.