Skip to content

Commit 2178c5f

Browse files
authored
Merge branch 'main' into kh-restrict-polymorphic-linting
2 parents e928282 + 882bd4d commit 2178c5f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+1183
-372
lines changed

.babelrc

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
{
66
"targets": {
77
"node": 4
8-
}
8+
},
9+
"transformRuntime": false
910
}
1011
]
1112
],

.eslintrc

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"ignorePatterns": [
88
"lib/",
99
"reports/",
10+
"examples/",
1011
],
1112
"parser": "@babel/eslint-parser",
1213
"plugins": [

.github/workflows/node-4+.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ jobs:
8888
eslint: 3
8989

9090
steps:
91-
- uses: actions/checkout@v3
91+
- uses: actions/checkout@v4
9292
with:
9393
fetch-depth: 0
9494
- uses: ljharb/actions/node/install@main
@@ -102,11 +102,11 @@ jobs:
102102
- run: rm __tests__/src/util/getComputedRole-test.js
103103
if: ${{ matrix.node-version < 7 }}
104104
- run: npm run test:ci
105-
- uses: codecov/codecov-action@v3
105+
- uses: codecov/codecov-action@v3.1.5
106106

107107
node:
108108
name: 'node 4+'
109109
needs: [latest]
110110
runs-on: ubuntu-latest
111111
steps:
112-
- run: 'echo tests completed'
112+
- run: true

.github/workflows/node-pretest.yml

+20-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77
runs-on: ubuntu-latest
88

99
steps:
10-
- uses: actions/checkout@v3
10+
- uses: actions/checkout@v4
1111
- uses: ljharb/actions/node/install@main
1212
name: 'nvm install lts/* && npm install'
1313
with:
@@ -19,7 +19,7 @@ jobs:
1919
runs-on: ubuntu-latest
2020

2121
steps:
22-
- uses: actions/checkout@v3
22+
- uses: actions/checkout@v4
2323
- uses: ljharb/actions/node/install@main
2424
name: 'nvm install lts/* && npm install'
2525
with:
@@ -31,10 +31,27 @@ jobs:
3131
runs-on: ubuntu-latest
3232

3333
steps:
34-
- uses: actions/checkout@v3
34+
- uses: actions/checkout@v4
3535
- uses: ljharb/actions/node/install@main
3636
name: 'nvm install lts/* && npm install'
3737
with:
3838
node-version: 'lts/*'
3939
skip-ls-check: true
4040
- run: npm run posttest
41+
42+
examples:
43+
runs-on: ubuntu-latest
44+
45+
steps:
46+
- uses: actions/checkout@v4
47+
- uses: ljharb/actions/node/install@main
48+
name: 'nvm install lts/* && npm install'
49+
with:
50+
node-version: 'lts/*'
51+
skip-ls-check: true
52+
- run: npm run test:examples
53+
54+
engines:
55+
runs-on: ubuntu-latest
56+
steps:
57+
- uses: ljharb/actions/node/engines@main

.github/workflows/readme.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77
runs-on: ubuntu-latest
88

99
steps:
10-
- uses: actions/checkout@v3
10+
- uses: actions/checkout@v4
1111
- uses: ljharb/actions/node/install@main
1212
name: 'nvm install lts/* && npm install'
1313
with:

.github/workflows/rebase.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
runs-on: ubuntu-latest
1010

1111
steps:
12-
- uses: actions/checkout@v3
12+
- uses: actions/checkout@v4
1313
- uses: ljharb/rebase@master
1414
env:
1515
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

CHANGELOG.md

+28
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,34 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [v6.9.0](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/compare/v6.8.0...v6.9.0) - 2024-06-19
9+
10+
### Fixed
11+
12+
- [Fix] `img-redundant-alt`: fixed multibyte character support [`#969`](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/issues/969)
13+
- [meta] fix changelog links [`#960`](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/issues/960)
14+
15+
### Commits
16+
17+
- [New] add support for Flat Config [`6b5f096`](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/commit/6b5f096f10b47326d68e2893152a48a79c8555b4)
18+
- Revert "[Fix] `isNonInteractiveElement`: Upgrade aria-query to 5.3.0 and axobject-query to 3.2.1" [`75d5dd7`](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/commit/75d5dd722bd67186d97afa7b151fd6fee5885c70)
19+
- [Robustness] use `safe-regex-test` [`4c7e781`](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/commit/4c7e7815c12a797587bb8e3cdced7f3003848964)
20+
- [actions] update actions/checkout [`51a1ca7`](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/commit/51a1ca7b4d83d4fbd1ea62888f7f2dc21ece6788)
21+
- [Dev Deps] update `@babel/cli`, `@babel/core`, `@babel/eslint-parser`, `@babel/plugin-transform-flow-strip-types`, `@babel/register`, `eslint-doc-generator`, `object.entries` [`1271ac1`](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/commit/1271ac1d6e5dcf9a2bc2c086faaf062335629171)
22+
- [Dev Deps] update `@babel/cli`, `@babel/core`, `@babel/register`, `aud`, `eslint-plugin-import`, `npmignore`, `object.assign` [`540cb7a`](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/commit/540cb7aefead582f237071d55a40f098d0885478)
23+
- [Deps] update `@babel/runtime`, `array-includes`, `es-iterator-helpers`, `hasown`, `object.fromentries`, `safe-regex-test` [`5d14408`](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/commit/5d1440825a8838ae10dc94cc3a4a7e1e967644b4)
24+
- [Deps] pin `aria-query` and `axobject-query`, add `ls-engines` test to CI [`32fd82c`](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/commit/32fd82c628d7f3e4ec8c06a1994f4eca1be2be4f)
25+
- [Dev Deps] update `@babel/core`, `@babel/eslint-parser`, `@babel/plugin-transform-flow-strip-types`, `eslint-doc-generator` [`d1b4114`](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/commit/d1b41142248a7cca45bb5f0b96ff23ee87fb9411)
26+
- [Fix] ensure `summary` remains non-interactive [`6a048da`](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/commit/6a048dacf2b98eaa204e2a5a70dc7e3d48d9463a)
27+
- [Deps] remove `@babel/runtime` [`0a98ad8`](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/commit/0a98ad83ffa7f4b66458cc1c39db2ef32bb2c480)
28+
- [New] `no-noninteractive-element-to-interactive-role`: allow `menuitemradio` and `menuitemcheckbox` on &lt;li&gt; [`c0733f9`](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/commit/c0733f94031fe3eec6b4d54176afe47929bb0a84)
29+
- [Deps] update `@babel/runtime`, `safe-regex-test` [`0d5321a`](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/commit/0d5321a5457c5f0da0ca216053cc5b4f571b53ae)
30+
- [actions] pin codecov to v3.1.5 [`961817f`](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/commit/961817f61fa56cd7815c6940c27ef08469b1516b)
31+
- [Deps] unpin `axe-core` [`b3559cf`](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/commit/b3559cf89be6b5352cd77ffa025831b3d793d565)
32+
- [Deps] move `object.entries` to dev deps [`1be7b70`](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/commit/1be7b709eececd83f1d5f67a60b2c97cfe9a561d)
33+
- [Deps] update `@babel/runtime` [`2a48abb`](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/commit/2a48abb5effa911e7d1a8575e1c9768c947a33f1)
34+
- [Deps] update `@babel/runtime` [`1adec35`](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/commit/1adec3517fc2c9797212ca4d38858deed917e7be)
35+
836
## [v6.8.0](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/compare/v6.7.1...v6.8.0) - 2023-11-01
937

1038
### Merged

README.md

+91-2
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ yarn add eslint-plugin-jsx-a11y --dev
6060

6161
**Note:** If you installed ESLint globally (using the `-g` flag in npm, or the `global` prefix in yarn) then you must also install `eslint-plugin-jsx-a11y` globally.
6262

63-
## Usage
63+
<a id="usage"></a>
64+
## Usage - Legacy Config (`.eslintrc`)
6465

6566
Add `jsx-a11y` to the plugins section of your `.eslintrc` configuration file. You can omit the `eslint-plugin-` prefix:
6667

@@ -109,6 +110,94 @@ Add `plugin:jsx-a11y/recommended` or `plugin:jsx-a11y/strict` in `extends`:
109110
}
110111
```
111112

113+
## Usage - Flat Config (`eslint.config.js`)
114+
115+
The default export of `eslint-plugin-jsx-a11y` is a plugin object.
116+
117+
```js
118+
const jsxA11y = require('eslint-plugin-jsx-a11y');
119+
120+
module.exports = [
121+
122+
{
123+
files: ['**/*.{js,mjs,cjs,jsx,mjsx,ts,tsx,mtsx}'],
124+
plugins: {
125+
'jsx-a11y': jsxA11y,
126+
},
127+
languageOptions: {
128+
parserOptions: {
129+
ecmaFeatures: {
130+
jsx: true,
131+
},
132+
},
133+
},
134+
rules: {
135+
// ... any rules you want
136+
'jsx-a11y/alt-text': 'error',
137+
},
138+
// ... others are omitted for brevity
139+
},
140+
141+
];
142+
```
143+
144+
### Shareable Configs
145+
146+
There are two shareable configs, provided by the plugin.
147+
148+
- `flatConfigs.recommended`
149+
- `flatConfigs.strict`
150+
151+
#### CJS
152+
153+
```js
154+
const jsxA11y = require('eslint-plugin-jsx-a11y');
155+
156+
export default [
157+
jsxA11y.flatConfigs.recommended,
158+
{
159+
// Your additional configs and overrides
160+
},
161+
];
162+
```
163+
164+
#### ESM
165+
166+
```js
167+
import jsxA11y from 'eslint-plugin-jsx-a11y';
168+
169+
export default [
170+
jsxA11y.flatConfigs.recommended,
171+
{
172+
// Your additional configs and overrides
173+
},
174+
];
175+
```
176+
177+
**Note**: Our shareable config do configure `files` or [`languageOptions.globals`](https://eslint.org/docs/latest/user-guide/configuring/configuration-files-new#configuration-objects).
178+
For most of the cases, you probably want to configure some of these properties yourself.
179+
180+
```js
181+
const jsxA11yRecommended = require('eslint-plugin-jsx-a11y');
182+
const globals = require('globals');
183+
184+
module.exports = [
185+
186+
{
187+
files: ['**/*.{js,mjs,cjs,jsx,mjsx,ts,tsx,mtsx}'],
188+
...jsxA11y.flatConfigs.recommended,
189+
languageOptions: {
190+
...jsxA11y.flatConfigs.recommended.languageOptions,
191+
globals: {
192+
...globals.serviceworker,
193+
...globals.browser,
194+
},
195+
},
196+
},
197+
198+
];
199+
```
200+
112201
#### Component Mapping
113202

114203
To enable your custom components to be checked as DOM elements, you can set global settings in your configuration file by mapping each custom component name to a DOM element type.
@@ -126,7 +215,7 @@ will be evaluated as an `h3`. If no `polymorphicPropName` is set, then the compo
126215

127216
To restrict polymorphic linting to specified components, additionally set `polymorphicAllowList` to an array of component names.
128217

129-
⚠️ Polymorphic components can make code harder to maintain; please use this feature with caution.
218+
⚠️ Polymorphic components can make code harder to maintain; please use this feature with caution.
130219

131220
## Supported Rules
132221

__mocks__/genInteractives.js

+5-10
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,14 @@ const interactiveElementsMap = {
4545
'input[type="time"]': [{ prop: 'type', value: 'time' }],
4646
'input[type="url"]': [{ prop: 'type', value: 'url' }],
4747
'input[type="week"]': [{ prop: 'type', value: 'week' }],
48+
link: [{ prop: 'href', value: '#' }],
4849
menuitem: [],
4950
option: [],
5051
select: [],
5152
// Whereas ARIA makes a distinction between cell and gridcell, the AXObject
5253
// treats them both as CellRole and since gridcell is interactive, we consider
5354
// cell interactive as well.
54-
td: [],
55+
// td: [],
5556
th: [],
5657
tr: [],
5758
textarea: [],
@@ -60,38 +61,34 @@ const interactiveElementsMap = {
6061

6162
const nonInteractiveElementsMap: {[string]: Array<{[string]: string}>} = {
6263
abbr: [],
63-
address: [],
6464
aside: [],
6565
article: [],
6666
blockquote: [],
67+
body: [],
6768
br: [],
6869
caption: [],
69-
code: [],
7070
dd: [],
71-
del: [],
7271
details: [],
7372
dfn: [],
7473
dialog: [],
7574
dir: [],
7675
dl: [],
7776
dt: [],
78-
em: [],
7977
fieldset: [],
8078
figcaption: [],
8179
figure: [],
8280
footer: [],
8381
form: [],
82+
frame: [],
8483
h1: [],
8584
h2: [],
8685
h3: [],
8786
h4: [],
8887
h5: [],
8988
h6: [],
9089
hr: [],
91-
html: [],
9290
iframe: [],
9391
img: [],
94-
ins: [],
9592
label: [],
9693
legend: [],
9794
li: [],
@@ -110,11 +107,9 @@ const nonInteractiveElementsMap: {[string]: Array<{[string]: string}>} = {
110107
ruby: [],
111108
'section[aria-label]': [{ prop: 'aria-label' }],
112109
'section[aria-labelledby]': [{ prop: 'aria-labelledby' }],
113-
strong: [],
114-
sub: [],
115-
sup: [],
116110
table: [],
117111
tbody: [],
112+
td: [],
118113
tfoot: [],
119114
thead: [],
120115
time: [],

__tests__/src/rules/control-has-associated-label-test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ const alwaysValid = [
157157
{ code: '<section />' },
158158
{ code: '<table />' },
159159
{ code: '<tbody />' },
160+
{ code: '<td />' },
160161
{ code: '<tfoot />' },
161162
{ code: '<thead />' },
162163
{ code: '<time />' },
@@ -261,7 +262,6 @@ const neverValid = [
261262
{ code: '<area href="#" />', errors: [expectedError] },
262263
{ code: '<menuitem />', errors: [expectedError] },
263264
{ code: '<option />', errors: [expectedError] },
264-
{ code: '<td />', errors: [expectedError] },
265265
{ code: '<th />', errors: [expectedError] },
266266
// Interactive Roles
267267
{ code: '<div role="button" />', errors: [expectedError] },

__tests__/src/rules/no-interactive-element-to-noninteractive-role-test.js

-1
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,6 @@ const alwaysValid = [
170170
{ code: '<style role="button" />;' },
171171
{ code: '<sub role="button" />;' },
172172
{ code: '<summary role="button" />;' },
173-
{ code: '<summary role="listitem" />;' },
174173
{ code: '<sup role="button" />;' },
175174
{ code: '<th role="button" />;' },
176175
{ code: '<time role="button" />;' },

0 commit comments

Comments
 (0)