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

TextControl: Add lint rule for 40px size prop usage #64455

Merged
merged 4 commits into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,14 @@ module.exports = {
componentName +
' should have the `__next40pxDefaultSize` prop to opt-in to the new default size.',
} ) ),
// 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.',
} ) ),
Comment on lines +325 to +332
Copy link
Member Author

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.

],
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ function NonDefaultControls( { format, onChange } ) {
/>
{ isCustom && (
<TextControl
// TODO: Switch to `true` (40px size) if possible
__next40pxDefaultSize={ false }
__nextHasNoMarginBottom
label={ __( 'Custom format' ) }
hideLabelFromVision
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,8 @@ function URLInput( props ) {
>
<PanelBody style={ styles[ 'media-upload__link-input' ] }>
<TextControl
// TODO: Switch to `true` (40px size) if possible
__next40pxDefaultSize={ false }
// eslint-disable-next-line jsx-a11y/no-autofocus
autoFocus
autoCapitalize="none"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,12 +227,16 @@ const ImageURLInputUI = ( {
checked={ linkTarget === '_blank' }
/>
<TextControl
// TODO: Switch to `true` (40px size) if possible
__next40pxDefaultSize={ false }
__nextHasNoMarginBottom
label={ __( 'Link rel' ) }
value={ rel ?? '' }
onChange={ onSetLinkRel }
/>
<TextControl
// TODO: Switch to `true` (40px size) if possible
__next40pxDefaultSize={ false }
__nextHasNoMarginBottom
label={ __( 'Link CSS class' ) }
value={ linkClass || '' }
Expand Down
2 changes: 2 additions & 0 deletions packages/block-library/src/button/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,8 @@ function ButtonEdit( props ) {
<InspectorControls group="advanced">
{ isLinkTag && (
<TextControl
// TODO: Switch to `true` (40px size) if possible
__next40pxDefaultSize={ false }
__nextHasNoMarginBottom
label={ __( 'Link rel' ) }
value={ rel || '' }
Expand Down
2 changes: 2 additions & 0 deletions packages/block-library/src/form-input/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ function InputFieldBlock( { attributes, setAttributes, className } ) {
) }
<InspectorControls group="advanced">
<TextControl
// TODO: Switch to `true` (40px size) if possible
__next40pxDefaultSize={ false }
__nextHasNoMarginBottom
autoComplete="off"
label={ __( 'Name' ) }
Expand Down
2 changes: 2 additions & 0 deletions packages/block-library/src/form/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@ const Edit = ( { attributes, setAttributes, clientId } ) => {
) }
/>
<TextControl
// TODO: Switch to `true` (40px size) if possible
__next40pxDefaultSize={ false }
__nextHasNoMarginBottom
autoComplete="off"
label={ __( 'Form action' ) }
Expand Down
2 changes: 2 additions & 0 deletions packages/block-library/src/image/image.js
Original file line number Diff line number Diff line change
Expand Up @@ -690,6 +690,8 @@ export default function Image( {
) }
renderContent={ () => (
<TextControl
// TODO: Switch to `true` (40px size) if possible
__next40pxDefaultSize={ false }
className="wp-block-image__toolbar_content_textarea"
__nextHasNoMarginBottom
label={ __( 'Title attribute' ) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ export default function NavigationMenuNameControl() {

return (
<TextControl
// TODO: Switch to `true` (40px size) if possible
__next40pxDefaultSize={ false }
__nextHasNoMarginBottom
label={ __( 'Menu name' ) }
value={ title }
Expand Down
2 changes: 2 additions & 0 deletions packages/block-library/src/post-comment/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ export default function Edit( { attributes: { commentId }, setAttributes } ) {
) }
>
<TextControl
// TODO: Switch to `true` (40px size) if possible
__next40pxDefaultSize={ false }
__nextHasNoMarginBottom
value={ commentId }
onChange={ ( val ) =>
Expand Down
2 changes: 2 additions & 0 deletions packages/block-library/src/post-featured-image/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,8 @@ export default function PostFeaturedImageEdit( {
checked={ linkTarget === '_blank' }
/>
<TextControl
// TODO: Switch to `true` (40px size) if possible
__next40pxDefaultSize={ false }
__nextHasNoMarginBottom
label={ __( 'Link rel' ) }
value={ rel }
Expand Down
2 changes: 2 additions & 0 deletions packages/block-library/src/post-terms/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ export default function PostTermsEdit( {
</BlockControls>
<InspectorControls group="advanced">
<TextControl
// TODO: Switch to `true` (40px size) if possible
__next40pxDefaultSize={ false }
__nextHasNoMarginBottom
autoComplete="off"
label={ __( 'Separator' ) }
Expand Down
2 changes: 2 additions & 0 deletions packages/block-library/src/post-title/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,8 @@ export default function PostTitleEdit( {
checked={ linkTarget === '_blank' }
/>
<TextControl
// TODO: Switch to `true` (40px size) if possible
__next40pxDefaultSize={ false }
__nextHasNoMarginBottom
label={ __( 'Link rel' ) }
value={ rel }
Expand Down
4 changes: 4 additions & 0 deletions packages/block-library/src/social-link/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ const SocialLinkEdit = ( {
<PanelBody title={ __( 'Settings' ) }>
<PanelRow>
<TextControl
// TODO: Switch to `true` (40px size) if possible
__next40pxDefaultSize={ false }
__nextHasNoMarginBottom
label={ __( 'Text' ) }
help={ __(
Expand All @@ -155,6 +157,8 @@ const SocialLinkEdit = ( {
</InspectorControls>
<InspectorControls group="advanced">
<TextControl
// TODO: Switch to `true` (40px size) if possible
__next40pxDefaultSize={ false }
__nextHasNoMarginBottom
label={ __( 'Link rel' ) }
value={ rel || '' }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ export function TemplatePartAdvancedControls( {
{ isEntityAvailable && (
<>
<TextControl
// TODO: Switch to `true` (40px size) if possible
__next40pxDefaultSize={ false }
__nextHasNoMarginBottom
label={ __( 'Title' ) }
value={ title }
Expand Down
4 changes: 4 additions & 0 deletions packages/block-library/src/video/tracks-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ function SingleTrackEditor( { track, onChange, onClose, onRemove } ) {
</span>
<Grid columns={ 2 } gap={ 4 }>
<TextControl
// TODO: Switch to `true` (40px size) if possible
__next40pxDefaultSize={ false }
__nextHasNoMarginBottom
/* eslint-disable jsx-a11y/no-autofocus */
autoFocus
Expand All @@ -114,6 +116,8 @@ function SingleTrackEditor( { track, onChange, onClose, onRemove } ) {
help={ __( 'Title of track' ) }
/>
<TextControl
// TODO: Switch to `true` (40px size) if possible
__next40pxDefaultSize={ false }
__nextHasNoMarginBottom
onChange={ ( newSrcLang ) =>
onChange( {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ function AddNewItemModalContent( { type, setIsAdding } ) {
>
<VStack spacing="5">
<TextControl
// TODO: Switch to `true` (40px size) if possible
__next40pxDefaultSize={ false }
__nextHasNoMarginBottom
label={ __( 'Name' ) }
value={ title }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ function RenameItemModalContent( { dataviewId, currentTitle, setIsRenaming } ) {
>
<VStack spacing="5">
<TextControl
// TODO: Switch to `true` (40px size) if possible
__next40pxDefaultSize={ false }
__nextHasNoMarginBottom
label={ __( 'Name' ) }
value={ title }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ class PostPublishPanelPostpublish extends Component {
</p>
<div className="post-publish-panel__postpublish-post-address-container">
<TextControl
// TODO: Switch to `true` (40px size) if possible
__next40pxDefaultSize={ false }
__nextHasNoMarginBottom
className="post-publish-panel__postpublish-post-address"
readOnly
Expand Down
2 changes: 2 additions & 0 deletions packages/editor/src/components/post-slug/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ function PostSlugControl() {

return (
<TextControl
// TODO: Switch to `true` (40px size) if possible
__next40pxDefaultSize={ false }
__nextHasNoMarginBottom
label={ __( 'Slug' ) }
autoComplete="off"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,8 @@ export function HierarchicalTermSelector( { slug } ) {
<Flex direction="column" gap="4">
{ showFilter && (
<TextControl
// TODO: Switch to `true` (40px size) if possible
__next40pxDefaultSize={ false }
__nextHasNoMarginBottom
label={ filterLabel }
value={ filterValue }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,8 @@ export default function ReusableBlockConvertButton( {
>
<VStack spacing="5">
<TextControl
// TODO: Switch to `true` (40px size) if possible
__next40pxDefaultSize={ false }
__nextHasNoMarginBottom
label={ __( 'Name' ) }
value={ title }
Expand Down
Loading