Skip to content

Commit 043b0e4

Browse files
committed
Upgrade the aria-query and axobject-query libraries
1 parent bccf0ae commit 043b0e4

32 files changed

+126
-135
lines changed

.eslintignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules/
2+
reports/
3+
lib/

.eslintrc

-5
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
11
{
2-
"root": true,
32
"extends": [
43
"airbnb-base",
54
"plugin:flowtype/recommended"
65
],
7-
"ignorePatterns": [
8-
"lib/",
9-
"reports/",
10-
],
116
"parser": "@babel/eslint-parser",
127
"plugins": [
138
"flowtype",

.gitignore

-2
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,3 @@ npm-shrinkwrap.json
88
package-lock.json
99
yarn-error.log
1010
yarn.lock
11-
12-
.npmignore

.npmignore

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
.DS_Store
2+
.flowconfig
3+
.travis.yml
4+
/coverage
5+
/flow
6+
/node_modules
7+
npm-debug.log
8+
/src
9+
/reports
10+
yarn-error.log

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ configuration file by mapping each custom component name to a DOM element type.
123123
- [aria-unsupported-elements](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/aria-unsupported-elements.md): Enforce that elements that do not support ARIA roles, states, and properties do not have those attributes.
124124
- [autocomplete-valid](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/autocomplete-valid.md): Enforce that autocomplete attributes are used correctly.
125125
- [click-events-have-key-events](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/click-events-have-key-events.md): Enforce a clickable non-interactive element has at least one keyboard event listener.
126-
- [control-has-associated-label](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/main/docs/rules/control-has-associated-label.md): Enforce that a control (an interactive element) has a text label.
126+
127127
- [heading-has-content](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/heading-has-content.md): Enforce heading (`h1`, `h2`, etc) elements contain accessible content.
128128
- [html-has-lang](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/html-has-lang.md): Enforce `<html>` element has `lang` prop.
129129
- [iframe-has-title](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/iframe-has-title.md): Enforce iframe elements have a title attribute.
@@ -168,7 +168,7 @@ configuration file by mapping each custom component name to a DOM element type.
168168
| [aria-unsupported-elements](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/aria-unsupported-elements.md) | error | error |
169169
| [autocomplete-valid](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/autocomplete-valid.md) | error | error |
170170
| [click-events-have-key-events](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/click-events-have-key-events.md) | error | error |
171-
| [control-has-associated-label](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/main/docs/rules/control-has-associated-label.md) | off | off |
171+
| [control-has-associated-label](undefined) | off | off |
172172
| [heading-has-content](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/heading-has-content.md) | error | error |
173173
| [html-has-lang](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/html-has-lang.md) | error | error |
174174
| [iframe-has-title](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/iframe-has-title.md) | error | error |

__mocks__/genInteractives.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ import JSXElementMock from './JSXElementMock';
1010
import type { JSXAttributeMockType } from './JSXAttributeMock';
1111
import type { JSXElementMockType } from './JSXElementMock';
1212

13-
const domElements = [...dom.keys()];
14-
const roleNames = [...roles.keys()];
13+
const domElements = dom.keys();
14+
const roleNames = roles.keys();
1515

1616
const interactiveElementsMap = {
1717
a: [{ prop: 'href', value: '#' }],

__tests__/src/rules/aria-role-test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const errorMessage = {
2323
type: 'JSXAttribute',
2424
};
2525

26-
const roleKeys = [...roles.keys()];
26+
const roleKeys = roles.keys();
2727

2828
const validRoles = roleKeys.filter((role) => roles.get(role).abstract === false);
2929
const invalidRoles = roleKeys.filter((role) => roles.get(role).abstract === true);

__tests__/src/rules/aria-unsupported-elements-test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Try removing the prop '${invalidProp}'.`,
2525
type: 'JSXOpeningElement',
2626
});
2727

28-
const domElements = [...dom.keys()];
28+
const domElements = dom.keys();
2929
// Generate valid test cases
3030
const roleValidityTests = domElements.map((element) => {
3131
const isReserved = dom.get(element).reserved || false;

__tests__/src/rules/role-has-required-aria-props-test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ const componentsSettings = {
3737
};
3838

3939
// Create basic test cases using all valid role types.
40-
const basicValidityTests = [...roles.keys()].map((role) => {
40+
const basicValidityTests = roles.keys().map((role) => {
4141
const {
4242
requiredProps: requiredPropKeyValues,
4343
} = roles.get(role);

__tests__/src/rules/role-supports-aria-props-test.js

+7-14
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,14 @@ const componentsSettings = {
4545
},
4646
};
4747

48-
const nonAbstractRoles = [...roles.keys()].filter((role) => roles.get(role).abstract === false);
48+
const nonAbstractRoles = roles.keys().filter((role) => roles.get(role).abstract === false);
4949

5050
const createTests = (rolesNames) => rolesNames.reduce((tests, role) => {
5151
const {
5252
props: propKeyValues,
5353
} = roles.get(role);
5454
const validPropsForRole = Object.keys(propKeyValues);
55-
const invalidPropsForRole = [...aria.keys()]
55+
const invalidPropsForRole = aria.keys()
5656
.map((attribute) => attribute.toLowerCase())
5757
.filter((attribute) => validPropsForRole.indexOf(attribute) === -1);
5858
const normalRole = role.toLowerCase();
@@ -94,7 +94,9 @@ ruleTester.run('role-supports-aria-props', rule, {
9494
{ code: '<a href="#" aria-disabled />' },
9595
{ code: '<a href="#" aria-dropeffect />' },
9696
{ code: '<a href="#" aria-flowto />' },
97+
{ code: '<a href="#" aria-haspopup />' },
9798
{ code: '<a href="#" aria-grabbed />' },
99+
{ code: '<a href="#" aria-haspopup />' },
98100
{ code: '<a href="#" aria-hidden />' },
99101
{ code: '<a href="#" aria-label />' },
100102
{ code: '<a href="#" aria-labelledby />' },
@@ -115,6 +117,7 @@ ruleTester.run('role-supports-aria-props', rule, {
115117
{ code: '<area href="#" aria-dropeffect />' },
116118
{ code: '<area href="#" aria-flowto />' },
117119
{ code: '<area href="#" aria-grabbed />' },
120+
{ code: '<area href="#" aria-haspopup />' },
118121
{ code: '<area href="#" aria-hidden />' },
119122
{ code: '<area href="#" aria-label />' },
120123
{ code: '<area href="#" aria-labelledby />' },
@@ -135,7 +138,9 @@ ruleTester.run('role-supports-aria-props', rule, {
135138
{ code: '<link href="#" aria-dropeffect />' },
136139
{ code: '<link href="#" aria-flowto />' },
137140
{ code: '<link href="#" aria-grabbed />' },
141+
{ code: '<link href="#" aria-haspopup />' },
138142
{ code: '<link href="#" aria-hidden />' },
143+
{ code: '<link href="#" aria-haspopup />' },
139144
{ code: '<link href="#" aria-label />' },
140145
{ code: '<link href="#" aria-labelledby />' },
141146
{ code: '<link href="#" aria-live />' },
@@ -552,22 +557,10 @@ ruleTester.run('role-supports-aria-props', rule, {
552557
code: '<link href="#" aria-invalid />',
553558
errors: [errorMessage('aria-invalid', 'link', 'link', true)],
554559
},
555-
{
556-
code: '<link href="#" aria-haspopup />',
557-
errors: [errorMessage('aria-haspopup', 'link', 'link', true)],
558-
},
559560
{
560561
code: '<area href="#" aria-invalid />',
561562
errors: [errorMessage('aria-invalid', 'link', 'area', true)],
562563
},
563-
{
564-
code: '<area href="#" aria-haspopup />',
565-
errors: [errorMessage('aria-haspopup', 'link', 'area', true)],
566-
},
567-
{
568-
code: '<a href="#" aria-haspopup />',
569-
errors: [errorMessage('aria-haspopup', 'link', 'a', true)],
570-
},
571564
{
572565
code: '<a href="#" aria-invalid />',
573566
errors: [errorMessage('aria-invalid', 'link', 'a', true)],

__tests__/src/util/isDOMElement-test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { elementType } from 'jsx-ast-utils';
44
import isDOMElement from '../../../src/util/isDOMElement';
55
import JSXElementMock from '../../../__mocks__/JSXElementMock';
66

7-
const domElements = [...dom.keys()];
7+
const domElements = dom.keys();
88

99
describe('isDOMElement', () => {
1010
describe('DOM elements', () => {

package.json

+13-21
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,11 @@
1717
},
1818
"main": "lib/index.js",
1919
"scripts": {
20-
"prepack": "npmignore --auto --commentLines=autogenerated",
2120
"build": "rimraf lib && babel src --out-dir lib --copy-files",
2221
"create": "node ./scripts/create-rule",
2322
"flow": "flow",
2423
"lint:fix": "npm run lint -- --fix",
25-
"lint": "eslint --ext=js,mjs,cjs,ts,tsx .",
24+
"lint": "eslint .",
2625
"prepublish": "not-in-publish || npm run prepublishOnly",
2726
"prepublishOnly": "safe-publish-latest && npm run lint && npm run flow && npm run jest && npm run build",
2827
"pretest": "npm run lint:fix && npm run flow",
@@ -34,13 +33,13 @@
3433
"generate-list-of-rules:check": "npm run generate-list-of-rules && git diff --exit-code README.md"
3534
},
3635
"devDependencies": {
37-
"@babel/cli": "^7.19.3",
38-
"@babel/core": "^7.19.3",
39-
"@babel/eslint-parser": "^7.19.1",
40-
"@babel/plugin-transform-flow-strip-types": "^7.19.0",
36+
"@babel/cli": "^7.18.9",
37+
"@babel/core": "^7.18.9",
38+
"@babel/eslint-parser": "^7.18.9",
39+
"@babel/plugin-transform-flow-strip-types": "^7.18.9",
4140
"@babel/register": "^7.18.9",
4241
"ast-types-flow": "^0.0.7",
43-
"aud": "^2.0.1",
42+
"aud": "^2.0.0",
4443
"babel-jest": "^24.9.0",
4544
"babel-plugin-add-module-exports": "^1.0.4",
4645
"babel-preset-airbnb": "^5.0.0",
@@ -57,8 +56,7 @@
5756
"jscodeshift": "^0.7.1",
5857
"markdown-magic": "^2.6.1",
5958
"minimist": "^1.2.6",
60-
"npmignore": "^0.3.0",
61-
"object.assign": "^4.1.4",
59+
"object.assign": "^4.1.2",
6260
"rimraf": "^3.0.2",
6361
"safe-publish-latest": "^2.0.0",
6462
"to-ast": "^1.0.0"
@@ -68,12 +66,12 @@
6866
},
6967
"license": "MIT",
7068
"dependencies": {
71-
"@babel/runtime": "^7.19.0",
72-
"aria-query": "^4.2.2",
69+
"@babel/runtime": "^7.18.9",
70+
"aria-query": "^5.0.3",
7371
"array-includes": "^3.1.5",
7472
"ast-types-flow": "^0.0.7",
7573
"axe-core": "^4.4.3",
76-
"axobject-query": "^2.2.0",
74+
"axobject-query": "^3.0.1",
7775
"damerau-levenshtein": "^1.0.8",
7876
"emoji-regex": "^9.2.2",
7977
"has": "^1.0.3",
@@ -100,16 +98,10 @@
10098
],
10199
"testEnvironment": "node"
102100
},
103-
"publishConfig": {
101+
"greenkeeper": {
104102
"ignore": [
105-
"!lib",
106-
".github/workflows",
107-
".flowconfig",
108-
"/src",
109-
"/reports",
110-
"/flow",
111-
"scripts/",
112-
"CONTRIBUTING.md"
103+
"jest",
104+
"babel-jest"
113105
]
114106
}
115107
}

scripts/boilerplate/rule.js

+1-4
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,7 @@ const schema = generateObjSchema();
1717
1818
export default {
1919
meta: {
20-
docs: {
21-
get description() { throw new SyntaxError('do not forget to add the description!'); },
22-
get url() { throw new SyntaxError('do not forget to add the URL!'); },
23-
},
20+
docs: {},
2421
schema: [schema],
2522
},
2623

src/rules/aria-activedescendant-has-tabindex.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const errorMessage = 'An element that manages focus with `aria-activedescendant`
1818

1919
const schema = generateObjSchema();
2020

21-
const domElements = [...dom.keys()];
21+
const domElements = dom.keys();
2222

2323
export default {
2424
meta: {

src/rules/aria-props.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { propName } from 'jsx-ast-utils';
1212
import { generateObjSchema } from '../util/schemas';
1313
import getSuggestion from '../util/getSuggestion';
1414

15-
const ariaAttributes = [...aria.keys()];
15+
const ariaAttributes = aria.keys();
1616

1717
const errorMessage = (name) => {
1818
const suggestions = getSuggestion(name, ariaAttributes);

src/rules/aria-unsupported-elements.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export default {
4747
return;
4848
}
4949

50-
const invalidAttributes = [...aria.keys(), 'role'];
50+
const invalidAttributes = aria.keys().concat('role');
5151

5252
node.attributes.forEach((prop) => {
5353
if (prop.type === 'JSXSpreadAttribute') {

src/rules/click-events-have-key-events.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import isPresentationRole from '../util/isPresentationRole';
1919
const errorMessage = 'Visible, non-interactive elements with click handlers must have at least one keyboard listener.';
2020

2121
const schema = generateObjSchema();
22-
const domElements = [...dom.keys()];
22+
const domElements = dom.keys();
2323

2424
export default {
2525
meta: {

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

+1-4
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,7 @@ const schema = generateObjSchema({
3939

4040
export default ({
4141
meta: {
42-
docs: {
43-
description: 'Enforce that a control (an interactive element) has a text label.',
44-
url: 'https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/main/docs/rules/control-has-associated-label.md',
45-
},
42+
docs: {},
4643
schema: [schema],
4744
},
4845

src/rules/interactive-supports-focus.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@ import getTabIndex from '../util/getTabIndex';
3636
// ----------------------------------------------------------------------------
3737

3838
const schema = generateObjSchema({
39-
tabbable: enumArraySchema([...roles.keys()]
39+
tabbable: enumArraySchema(roles.keys()
4040
.filter((name) => !roles.get(name).abstract)
4141
.filter((name) => roles.get(name).superClass.some((klasses) => includes(klasses, 'widget')))),
4242
});
43-
const domElements = [...dom.keys()];
43+
const domElements = dom.keys();
4444

4545
const interactiveProps = [].concat(
4646
eventHandlersByType.mouse,

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import isPresentationRole from '../util/isPresentationRole';
2727

2828
const errorMessage = 'Interactive elements should not be assigned non-interactive roles.';
2929

30-
const domElements = [...dom.keys()];
30+
const domElements = dom.keys();
3131

3232
export default ({
3333
meta: {

src/rules/no-noninteractive-element-interactions.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@ import isPresentationRole from '../util/isPresentationRole';
3131

3232
const errorMessage = 'Non-interactive elements should not be assigned mouse or keyboard event listeners.';
3333

34-
const domElements = [...dom.keys()];
35-
const defaultInteractiveProps = [].concat(
36-
eventHandlersByType.focus,
37-
eventHandlersByType.image,
38-
eventHandlersByType.keyboard,
39-
eventHandlersByType.mouse,
40-
);
34+
const domElements = dom.keys();
35+
const defaultInteractiveProps = [
36+
...eventHandlersByType.focus,
37+
...eventHandlersByType.image,
38+
...eventHandlersByType.keyboard,
39+
...eventHandlersByType.mouse,
40+
];
4141
const schema = generateObjSchema({
4242
handlers: arraySchema,
4343
});

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import isInteractiveRole from '../util/isInteractiveRole';
2525

2626
const errorMessage = 'Non-interactive elements should not be assigned interactive roles.';
2727

28-
const domElements = [...dom.keys()];
28+
const domElements = dom.keys();
2929

3030
export default ({
3131
meta: {

src/rules/no-static-element-interactions.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@ import isPresentationRole from '../util/isPresentationRole';
3131

3232
const errorMessage = 'Avoid non-native interactive elements. If using native HTML is not possible, add an appropriate role and support for tabbing, mouse, keyboard, and touch inputs to an interactive content element.';
3333

34-
const domElements = [...dom.keys()];
35-
const defaultInteractiveProps = [].concat(
36-
eventHandlersByType.focus,
37-
eventHandlersByType.keyboard,
38-
eventHandlersByType.mouse,
39-
);
34+
const domElements = dom.keys();
35+
const defaultInteractiveProps = [
36+
...eventHandlersByType.focus,
37+
...eventHandlersByType.keyboard,
38+
...eventHandlersByType.mouse,
39+
];
4040
const schema = generateObjSchema({
4141
handlers: arraySchema,
4242
});

src/rules/role-has-required-aria-props.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ export default {
5858
return;
5959
}
6060

61-
const normalizedValues = String(roleAttrValue).toLowerCase().split(' ');
62-
const validRoles = normalizedValues
63-
.filter((val) => [...roles.keys()].indexOf(val) > -1);
61+
const normalizedValues = String(roleAttrValue).toLowerCase().split(' ');
62+
const validRoles = normalizedValues
63+
.filter((val) => roles.keys().indexOf(val) > -1);
6464

6565
// Check semantic DOM elements
6666
// For example, <input type="checkbox" role="switch" />

0 commit comments

Comments
 (0)