Skip to content

Commit 094b531

Browse files
authored
Fixing test failures for eslint rule @elastic/eui/no-unnamed-interactive-element (#9010)
1 parent 1c9f813 commit 094b531

File tree

1 file changed

+53
-18
lines changed

1 file changed

+53
-18
lines changed

packages/eslint-plugin/src/rules/a11y/no_unnamed_interactive_element.test.ts

Lines changed: 53 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,82 +17,117 @@
1717
* under the License.
1818
*/
1919

20-
import dedent from 'dedent';
2120
import { RuleTester } from '@typescript-eslint/rule-tester';
2221
import { NoUnnamedInteractiveElement } from './no_unnamed_interactive_element';
2322

24-
const ruleTester = new RuleTester({});
25-
// Set the parser for RuleTester
26-
// @ts-ignore
27-
ruleTester.parser = require.resolve('@typescript-eslint/parser');
23+
const ruleTester = new RuleTester();
24+
25+
// Enable JSX for each snippet
26+
const languageOptions = {
27+
parserOptions: {
28+
ecmaFeatures: {
29+
jsx: true,
30+
},
31+
},
32+
};
2833

2934
ruleTester.run('NoUnnamedInteractiveElement', NoUnnamedInteractiveElement, {
3035
valid: [
3136
// Components with allowed a11y props
32-
{ code: '<EuiBetaBadge aria-label="Beta badge" />' },
33-
{ code: '<EuiButtonEmpty aria-labelledby="btnLabel" />' },
34-
{ code: '<EuiButtonIcon aria-label="Icon" />' },
35-
{ code: '<EuiComboBox label="Combo label" />' },
36-
{ code: '<EuiSelect aria-label="Select label" />' },
37-
{ code: '<EuiSelectWithWidth label="SelectWithWidth label" />' },
38-
{ code: '<EuiSuperSelect aria-labelledby="superLabel" />' },
39-
{ code: '<EuiPagination label="Pagination label" />' },
40-
{ code: '<EuiTreeView label="TreeView label" />' },
41-
{ code: '<EuiBreadcrumbs aria-label="Breadcrumbs label" />' },
37+
{ code: '<EuiBetaBadge aria-label="Beta badge" />', languageOptions },
38+
{ code: '<EuiButtonEmpty aria-labelledby="btnLabel" />', languageOptions },
39+
{ code: '<EuiButtonIcon aria-label="Icon" />', languageOptions },
40+
{ code: '<EuiComboBox aria-label="Combo label" />', languageOptions },
41+
{ code: '<EuiSelect aria-label="Select label" />', languageOptions },
42+
{
43+
code: '<EuiSelectWithWidth aria-label="SelectWithWidth label" />',
44+
languageOptions,
45+
},
46+
{
47+
code: '<EuiSuperSelect aria-labelledby="superLabel" />',
48+
languageOptions,
49+
},
50+
{
51+
code: '<EuiPagination aria-label="Pagination label" />',
52+
languageOptions,
53+
},
54+
{ code: '<EuiTreeView aria-label="TreeView label" />', languageOptions },
55+
{
56+
code: '<EuiBreadcrumbs aria-label="Breadcrumbs label" />',
57+
languageOptions,
58+
},
4259
// Wrapped in EuiFormRow with label
43-
{ code: '<EuiFormRow label="Row label"><EuiComboBox /></EuiFormRow>' },
44-
{ code: '<EuiFormRow label="Row label"><EuiSelect /></EuiFormRow>' },
60+
{
61+
code: '<EuiFormRow label="Row label"><EuiComboBox /></EuiFormRow>',
62+
languageOptions,
63+
},
64+
{
65+
code: '<EuiFormRow label="Row label"><EuiSelect /></EuiFormRow>',
66+
languageOptions,
67+
},
4568
],
4669
invalid: [
4770
// Missing a11y prop for interactive components
4871
{
4972
code: '<EuiBetaBadge />',
73+
languageOptions,
5074
errors: [{ messageId: 'missingA11y' }],
5175
},
5276
{
5377
code: '<EuiButtonEmpty />',
78+
languageOptions,
5479
errors: [{ messageId: 'missingA11y' }],
5580
},
5681
{
5782
code: '<EuiButtonIcon />',
83+
languageOptions,
5884
errors: [{ messageId: 'missingA11y' }],
5985
},
6086
{
6187
code: '<EuiComboBox />',
88+
languageOptions,
6289
errors: [{ messageId: 'missingA11y' }],
6390
},
6491
{
6592
code: '<EuiSelect />',
93+
languageOptions,
6694
errors: [{ messageId: 'missingA11y' }],
6795
},
6896
{
6997
code: '<EuiSelectWithWidth />',
98+
languageOptions,
7099
errors: [{ messageId: 'missingA11y' }],
71100
},
72101
{
73102
code: '<EuiSuperSelect />',
103+
languageOptions,
74104
errors: [{ messageId: 'missingA11y' }],
75105
},
76106
{
77107
code: '<EuiPagination />',
108+
languageOptions,
78109
errors: [{ messageId: 'missingA11y' }],
79110
},
80111
{
81112
code: '<EuiTreeView />',
113+
languageOptions,
82114
errors: [{ messageId: 'missingA11y' }],
83115
},
84116
{
85117
code: '<EuiBreadcrumbs />',
118+
languageOptions,
86119
errors: [{ messageId: 'missingA11y' }],
87120
},
88121
// Wrapped but missing label
89122
{
90123
code: '<EuiFormRow><EuiComboBox /></EuiFormRow>',
124+
languageOptions,
91125
errors: [{ messageId: 'missingA11y' }],
92126
},
93127
{
94128
code: '<EuiFormRow><EuiSelect /></EuiFormRow>',
129+
languageOptions,
95130
errors: [{ messageId: 'missingA11y' }],
96131
},
97132
],
98-
});
133+
});

0 commit comments

Comments
 (0)