forked from vue-a11y/eslint-plugin-vuejs-accessibility
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathno-aria-hidden-on-focusable.ts
34 lines (31 loc) · 1.02 KB
/
no-aria-hidden-on-focusable.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import type { Rule } from "eslint";
import { defineTemplateBodyVisitor, getElementAttributeValue, makeDocsURL } from "../utils";
import hasFocusableElements from "../utils/hasFocusableElement";
const rule: Rule.RuleModule = {
meta: {
type: "problem",
docs: {
url: makeDocsURL("no-aria-hidden-on-focusable")
},
messages: {
default: "Focusable/Interactive elements must not have an aria-hidden attribute."
},
schema: []
},
create(context) {
return defineTemplateBodyVisitor(context, {
VElement(node) {
const hasAriaHidden = getElementAttributeValue(node, 'aria-hidden');
if (hasAriaHidden) {
if (hasFocusableElements(node)) {
context.report({
node: node as any,
messageId: 'default',
});
}
}
},
});
}
}
export default rule;