From 717e72030e079e5c5fdec8feeb517de830c94924 Mon Sep 17 00:00:00 2001 From: "Mr.Dr.Professor Patrick" Date: Thu, 1 Jun 2023 14:27:56 +0200 Subject: [PATCH] chore: add eslint a11y rules (#700) --- .eslintrc | 7 ++++++- .../ArrowToggle/__stories__/ArrowToggle.stories.tsx | 1 + src/components/Card/Card.tsx | 1 + src/components/DropdownMenu/DropdownMenu.tsx | 1 + src/components/Label/Label.tsx | 1 + src/components/Link/Link.tsx | 2 ++ src/components/List/List.tsx | 2 ++ src/components/List/components/ListItem.tsx | 1 + src/components/PersonaWrap/PersonaWrap.tsx | 2 ++ src/components/Popover/components/Trigger/Trigger.tsx | 1 + src/components/Popup/Popup.tsx | 1 + src/components/Popup/__stories__/Popup.stories.tsx | 2 ++ src/components/Sheet/SheetContent.tsx | 1 + src/components/StoreBadge/StoreBadge.tsx | 1 + .../components/StoriesPreview/StoriesPreview.tsx | 3 +++ .../TableColumnSetup/TableColumnSetup.tsx | 1 + .../Table/hoc/withTableSorting/withTableSorting.tsx | 1 + src/components/Tabs/__stories__/Tabs.stories.tsx | 1 + .../TextInput/AdditionalContent/AdditionalContent.tsx | 1 + src/components/TextInput/InputControl/InputControl.tsx | 1 + .../TextInput/TextAreaControl/TextAreaControl.tsx | 1 + src/components/UserAvatar/UserAvatar.tsx | 1 + src/components/utils/__tests__/xpath.test.tsx | 2 ++ src/demo/colors/ColorPanel.tsx | 1 + 24 files changed, 36 insertions(+), 1 deletion(-) diff --git a/.eslintrc b/.eslintrc index 22a614c5e8..00c5a8ed9d 100644 --- a/.eslintrc +++ b/.eslintrc @@ -1,5 +1,10 @@ { - "extends": ["@gravity-ui/eslint-config", "@gravity-ui/eslint-config/client", "@gravity-ui/eslint-config/prettier"], + "extends": [ + "@gravity-ui/eslint-config", + "@gravity-ui/eslint-config/client", + "@gravity-ui/eslint-config/prettier", + "@gravity-ui/eslint-config/a11y" + ], "root": true, "rules": { "react/jsx-fragments": ["error", "element"], diff --git a/src/components/ArrowToggle/__stories__/ArrowToggle.stories.tsx b/src/components/ArrowToggle/__stories__/ArrowToggle.stories.tsx index 8075864df4..3512a173d7 100644 --- a/src/components/ArrowToggle/__stories__/ArrowToggle.stories.tsx +++ b/src/components/ArrowToggle/__stories__/ArrowToggle.stories.tsx @@ -47,6 +47,7 @@ export const Interactive: Story = (args) => { const direction = directions[directionIndex % directions.length]; return ( + // eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions setDirectionIndex(directionIndex + 1)} style={{cursor: 'pointer'}}>

{direction}

diff --git a/src/components/Card/Card.tsx b/src/components/Card/Card.tsx index 9aea522d63..d11011ad44 100644 --- a/src/components/Card/Card.tsx +++ b/src/components/Card/Card.tsx @@ -59,6 +59,7 @@ export const Card = React.forwardRef(function Card(pr const defaultView = isTypeContainer || isTypeSelection ? 'outlined' : undefined; return ( + // eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions
({ return ( + {/* eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions */}
(function Label } return ( + // eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions
(function Link( const relProp = target === '_blank' && !rel ? 'noopener noreferrer' : rel; return ( + // eslint-disable-next-line jsx-a11y/anchor-has-content )} {...commonProps} @@ -85,6 +86,7 @@ export const Link = React.forwardRef(function Link( {...(extraProps as React.HTMLAttributes)} {...commonProps} ref={ref as React.Ref} + // eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex tabIndex={0} /> ); diff --git a/src/components/List/List.tsx b/src/components/List/List.tsx index 5583af9926..cf2b699e59 100644 --- a/src/components/List/List.tsx +++ b/src/components/List/List.tsx @@ -107,6 +107,7 @@ export class List extends React.Component, ListState {({mobile}) => ( + // eslint-disable-next-line jsx-a11y/no-static-element-interactions
extends React.Component, ListState
diff --git a/src/components/List/components/ListItem.tsx b/src/components/List/components/ListItem.tsx index 6ac2b44321..d6bba3e45a 100644 --- a/src/components/List/components/ListItem.tsx +++ b/src/components/List/components/ListItem.tsx @@ -21,6 +21,7 @@ export class ListItem extends React.Component> { this.props; return ( + // eslint-disable-next-line jsx-a11y/click-events-have-key-events
+ {/* eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions */}
{avatar &&
{avatar}
}
{children}
{onClose && ( + // eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions
diff --git a/src/components/Popover/components/Trigger/Trigger.tsx b/src/components/Popover/components/Trigger/Trigger.tsx index 01ad3e4773..d9e521bd64 100644 --- a/src/components/Popover/components/Trigger/Trigger.tsx +++ b/src/components/Popover/components/Trigger/Trigger.tsx @@ -66,5 +66,6 @@ export const Trigger = ({ toggleTooltip(); }; + // eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions return {children}; }; diff --git a/src/components/Popup/Popup.tsx b/src/components/Popup/Popup.tsx index 831ff7cf78..dbb1f101ce 100644 --- a/src/components/Popup/Popup.tsx +++ b/src/components/Popup/Popup.tsx @@ -130,6 +130,7 @@ export function Popup({ {...containerProps} className={bWrapper({open})} > + {/* eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions */}
= (args) => { const anchorRef = useVirtualElementRef({rect: {top, left}}); return (
+ {/* eslint-disable-next-line jsx-a11y/label-has-associated-control */} + {/* eslint-disable-next-line jsx-a11y/label-has-associated-control */}
; } diff --git a/src/components/StoriesGroup/components/StoriesPreview/StoriesPreview.tsx b/src/components/StoriesGroup/components/StoriesPreview/StoriesPreview.tsx index 9e6f864d67..fd61d07733 100644 --- a/src/components/StoriesGroup/components/StoriesPreview/StoriesPreview.tsx +++ b/src/components/StoriesGroup/components/StoriesPreview/StoriesPreview.tsx @@ -38,6 +38,7 @@ const PreviewItem = ({active, disabled, groupIndex, media, onSelectGroup}: Previ ); return ( + // eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions
{ return (
+ {/* eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions */}
{switcher || (