From 44a3dc94f38e8056200155ea19bfd19904d8cba2 Mon Sep 17 00:00:00 2001 From: Josh Black Date: Wed, 18 Sep 2024 11:33:42 -0500 Subject: [PATCH] fix(UnderlinePanels): add explicit type="button" to UnderlinePanels (#4970) * refactor(eslint): enable react/button-has-type rule * fix(UnderlinePanels): add explicit type="button" to UnderlinePanels * chore: add changeset * chore: fix eslint violation --------- Co-authored-by: Josh Black --- .changeset/selfish-carpets-breathe.md | 5 ++ .eslintrc.js | 1 + .../ActionList.features.stories.tsx | 6 ++- .../react/src/ActionList/ActionList.test.tsx | 4 +- .../src/TooltipV2/__tests__/Tooltip.test.tsx | 2 +- packages/react/src/TreeView/TreeView.test.tsx | 12 +++-- .../src/UnderlineNav/UnderlineNav.test.tsx | 2 +- packages/react/src/__tests__/Dialog.test.tsx | 4 +- .../__tests__/TextInputWithTokens.test.tsx | 8 ++- .../src/__tests__/ThemeProvider.test.tsx | 54 +++++++++++++++---- .../hooks/useMenuInitialFocus.test.tsx | 8 +-- .../src/__tests__/hooks/useMnemonics.test.tsx | 22 +++++--- .../hooks/useOnOutsideClick.test.tsx | 8 ++- .../hooks/useOpenAndCloseFocus.test.tsx | 18 ++++--- .../UnderlinePanels/UnderlinePanels.tsx | 1 + 15 files changed, 113 insertions(+), 42 deletions(-) create mode 100644 .changeset/selfish-carpets-breathe.md diff --git a/.changeset/selfish-carpets-breathe.md b/.changeset/selfish-carpets-breathe.md new file mode 100644 index 00000000000..b7e33098ea3 --- /dev/null +++ b/.changeset/selfish-carpets-breathe.md @@ -0,0 +1,5 @@ +--- +'@primer/react': patch +--- + +Update tab in UnderlinePanels to set explicit type diff --git a/.eslintrc.js b/.eslintrc.js index ad4b613cd44..b61b249e1dd 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -61,6 +61,7 @@ module.exports = { // rules which apply to JS, TS, etc. rules: { 'no-shadow': 'off', + 'react/button-has-type': 'error', 'react/prop-types': 'off', 'react/display-name': 'off', 'react-hooks/exhaustive-deps': 'error', diff --git a/packages/react/src/ActionList/ActionList.features.stories.tsx b/packages/react/src/ActionList/ActionList.features.stories.tsx index e2beee85f9e..c7e6c6be821 100644 --- a/packages/react/src/ActionList/ActionList.features.stories.tsx +++ b/packages/react/src/ActionList/ActionList.features.stories.tsx @@ -637,7 +637,11 @@ export const InsideOverlay = () => { open={open} onOpen={toggle} onClose={toggle} - renderAnchor={props => } + renderAnchor={props => ( + + )} > diff --git a/packages/react/src/ActionList/ActionList.test.tsx b/packages/react/src/ActionList/ActionList.test.tsx index 04a51881d26..fb847677cdc 100644 --- a/packages/react/src/ActionList/ActionList.test.tsx +++ b/packages/react/src/ActionList/ActionList.test.tsx @@ -465,7 +465,9 @@ describe('ActionList', () => { return ( - + Item 1 Item 2 diff --git a/packages/react/src/TooltipV2/__tests__/Tooltip.test.tsx b/packages/react/src/TooltipV2/__tests__/Tooltip.test.tsx index 3a237603182..0bf8c8b3149 100644 --- a/packages/react/src/TooltipV2/__tests__/Tooltip.test.tsx +++ b/packages/react/src/TooltipV2/__tests__/Tooltip.test.tsx @@ -128,7 +128,7 @@ describe('Tooltip', () => {
Legend - +
, ) diff --git a/packages/react/src/TreeView/TreeView.test.tsx b/packages/react/src/TreeView/TreeView.test.tsx index 3dc535270fa..74fd658ed85 100644 --- a/packages/react/src/TreeView/TreeView.test.tsx +++ b/packages/react/src/TreeView/TreeView.test.tsx @@ -249,7 +249,7 @@ describe('Markup', () => { const user = userEvent.setup({delay: null}) const {getByRole} = renderWithTheme(
- + Item 1 @@ -277,7 +277,7 @@ describe('Markup', () => { const user = userEvent.setup({delay: null}) const {getByRole} = renderWithTheme(
- + Item 1 @@ -318,13 +318,13 @@ describe('Markup', () => { Item 1 Item 2 - Item 3 - +
, ) @@ -1359,7 +1359,9 @@ describe('Asyncronous loading', () => { return (
{/* Mimic the completion of async loading by clicking the button */} - + Parent diff --git a/packages/react/src/UnderlineNav/UnderlineNav.test.tsx b/packages/react/src/UnderlineNav/UnderlineNav.test.tsx index bd1551a3922..5d7793390a3 100644 --- a/packages/react/src/UnderlineNav/UnderlineNav.test.tsx +++ b/packages/react/src/UnderlineNav/UnderlineNav.test.tsx @@ -67,7 +67,7 @@ const ResponsiveUnderlineNav = ({ ))} - {displayExtraEl && } + {displayExtraEl && }
) } diff --git a/packages/react/src/__tests__/Dialog.test.tsx b/packages/react/src/__tests__/Dialog.test.tsx index 281f4c5d641..0fed5ca5172 100644 --- a/packages/react/src/__tests__/Dialog.test.tsx +++ b/packages/react/src/__tests__/Dialog.test.tsx @@ -61,7 +61,7 @@ const DialogWithCustomFocusRef = () => { Title Some content - @@ -90,7 +90,7 @@ const DialogWithCustomFocusRefAndReturnFocusRef = () => { Title Some content - diff --git a/packages/react/src/__tests__/TextInputWithTokens.test.tsx b/packages/react/src/__tests__/TextInputWithTokens.test.tsx index d70ec90d97d..10a21222184 100644 --- a/packages/react/src/__tests__/TextInputWithTokens.test.tsx +++ b/packages/react/src/__tests__/TextInputWithTokens.test.tsx @@ -317,7 +317,9 @@ describe('TextInputWithTokens', () => { onTokenRemove={onRemoveMock} visibleTokenCount={visibleTokenCount} /> - + , ) const inputNode = getByLabelText('Tokens') @@ -373,7 +375,9 @@ describe('TextInputWithTokens', () => { onTokenRemove={onRemoveMock} visibleTokenCount={visibleTokenCount} /> - + , ) const inputNode = getByLabelText('Tokens') diff --git a/packages/react/src/__tests__/ThemeProvider.test.tsx b/packages/react/src/__tests__/ThemeProvider.test.tsx index c94e6d3fd72..66d79d2590c 100644 --- a/packages/react/src/__tests__/ThemeProvider.test.tsx +++ b/packages/react/src/__tests__/ThemeProvider.test.tsx @@ -203,7 +203,9 @@ it('updates when colorMode prop changes', async () => { return ( {colorMode} - + ) } @@ -229,7 +231,9 @@ it('updates when dayScheme prop changes', async () => { return ( {dayScheme} - + ) } @@ -255,7 +259,9 @@ it('updates when nightScheme prop changes', async () => { return ( {nightScheme} - + ) } @@ -280,7 +286,9 @@ it('inherits colorMode from parent', async () => { const [colorMode, setcolorMode] = React.useState<'day' | 'night'>('day') return ( - + {colorMode} @@ -304,7 +312,9 @@ it('inherits dayScheme from parent', async () => { const [dayScheme, setDayScheme] = React.useState('light') return ( - + {dayScheme} @@ -328,7 +338,9 @@ it('inherits nightScheme from parent', async () => { const [nightScheme, setNightScheme] = React.useState('dark') return ( - + {nightScheme} @@ -351,7 +363,11 @@ describe('setColorMode', () => { function ToggleMode() { const {colorMode, setColorMode} = useTheme() - return + return ( + + ) } render( @@ -377,7 +393,11 @@ describe('setDayScheme', () => { function ToggleDayScheme() { const {dayScheme, setDayScheme} = useTheme() - return + return ( + + ) } render( @@ -403,7 +423,11 @@ describe('setNightScheme', () => { function ToggleNightScheme() { const {nightScheme, setNightScheme} = useTheme() - return + return ( + + ) } render( @@ -429,7 +453,11 @@ describe('useColorSchemeVar', () => { function ToggleMode() { const {colorMode, setColorMode} = useTheme() - return + return ( + + ) } function CustomBg() { @@ -464,7 +492,11 @@ describe('useColorSchemeVar', () => { function ToggleMode() { const {colorMode, setColorMode} = useTheme() - return + return ( + + ) } function CustomBg() { diff --git a/packages/react/src/__tests__/hooks/useMenuInitialFocus.test.tsx b/packages/react/src/__tests__/hooks/useMenuInitialFocus.test.tsx index e5d5dc65ce7..7519ca1a1d5 100644 --- a/packages/react/src/__tests__/hooks/useMenuInitialFocus.test.tsx +++ b/packages/react/src/__tests__/hooks/useMenuInitialFocus.test.tsx @@ -12,15 +12,15 @@ const Component = () => { return ( <> - {open && (
not focusable - - - + + + not focusable
)} diff --git a/packages/react/src/__tests__/hooks/useMnemonics.test.tsx b/packages/react/src/__tests__/hooks/useMnemonics.test.tsx index 6b2949c7404..2070db57621 100644 --- a/packages/react/src/__tests__/hooks/useMnemonics.test.tsx +++ b/packages/react/src/__tests__/hooks/useMnemonics.test.tsx @@ -21,12 +21,22 @@ const Fixture = ({
{hasInput && } {hasTextarea &&