From 6337e036f3bc5ece013d5b2536d7d16b1ec658e8 Mon Sep 17 00:00:00 2001 From: Echo Date: Wed, 5 Nov 2025 16:11:04 +0100 Subject: [PATCH] Add new ESLint rule requiring explicit button types (#36738) --- app/javascript/mastodon/components/alert/index.tsx | 6 +++++- app/javascript/mastodon/components/button/index.tsx | 1 + .../mastodon/components/column_back_button.tsx | 2 +- app/javascript/mastodon/components/column_header.tsx | 12 +++++++++++- .../mastodon/components/copy_paste_text.tsx | 2 +- app/javascript/mastodon/components/dropdown_menu.tsx | 1 + .../mastodon/components/edited_timestamp/index.tsx | 9 +++++++-- app/javascript/mastodon/components/hashtag_bar.tsx | 2 +- .../mastodon/components/hotkeys/hotkeys.stories.tsx | 2 +- .../mastodon/components/learn_more_link.tsx | 7 ++++++- app/javascript/mastodon/components/load_gap.tsx | 1 + app/javascript/mastodon/components/load_pending.tsx | 2 +- app/javascript/mastodon/components/poll.tsx | 9 +++++++-- .../mastodon/components/status/boost_button.tsx | 1 + app/javascript/mastodon/components/status_quoted.tsx | 4 ++-- .../mastodon/features/about/components/section.tsx | 1 + .../features/account/components/domain_pill.tsx | 3 +++ .../mastodon/features/alt_text_modal/index.tsx | 1 + .../mastodon/features/compose/components/search.tsx | 8 +++++++- .../components/inline_follow_suggestions.tsx | 4 +++- .../mastodon/features/interaction_modal/index.tsx | 3 ++- .../navigation_panel/components/more_link.tsx | 2 +- .../navigation_panel/components/sign_in_banner.tsx | 1 + .../components/filtered_notifications_banner.tsx | 1 + .../components/notification_annual_report.tsx | 2 +- .../features/notifications_v2/filter_bar.tsx | 1 + .../mastodon/features/notifications_v2/index.tsx | 1 + .../features/search/components/search_section.tsx | 2 +- app/javascript/mastodon/features/search/index.tsx | 4 ++++ .../features/ui/components/actions_modal.tsx | 7 ++++++- .../mastodon/features/ui/components/boost_modal.tsx | 2 +- .../confirmation_modals/confirmation_modal.tsx | 8 ++++++-- .../features/ui/components/domain_block_modal.tsx | 2 +- .../mastodon/features/ui/components/media_modal.tsx | 3 +++ .../features/ui/components/navigation_bar.tsx | 7 ++++++- app/javascript/mastodon/features/video/index.tsx | 1 + eslint.config.mjs | 2 ++ 37 files changed, 101 insertions(+), 26 deletions(-) diff --git a/app/javascript/mastodon/components/alert/index.tsx b/app/javascript/mastodon/components/alert/index.tsx index 72fee0a4a3..8bee99130f 100644 --- a/app/javascript/mastodon/components/alert/index.tsx +++ b/app/javascript/mastodon/components/alert/index.tsx @@ -49,7 +49,11 @@ export const Alert: React.FC<{ {hasAction && ( - )} diff --git a/app/javascript/mastodon/components/button/index.tsx b/app/javascript/mastodon/components/button/index.tsx index f940c07d05..ca2da05b70 100644 --- a/app/javascript/mastodon/components/button/index.tsx +++ b/app/javascript/mastodon/components/button/index.tsx @@ -78,6 +78,7 @@ export const Button: React.FC = ({ aria-live={loading !== undefined ? 'polite' : undefined} onClick={handleClick} title={title} + // eslint-disable-next-line react/button-has-type -- set correctly via TS type={type} {...props} > diff --git a/app/javascript/mastodon/components/column_back_button.tsx b/app/javascript/mastodon/components/column_back_button.tsx index aad355d710..8012ba7df6 100644 --- a/app/javascript/mastodon/components/column_back_button.tsx +++ b/app/javascript/mastodon/components/column_back_button.tsx @@ -30,7 +30,7 @@ export const ColumnBackButton: React.FC<{ onClick?: OnClickCallback }> = ({ const handleClick = useHandleClick(onClick); const component = ( - @@ -193,6 +196,7 @@ export const ColumnHeader: React.FC = ({ aria-label={intl.formatMessage(messages.moveRight)} className='icon-button column-header__setting-btn' onClick={handleMoveRight} + type='button' > @@ -203,6 +207,7 @@ export const ColumnHeader: React.FC = ({ diff --git a/app/javascript/mastodon/components/edited_timestamp/index.tsx b/app/javascript/mastodon/components/edited_timestamp/index.tsx index 63b21cf5bd..2253434667 100644 --- a/app/javascript/mastodon/components/edited_timestamp/index.tsx +++ b/app/javascript/mastodon/components/edited_timestamp/index.tsx @@ -98,7 +98,12 @@ export const EditedTimestamp: React.FC<{ className='dropdown-menu__item edited-timestamp__history__item' key={item.get('created_at') as string} > - @@ -118,7 +123,7 @@ export const EditedTimestamp: React.FC<{ onItemClick={handleItemClick} forceDropdown > - is focused, + When a is focused, Enter should not trigger open, but o should. diff --git a/app/javascript/mastodon/components/learn_more_link.tsx b/app/javascript/mastodon/components/learn_more_link.tsx index b5337794c9..8d22bb7a3b 100644 --- a/app/javascript/mastodon/components/learn_more_link.tsx +++ b/app/javascript/mastodon/components/learn_more_link.tsx @@ -23,6 +23,7 @@ export const LearnMoreLink: React.FC<{ children: React.ReactNode }> = ({ onClick={handleClick} aria-expanded={open} aria-controls={accessibilityId} + type='button' > = ({
{children}
- )} {!showResults && ( <> - {' '} ·{' '} @@ -185,7 +186,11 @@ export const Poll: React.FC = ({ pollId, disabled, status }) => { )} {showResults && !disabled && ( <> - {' '} ·{' '} diff --git a/app/javascript/mastodon/components/status/boost_button.tsx b/app/javascript/mastodon/components/status/boost_button.tsx index cdbe242289..bbb7c031d9 100644 --- a/app/javascript/mastodon/components/status/boost_button.tsx +++ b/app/javascript/mastodon/components/status/boost_button.tsx @@ -232,6 +232,7 @@ const ReblogMenuItem: FC = ({ ref={focusRefCallback} aria-disabled={disabled} data-index={index} + type='button' > diff --git a/app/javascript/mastodon/components/status_quoted.tsx b/app/javascript/mastodon/components/status_quoted.tsx index 647672e054..eac2167294 100644 --- a/app/javascript/mastodon/components/status_quoted.tsx +++ b/app/javascript/mastodon/components/status_quoted.tsx @@ -73,7 +73,7 @@ const LimitedAccountHint: React.FC<{ accountId: string }> = ({ accountId }) => { defaultMessage='This account has been hidden by the moderators of {domain}.' values={{ domain }} /> - @@ -154,6 +155,7 @@ export const DomainPill: React.FC<{ @@ -169,6 +171,7 @@ export const DomainPill: React.FC<{ diff --git a/app/javascript/mastodon/features/alt_text_modal/index.tsx b/app/javascript/mastodon/features/alt_text_modal/index.tsx index f285c35929..c118c1812b 100644 --- a/app/javascript/mastodon/features/alt_text_modal/index.tsx +++ b/app/javascript/mastodon/features/alt_text_modal/index.tsx @@ -489,6 +489,7 @@ export const AltTextModal = forwardRef>( className='link-button' onClick={handleDetectClick} disabled={type !== 'image' || isDetecting} + type='button' > {label} -
@@ -591,6 +595,7 @@ export const Search: React.FC<{ className={classNames('search__popout__menu__item', { selected: selectedOption === i, })} + type='button' > {label} @@ -617,6 +622,7 @@ export const Search: React.FC<{ selectedOption === (quickActions.length || recent.length) + i, })} + type='button' > {label} diff --git a/app/javascript/mastodon/features/home_timeline/components/inline_follow_suggestions.tsx b/app/javascript/mastodon/features/home_timeline/components/inline_follow_suggestions.tsx index 05799ccb82..d297d7cee5 100644 --- a/app/javascript/mastodon/features/home_timeline/components/inline_follow_suggestions.tsx +++ b/app/javascript/mastodon/features/home_timeline/components/inline_follow_suggestions.tsx @@ -270,7 +270,7 @@ export const InlineFollowSuggestions: React.FC<{ hidden?: boolean }> = ({
- diff --git a/app/javascript/mastodon/features/notifications_v2/components/notification_annual_report.tsx b/app/javascript/mastodon/features/notifications_v2/components/notification_annual_report.tsx index 8b92f31add..4541592fbd 100644 --- a/app/javascript/mastodon/features/notifications_v2/components/notification_annual_report.tsx +++ b/app/javascript/mastodon/features/notifications_v2/components/notification_annual_report.tsx @@ -47,7 +47,7 @@ export const NotificationAnnualReport: React.FC<{ values={{ year }} />

- diff --git a/app/javascript/mastodon/features/notifications_v2/index.tsx b/app/javascript/mastodon/features/notifications_v2/index.tsx index 7c73d602fc..3fca9eb44e 100644 --- a/app/javascript/mastodon/features/notifications_v2/index.tsx +++ b/app/javascript/mastodon/features/notifications_v2/index.tsx @@ -245,6 +245,7 @@ export const Notifications: React.FC<{ title={intl.formatMessage(messages.markAsRead)} onClick={handleMarkAsRead} className='column-header__button' + type='button' > diff --git a/app/javascript/mastodon/features/search/components/search_section.tsx b/app/javascript/mastodon/features/search/components/search_section.tsx index ae0c129676..c59d0c2fe4 100644 --- a/app/javascript/mastodon/features/search/components/search_section.tsx +++ b/app/javascript/mastodon/features/search/components/search_section.tsx @@ -9,7 +9,7 @@ export const SearchSection: React.FC<{

{title}

{onClickMore && ( - ); diff --git a/app/javascript/mastodon/features/ui/components/boost_modal.tsx b/app/javascript/mastodon/features/ui/components/boost_modal.tsx index 1963189194..a55141167b 100644 --- a/app/javascript/mastodon/features/ui/components/boost_modal.tsx +++ b/app/javascript/mastodon/features/ui/components/boost_modal.tsx @@ -113,7 +113,7 @@ export const BoostModal: React.FC<{
- diff --git a/app/javascript/mastodon/features/ui/components/domain_block_modal.tsx b/app/javascript/mastodon/features/ui/components/domain_block_modal.tsx index ec08991144..b6c17f9062 100644 --- a/app/javascript/mastodon/features/ui/components/domain_block_modal.tsx +++ b/app/javascript/mastodon/features/ui/components/domain_block_modal.tsx @@ -196,7 +196,7 @@ export const DomainBlockModal: React.FC<{
- @@ -257,6 +258,7 @@ export const MediaModal: FC = forwardRef< className='media-modal__nav media-modal__nav--next' onClick={handleNextClick} aria-label={intl.formatMessage(messages.next)} + type='button' > @@ -354,6 +356,7 @@ const MediaPagination: FC = ({ active: i === index, })} onClick={handleChangeIndex(i)} + type='button' > {i + 1} diff --git a/app/javascript/mastodon/features/ui/components/navigation_bar.tsx b/app/javascript/mastodon/features/ui/components/navigation_bar.tsx index 467e20a572..a542bd1f68 100644 --- a/app/javascript/mastodon/features/ui/components/navigation_bar.tsx +++ b/app/javascript/mastodon/features/ui/components/navigation_bar.tsx @@ -127,7 +127,11 @@ const LoginOrSignUp: React.FC = () => { ); } else { signupButton = ( - diff --git a/app/javascript/mastodon/features/video/index.tsx b/app/javascript/mastodon/features/video/index.tsx index 65f26cedad..aa03e3d2e9 100644 --- a/app/javascript/mastodon/features/video/index.tsx +++ b/app/javascript/mastodon/features/video/index.tsx @@ -875,6 +875,7 @@ export const Video: React.FC<{