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

chore: Add eslint-plugin-jsx-a11y plugin #1348

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
1 change: 1 addition & 0 deletions packages/eslint-config-alt/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
"eslint-config-prettier": "~8.8.0",
"eslint-import-resolver-typescript": "~3.5.5",
"eslint-plugin-import": "~2.26.0",
"eslint-plugin-jsx-a11y": "~6.8.0",
"eslint-plugin-prettier": "~4.2.1",
"eslint-plugin-react": "~7.32.2",
"eslint-plugin-react-hooks": "~4.6.0"
Expand Down
4 changes: 2 additions & 2 deletions packages/eslint-config-alt/react/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/** @type {import('eslint').Linter.Config} */
module.exports = {
extends: '../minimal',
plugins: ['react', 'react-hooks'],
plugins: ['react', 'react-hooks', 'jsx-a11y'],
extends: ['../minimal', 'plugin:jsx-a11y/recommended'],
parser: '@babel/eslint-parser',
rules: {
'jsx-quotes': ['error', 'prefer-single'],
Expand Down
35 changes: 19 additions & 16 deletions packages/fuselage/src/components/AudioPlayer/AudioPlayer.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { useMergedRefs, useResizeObserver } from '@rocket.chat/fuselage-hooks';
import type { TrackHTMLAttributes } from 'react';
import React, { useState, useRef, forwardRef } from 'react';

import { Box, Button, IconButton, Margins } from '../..';
Expand Down Expand Up @@ -54,22 +55,22 @@ const getDurationForInfinityDurationAudioFile = (
});
};

export const AudioPlayer = forwardRef<
HTMLAudioElement,
{
src: string;
type?: string;
maxPlaybackSpeed?: number;
minPlaybackSpeed?: number;
playbackSpeedStep?: number;
download?: boolean;
playLabel?: string;
pauseLabel?: string;
audioPlaybackRangeLabel?: string;
changePlaybackSpeedLabel?: string;
downloadAudioFileLabel?: string;
}
>(
type AudioPlayerProps = {
src: string;
type?: string;
maxPlaybackSpeed?: number;
minPlaybackSpeed?: number;
playbackSpeedStep?: number;
download?: boolean;
playLabel?: string;
pauseLabel?: string;
audioPlaybackRangeLabel?: string;
changePlaybackSpeedLabel?: string;
downloadAudioFileLabel?: string;
trackProps?: TrackHTMLAttributes<HTMLTrackElement>;
};

export const AudioPlayer = forwardRef<HTMLAudioElement, AudioPlayerProps>(
(
{
src,
Expand All @@ -83,6 +84,7 @@ export const AudioPlayer = forwardRef<
audioPlaybackRangeLabel = 'Audio Playback Range',
changePlaybackSpeedLabel = 'Change Playback Speed',
downloadAudioFileLabel = 'Download Audio File',
trackProps,
},
ref
) => {
Expand Down Expand Up @@ -219,6 +221,7 @@ export const AudioPlayer = forwardRef<
controls
>
<source src={src} type={type} />
<track kind='captions' {...trackProps} />
</audio>
</Box>
);
Expand Down
3 changes: 2 additions & 1 deletion packages/fuselage/src/components/Avatar/Avatar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export const Avatar = ({
objectFit = false,
url,
className,
alt,
...props
}: AvatarProps) => {
const innerClass = [
Expand All @@ -29,7 +30,7 @@ export const Avatar = ({

return (
<AvatarContainer size={size} className={className}>
<img src={`${url}`} className={`${innerClass}`} {...props} />
<img src={url} className={innerClass} alt={alt || ''} {...props} />
</AvatarContainer>
);
};
Expand Down
10 changes: 7 additions & 3 deletions packages/fuselage/src/components/Banner/Banner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,17 @@ const Banner = ({
);

return (
<section
<div
className={cx('rcx-banner')(
{ [variant]: true, inline, actionable },
className
)}
ref={ref}
role='banner'
role={onAction ? 'button' : 'banner'}
tabIndex={onAction ? 0 : -1}
onKeyDown={(e) =>
e.code === 'Enter' || (e.code === 'Space' && handleBannerClick())
}
onClick={handleBannerClick}
{...props}
>
Expand Down Expand Up @@ -115,7 +119,7 @@ const Banner = ({
<IconButton small onClick={handleCloseButtonClick} icon='cross' />
</div>
)}
</section>
</div>
);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ i.storyName = 'i';
export const a: ComponentStory<typeof Box> = () => (
<>
<div>
<a href='#'>Normal</a>
<a href='#any'>Normal</a>
</div>
<br />
<div>
<a href='#' className='is-focused'>
<a href='#any' className='is-focused'>
Focused
</a>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,28 @@
import type { AnchorHTMLAttributes, HTMLAttributes, ReactNode } from 'react';
import type { AnchorHTMLAttributes, HTMLAttributes } from 'react';
import React from 'react';

type MessageGenericPreviewTitleProps = {
children?: ReactNode;
externalUrl?: string;
} & HTMLAttributes<HTMLSpanElement> &
AnchorHTMLAttributes<HTMLAnchorElement>;

export const MessageGenericPreviewTitle = ({
externalUrl,
children,
...props
}: MessageGenericPreviewTitleProps) =>
externalUrl ? (
<span>
}: MessageGenericPreviewTitleProps) => {
if (externalUrl) {
return (
<a
className='rcx-message-generic-preview__title rcx-message-generic-preview__title-link'
href={externalUrl}
target='_blank'
{...props}
/>
</span>
) : (
<span className='rcx-message-generic-preview__title' {...props} />
);
>
{children}
</a>
);
}

return <span className='rcx-message-generic-preview__title' {...props} />;
};
3 changes: 3 additions & 0 deletions packages/fuselage/src/components/Sidebar/SidebarBanner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,16 @@ export const SidebarBanner = ({
{text && <div className='rcx-sidebar-banner--text'>{text}</div>}
{description && (
<div
role='link'
tabIndex={0}
className={[
'rcx-sidebar-banner--description',
onClick && 'rcx-sidebar-banner--description--clickable',
]
.filter(Boolean)
.join(' ')}
onClick={onClick}
onKeyDown={(e) => e.key === 'Enter' && onClick?.()}
>
{description}
</div>
Expand Down
Loading
Loading