Skip to content

Commit c30ba41

Browse files
authored
Merge pull request github#7188 from github/kh-enable_jsx_a11y_linter
Enable jsx-a11y linter and linting
2 parents fdbbb98 + f4e6c3e commit c30ba41

22 files changed

+933
-90
lines changed

.eslintrc.js

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ module.exports = {
88
parser: '@babel/eslint-parser',
99
extends: [
1010
'eslint:recommended',
11-
'standard'
11+
'standard',
12+
'prettier'
1213
],
1314
parserOptions: {
1415
ecmaVersion: 11
@@ -24,6 +25,24 @@ module.exports = {
2425
env: {
2526
jest: true
2627
}
27-
}
28+
},
29+
{
30+
files: [
31+
'**/*.tsx', '**/*.ts'
32+
],
33+
plugins: [
34+
'@typescript-eslint',
35+
'jsx-a11y'
36+
],
37+
extends: ['plugin:jsx-a11y/recommended'],
38+
parser: '@typescript-eslint/parser',
39+
rules: {
40+
'camelcase': 'off',
41+
'no-unused-vars': 'off',
42+
'no-undef': 'off',
43+
'no-use-before-define': 'off',
44+
'@typescript-eslint/no-unused-vars': ['error'],
45+
}
46+
},
2847
]
2948
}

components/Breadcrumbs.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ export type BreadcrumbT = {
99
href?: string
1010
}
1111

12-
type Props = {}
13-
export const Breadcrumbs = (props: Props) => {
12+
export const Breadcrumbs = () => {
1413
const router = useRouter()
1514
const pathWithLocale = `/${router.locale}${router.asPath.split('?')[0]}` // remove query string
1615
const { breadcrumbs } = useMainContext()

components/Contribution.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ export const Contribution = () => {
66
const { relativePath } = useMainContext()
77
const { t } = useTranslation('contribution_cta')
88

9-
const contribution_href = relativePath
9+
const contributionHref = relativePath
1010
? `https://github.com/github/docs/edit/main/content/${relativePath}`
1111
: 'https://github.com/github/docs'
1212

1313
return (
1414
<div className="f5 contribution">
1515
<h2 className="f4">{t`title`}</h2>
1616
<p className="color-text-secondary f6">{t`body`}</p>
17-
<a className="btn btn-outline" href={contribution_href}>
17+
<a className="btn btn-outline" href={contributionHref}>
1818
<GitPullRequestIcon size="small" className="octicon mr-1" />
1919
{t`button`}
2020
</a>

components/Link.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,14 @@ export function Link(props: Props) {
3030
if (enableNextLinks) {
3131
return (
3232
<NextLink href={href || ''} locale={locale}>
33+
{/* eslint-disable-next-line jsx-a11y/anchor-has-content */}
3334
<a rel={isExternal ? 'noopener' : ''} {...restProps} />
3435
</NextLink>
3536
)
3637
}
3738

3839
return (
40+
/* eslint-disable-next-line jsx-a11y/anchor-has-content */
3941
<a
4042
href={locale ? `/${locale}${href}` : href}
4143
rel={isExternal ? 'noopener' : ''}

components/ProductPicker.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import { useRouter } from 'next/router'
2-
import { LinkExternalIcon } from '@primer/octicons-react'
32
import cx from 'classnames'
43

54
import { Link } from 'components/Link'
65
import { useMainContext } from 'components/context/MainContext'
7-
import { ChevronDownIcon } from '@primer/octicons-react'
6+
import { ChevronDownIcon, LinkExternalIcon } from '@primer/octicons-react'
87
import { Details, useDetails } from '@primer/components'
98

109
export const ProductPicker = () => {

components/Search.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import { useState, useEffect, useRef, Children, ReactNode } from 'react'
2-
import cx from 'classnames'
1+
import { useState, useEffect, useRef, ReactNode } from 'react'
32
import { useRouter } from 'next/router'
43
import debounce from 'lodash/debounce'
54
import { useTranslation } from 'components/hooks/useTranslation'
@@ -184,6 +183,7 @@ export function Search({ isStandalone = false, updateSearchParams = true, childr
184183
</div>
185184
)}
186185
</div>
186+
{/* eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions */}
187187
<div
188188
className={'search-overlay-desktop' + (!isStandalone && query ? ' js-open' : '')}
189189
onClick={closeSearch}
@@ -200,6 +200,7 @@ export function Search({ isStandalone = false, updateSearchParams = true, childr
200200
className={'ais-SearchBox-input' + (isStandalone || query ? ' js-open' : '')}
201201
type="search"
202202
placeholder={t`placeholder`}
203+
/* eslint-disable-next-line jsx-a11y/no-autofocus */
203204
autoFocus={isStandalone}
204205
autoComplete="off"
205206
autoCorrect="off"

components/SidebarNav.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ import { SidebarProduct } from './product/SidebarProduct'
88
import { AllProductsLink } from './product/AllProductsLink'
99
import { useVersion } from './hooks/useVersion'
1010

11-
type Props = {}
12-
export const SidebarNav = (props: Props) => {
11+
export const SidebarNav = () => {
1312
const router = useRouter()
1413
const { error, relativePath, isHomepageVersion } = useMainContext()
1514
const { t } = useTranslation('header')

components/Survey.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export const Survey = () => {
1717
const formRef = useRef<HTMLFormElement>(null)
1818

1919
function vote(state: ViewState) {
20-
return (evt: React.ChangeEvent<HTMLInputElement>) => {
20+
return () => {
2121
trackEvent(getFormData())
2222
setState(state)
2323
}

components/article/ArticlePage.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,16 +73,19 @@ export const ArticlePage = () => {
7373
data-default-platform={defaultPlatform || undefined}
7474
>
7575
<div className="UnderlineNav-body">
76+
{/* eslint-disable-next-line jsx-a11y/anchor-is-valid */}
7677
<a href="#" className="UnderlineNav-item platform-switcher" data-platform="mac">
7778
Mac
7879
</a>
80+
{/* eslint-disable-next-line jsx-a11y/anchor-is-valid */}
7981
<a
8082
href="#"
8183
className="UnderlineNav-item platform-switcher"
8284
data-platform="windows"
8385
>
8486
Windows
8587
</a>
88+
{/* eslint-disable-next-line jsx-a11y/anchor-is-valid */}
8689
<a
8790
href="#"
8891
className="UnderlineNav-item platform-switcher"

components/landing/CommunityExamples.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export const CommunityExamples = () => {
1717
return (
1818
<div>
1919
<div className="d-flex flex-wrap gutter">
20-
{productCommunityExamples.slice(0, numVisible).map((repo, i) => {
20+
{productCommunityExamples.slice(0, numVisible).map((repo) => {
2121
return (
2222
<div key={repo.repo} className="col-12 col-xl-4 col-lg-6 mb-4">
2323
<RepoCard repo={repo} />

0 commit comments

Comments
 (0)