Chore: Enable remaining jsx-a11y rules (#70990)

enabling remaining a11y rules + ignore existing violations
This commit is contained in:
Ashley Harrison
2023-06-30 16:58:16 +01:00
committed by GitHub
parent f32f1859a0
commit 7a2a5dde8b
28 changed files with 63 additions and 5 deletions

View File

@@ -74,20 +74,18 @@
}, },
{ {
"extends": ["plugin:jsx-a11y/recommended"], "extends": ["plugin:jsx-a11y/recommended"],
"files": ["**/*"], "files": ["**/*.tsx"],
"excludedFiles": ["**/*.{spec,test}.{ts,tsx}"], "excludedFiles": ["**/*.{spec,test}.tsx"],
"rules": { "rules": {
// rules marked "off" are those left in the recommended preset we need to fix // rules marked "off" are those left in the recommended preset we need to fix
// we should remove the corresponding line and fix them one by one // we should remove the corresponding line and fix them one by one
// any marked "error" contain specific overrides we'll need to keep // any marked "error" contain specific overrides we'll need to keep
"jsx-a11y/click-events-have-key-events": "off",
"jsx-a11y/no-autofocus": [ "jsx-a11y/no-autofocus": [
"error", "error",
{ {
"ignoreNonDOM": true "ignoreNonDOM": true
} }
], ],
"jsx-a11y/no-static-element-interactions": "off",
"jsx-a11y/label-has-associated-control": [ "jsx-a11y/label-has-associated-control": [
"error", "error",
{ {

View File

@@ -81,6 +81,8 @@ class UnthemedSelectOptionGroup extends PureComponent<ExtendedGroupProps, State>
return ( return (
<div> <div>
{/* TODO: fix keyboard a11y */}
{/* eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions */}
<div className={styles.header} onClick={this.onToggleChildren}> <div className={styles.header} onClick={this.onToggleChildren}>
<span className={styles.label}>{label}</span> <span className={styles.label}>{label}</span>
<Icon className={styles.icon} name={expanded ? 'angle-up' : 'angle-down'} />{' '} <Icon className={styles.icon} name={expanded ? 'angle-up' : 'angle-down'} />{' '}

View File

@@ -51,7 +51,7 @@ export const FilterPopup = ({ column: { preFilteredRows, filterValue, setFilter
return ( return (
<ClickOutsideWrapper onClick={onCancel} useCapture={true}> <ClickOutsideWrapper onClick={onCancel} useCapture={true}>
{/* This is just blocking click events from bubbeling and should not have a keyboard interaction. */} {/* This is just blocking click events from bubbeling and should not have a keyboard interaction. */}
{/* eslint-disable-next-line jsx-a11y/no-static-element-interactions */} {/* eslint-disable-next-line jsx-a11y/no-static-element-interactions, jsx-a11y/click-events-have-key-events */}
<div className={cx(styles.filterContainer)} onClick={stopPropagation}> <div className={cx(styles.filterContainer)} onClick={stopPropagation}>
<VerticalGroup spacing="lg"> <VerticalGroup spacing="lg">
<VerticalGroup spacing="xs"> <VerticalGroup spacing="xs">

View File

@@ -66,6 +66,8 @@ class Popover extends PureComponent<Props> {
> >
{({ ref, style, placement, arrowProps, update }) => { {({ ref, style, placement, arrowProps, update }) => {
return ( return (
// TODO: fix keyboard a11y
// eslint-disable-next-line jsx-a11y/no-static-element-interactions
<div <div
onMouseEnter={onMouseEnter} onMouseEnter={onMouseEnter}
onMouseLeave={onMouseLeave} onMouseLeave={onMouseLeave}

View File

@@ -61,6 +61,8 @@ export const LayerDragDropList = <T extends LayerElement>({
rows.push( rows.push(
<Draggable key={uid} draggableId={uid} index={rows.length}> <Draggable key={uid} draggableId={uid} index={rows.length}>
{(provided, snapshot) => ( {(provided, snapshot) => (
// TODO: fix keyboard a11y
// eslint-disable-next-line jsx-a11y/no-static-element-interactions
<div <div
className={getRowStyle(isSelected)} className={getRowStyle(isSelected)}
ref={provided.innerRef} ref={provided.innerRef}

View File

@@ -45,10 +45,14 @@ export const ColorValueEditor = ({ value, settings, onChange, details }: Props)
{details && ( {details && (
<> <>
{value ? ( {value ? (
// TODO: fix keyboard a11y
// eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions
<span className={styles.colorText} onClick={showColorPicker}> <span className={styles.colorText} onClick={showColorPicker}>
{value} {value}
</span> </span>
) : ( ) : (
// TODO: fix keyboard a11y
// eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions
<span className={styles.placeholderText} onClick={showColorPicker}> <span className={styles.placeholderText} onClick={showColorPicker}>
{settings?.placeholder ?? 'Select color'} {settings?.placeholder ?? 'Select color'}
</span> </span>

View File

@@ -81,6 +81,8 @@ export const RoleMenuGroupOption = memo(
return ( return (
<div onMouseEnter={onMouseEnter} onMouseLeave={onMouseLeave}> <div onMouseEnter={onMouseEnter} onMouseLeave={onMouseLeave}>
{/* TODO: fix keyboard a11y */}
{/* eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions */}
<div ref={ref} className={wrapperClassName} aria-label="Role picker option" onClick={onClickInternal}> <div ref={ref} className={wrapperClassName} aria-label="Role picker option" onClick={onClickInternal}>
<Checkbox <Checkbox
value={isSelected} value={isSelected}

View File

@@ -38,6 +38,8 @@ export const RoleMenuOption = React.forwardRef<HTMLDivElement, React.PropsWithCh
}; };
return ( return (
// TODO: fix keyboard a11y
// eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions
<div ref={ref} className={wrapperClassName} aria-label="Role picker option" onClick={onChangeInternal}> <div ref={ref} className={wrapperClassName} aria-label="Role picker option" onClick={onChangeInternal}>
<Checkbox <Checkbox
value={isSelected} value={isSelected}

View File

@@ -52,6 +52,8 @@ export const RolePickerInput = ({
const numberOfRoles = appliedRoles.length; const numberOfRoles = appliedRoles.length;
return !isFocused ? ( return !isFocused ? (
// TODO: fix keyboard a11y
// eslint-disable-next-line jsx-a11y/no-static-element-interactions
<div className={cx(styles.wrapper, styles.selectedRoles)} onMouseDown={onOpen}> <div className={cx(styles.wrapper, styles.selectedRoles)} onMouseDown={onOpen}>
{showBasicRole && <ValueContainer>{basicRole}</ValueContainer>} {showBasicRole && <ValueContainer>{basicRole}</ValueContainer>}
<RolesLabel appliedRoles={appliedRoles} numberOfRoles={numberOfRoles} showBuiltInRole={showBasicRole} /> <RolesLabel appliedRoles={appliedRoles} numberOfRoles={numberOfRoles} showBuiltInRole={showBasicRole} />

View File

@@ -53,6 +53,8 @@ function NotificationRouteHeader({
/> />
<Stack flexGrow={1} gap={1}> <Stack flexGrow={1} gap={1}>
{/* TODO: fix keyboard a11y */}
{/* eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions */}
<div onClick={() => onExpandRouteClick(!expandRoute)} className={styles.expandable}> <div onClick={() => onExpandRouteClick(!expandRoute)} className={styles.expandable}>
<Stack gap={1} direction="row" alignItems="center"> <Stack gap={1} direction="row" alignItems="center">
Notification policy Notification policy

View File

@@ -16,6 +16,8 @@ export const settingsViewable = (scene: Scene) => ({
const rect = moveable.getRect(); const rect = moveable.getRect();
return ( return (
// TODO: fix keyboard a11y
// eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions
<div <div
key={'settings-viewable'} key={'settings-viewable'}
className={'moveable-settings'} className={'moveable-settings'}

View File

@@ -499,6 +499,8 @@ export class ElementState implements LayerElement {
const isSelected = div && scene && scene.selecto && scene.selecto.getSelectedTargets().includes(div); const isSelected = div && scene && scene.selecto && scene.selecto.getSelectedTargets().includes(div);
return ( return (
// TODO: fix keyboard a11y
// eslint-disable-next-line jsx-a11y/click-events-have-key-events
<div <div
key={this.UID} key={this.UID}
ref={this.initElement} ref={this.initElement}

View File

@@ -14,6 +14,8 @@ export const PanelHeaderLoadingIndicator = ({ state, onClick }: Props) => {
if (state === LoadingState.Loading) { if (state === LoadingState.Loading) {
return ( return (
// TODO: fix keyboard a11y
// eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions
<div className="panel-loading" onClick={onClick}> <div className="panel-loading" onClick={onClick}>
<Tooltip content="Cancel query"> <Tooltip content="Cancel query">
<Icon className="panel-loading__spinner spin-clockwise" name="sync" /> <Icon className="panel-loading__spinner spin-clockwise" name="sync" />
@@ -24,6 +26,8 @@ export const PanelHeaderLoadingIndicator = ({ state, onClick }: Props) => {
if (state === LoadingState.Streaming) { if (state === LoadingState.Streaming) {
return ( return (
// TODO: fix keyboard a11y
// eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions
<div className="panel-loading" onClick={onClick}> <div className="panel-loading" onClick={onClick}>
<div title="Streaming (click to stop)" className={styles.streamIndicator} /> <div title="Streaming (click to stop)" className={styles.streamIndicator} />
</div> </div>

View File

@@ -35,6 +35,8 @@ export function PanelHeaderMenuTrigger({ children, onOpenMenu, ...divProps }: Pr
}, []); }, []);
return ( return (
// TODO: fix keyboard a11y
// eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions
<header {...divProps} className="panel-title-container" onClick={onMenuToggle} onMouseDown={onMouseDown}> <header {...divProps} className="panel-title-container" onClick={onMenuToggle} onMouseDown={onMouseDown}>
{children({ panelMenuOpen, closeMenu: () => setPanelMenuOpen(false) })} {children({ panelMenuOpen, closeMenu: () => setPanelMenuOpen(false) })}
</header> </header>

View File

@@ -183,6 +183,8 @@ export function DataSourceDropdown(props: DataSourceDropdownProps) {
{isOpen ? ( {isOpen ? (
<Portal> <Portal>
<div {...underlayProps} /> <div {...underlayProps} />
{/* TODO: fix keyboard a11y */}
{/* eslint-disable-next-line jsx-a11y/no-static-element-interactions */}
<div <div
ref={ref} ref={ref}
{...overlayProps} {...overlayProps}

View File

@@ -32,6 +32,8 @@ const MemoizedCell = memo(function Cell(props: CellProps) {
return ( return (
<div style={style}> <div style={style}>
{card && ( {card && (
// TODO: fix keyboard a11y
// eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions
<div <div
key={card.value} key={card.value}
className={selected === card.value ? cx(styles.card, styles.selected) : styles.card} className={selected === card.value ? cx(styles.card, styles.selected) : styles.card}

View File

@@ -96,6 +96,8 @@ export const ResourcePicker = (props: Props) => {
/> />
)} )}
{/* TODO: fix keyboard a11y */}
{/* eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions */}
<div ref={pickerTriggerRef} onClick={showPopper} className={styles.pointer}> <div ref={pickerTriggerRef} onClick={showPopper} className={styles.pointer}>
{size === ResourcePickerSize.SMALL && renderSmallResourcePicker()} {size === ResourcePickerSize.SMALL && renderSmallResourcePicker()}
{size === ResourcePickerSize.NORMAL && renderNormalResourcePicker()} {size === ResourcePickerSize.NORMAL && renderNormalResourcePicker()}

View File

@@ -147,6 +147,8 @@ export default memo(function NewTracePageSearchBar(props: TracePageSearchBarProp
onChange={(value) => setShowSpanFilterMatchesOnly(value.currentTarget.checked ?? false)} onChange={(value) => setShowSpanFilterMatchesOnly(value.currentTarget.checked ?? false)}
label="Show matches only switch" label="Show matches only switch"
/> />
{/* TODO: fix keyboard a11y */}
{/* eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions */}
<span onClick={() => setShowSpanFilterMatchesOnly(!showSpanFilterMatchesOnly)}>Show matches only</span> <span onClick={() => setShowSpanFilterMatchesOnly(!showSpanFilterMatchesOnly)}>Show matches only</span>
</div> </div>
</div> </div>

View File

@@ -383,6 +383,8 @@ export default function SpanDetail(props: SpanDetailProps) {
)} )}
{topOfViewRefType === TopOfViewRefType.Explore && ( {topOfViewRefType === TopOfViewRefType.Explore && (
<small className={styles.debugInfo}> <small className={styles.debugInfo}>
{/* TODO: fix keyboard a11y */}
{/* eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions */}
<a <a
{...focusSpanLink} {...focusSpanLink}
onClick={(e) => { onClick={(e) => {

View File

@@ -115,6 +115,8 @@ export class LogRowMessage extends PureComponent<Props> {
</td> </td>
<td className={cx('log-row-menu-cell', styles.logRowMenuCell)}> <td className={cx('log-row-menu-cell', styles.logRowMenuCell)}>
{pinned && ( {pinned && (
// TODO: fix keyboard a11y
// eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions
<span className={cx('log-row-menu', 'log-row-menu-visible', styles.rowMenu)} onClick={this.onLogRowClick}> <span className={cx('log-row-menu', 'log-row-menu-visible', styles.rowMenu)} onClick={this.onLogRowClick}>
<IconButton <IconButton
className={styles.unPinButton} className={styles.unPinButton}
@@ -127,6 +129,8 @@ export class LogRowMessage extends PureComponent<Props> {
/> />
</span> </span>
)} )}
{/* TODO: fix keyboard a11y */}
{/* eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions */}
<span className={cx('log-row-menu', styles.rowMenu, styles.hidden)} onClick={this.onLogRowClick}> <span className={cx('log-row-menu', styles.rowMenu, styles.hidden)} onClick={this.onLogRowClick}>
{shouldShowContextToggle && ( {shouldShowContextToggle && (
<IconButton <IconButton

View File

@@ -37,6 +37,8 @@ export const PanelTypeCard = ({
}); });
return ( return (
// TODO: fix keyboard a11y
// eslint-disable-next-line jsx-a11y/click-events-have-key-events
<div <div
className={cssClass} className={cssClass}
aria-label={selectors.components.PluginVisualization.item(plugin.name)} aria-label={selectors.components.PluginVisualization.item(plugin.name)}

View File

@@ -146,6 +146,8 @@ export const FolderSection = ({
label={ label={
<> <>
{selectionToggle && selection && ( {selectionToggle && selection && (
// TODO: fix keyboard a11y
// eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions
<div onClick={onToggleFolder}> <div onClick={onToggleFolder}>
<Checkbox <Checkbox
className={styles.checkbox} className={styles.checkbox}

View File

@@ -246,6 +246,8 @@ export const generateColumns = (
Header: () => <div className={styles.sortedHeader}>Score</div>, Header: () => <div className={styles.sortedHeader}>Score</div>,
Cell: (p) => { Cell: (p) => {
return ( return (
// TODO: fix keyboard a11y
// eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions
<div <div
{...p.cellProps} {...p.cellProps}
className={cx(styles.cell, styles.explainItem)} className={cx(styles.cell, styles.explainItem)}
@@ -298,6 +300,8 @@ function makeDataSourceColumn(
const icon = settings?.meta?.info?.logos?.small; const icon = settings?.meta?.info?.logos?.small;
if (icon) { if (icon) {
return ( return (
// TODO: fix keyboard a11y
// eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions
<span <span
key={i} key={i}
onClick={(e) => { onClick={(e) => {

View File

@@ -27,6 +27,8 @@ export function Breadcrumb({ pathName, onPathChange, rootIcon }: Props) {
const onClickBreadcrumb = () => onPathChange(url); const onClickBreadcrumb = () => onPathChange(url);
const isLastBreadcrumb = index === paths.length - 1; const isLastBreadcrumb = index === paths.length - 1;
return ( return (
// TODO: fix keyboard a11y
// eslint-disable-next-line jsx-a11y/click-events-have-key-events
<li key={uniqueId(path)} onClick={isLastBreadcrumb ? undefined : onClickBreadcrumb}> <li key={uniqueId(path)} onClick={isLastBreadcrumb ? undefined : onClickBreadcrumb}>
{path} {path}
</li> </li>

View File

@@ -155,6 +155,8 @@ const Option = (props: React.PropsWithChildren<OptionProps>) => {
}; };
return ( return (
// TODO: fix keyboard a11y
// eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions
<div <div
ref={innerRef} ref={innerRef}
className={cx( className={cx(

View File

@@ -163,6 +163,8 @@ export function MetricSelect({
const isFocused = props.isFocused ? styles.focus : ''; const isFocused = props.isFocused ? styles.focus : '';
return ( return (
// TODO: fix keyboard a11y
// eslint-disable-next-line jsx-a11y/no-static-element-interactions
<div <div
{...props.innerProps} {...props.innerProps}
ref={props.innerRef} ref={props.innerRef}

View File

@@ -204,6 +204,8 @@ export const ExemplarMarker = ({
return ( return (
<> <>
{/* TODO: fix keyboard a11y */}
{/* eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions */}
<div <div
ref={setMarkerElement} ref={setMarkerElement}
onClick={() => { onClick={() => {

View File

@@ -66,6 +66,8 @@ export const ManualEditor = ({
<div className={style.marginBot}> <div className={style.marginBot}>
{value.map((series, index) => { {value.map((series, index) => {
return ( return (
// TODO: fix keyboard a11y
// eslint-disable-next-line jsx-a11y/no-static-element-interactions
<div key={`series/${index}`} className={getRowStyle(index)} onMouseDown={() => setSelected(index)}> <div key={`series/${index}`} className={getRowStyle(index)} onMouseDown={() => setSelected(index)}>
<LayerName <LayerName
name={series.name ?? `Series ${index + 1}`} name={series.name ?? `Series ${index + 1}`}