mirror of https://github.com/sveltejs/svelte
[feat]: Add A11y aria-proptypes check (#6978)
* Add aria prop type list * feat: check aria attribute types * feat: add proptype tests * Add documentation * use aria-query Co-authored-by: Nurassyl Zekenov <nurassyl@snoonu.com> Co-authored-by: mka_882@yahoo.com <mka_882@yahoo.com> Co-authored-by: tanhauhau <lhtan93@gmail.com> Co-authored-by: David Mosher <davidmosher@gmail.com>pull/5613/head
parent
4617c0d5f5
commit
39901986d6
@ -0,0 +1,8 @@
|
||||
<script>
|
||||
const abc = 'abc';
|
||||
</script>
|
||||
|
||||
<button aria-disabled="yes"/>
|
||||
<button aria-disabled="no"/>
|
||||
<button aria-disabled={1234}/>
|
||||
<button aria-disabled={`${abc}`}/>
|
@ -0,0 +1,32 @@
|
||||
[
|
||||
{
|
||||
"code": "a11y-incorrect-aria-attribute-type",
|
||||
"message": "A11y: The value of 'aria-disabled' must be exactly one of true or false",
|
||||
"start": {
|
||||
"line": 5,
|
||||
"column": 8,
|
||||
"character": 51
|
||||
},
|
||||
"end": {
|
||||
"line": 5,
|
||||
"column": 27,
|
||||
"character": 70
|
||||
},
|
||||
"pos": 51
|
||||
},
|
||||
{
|
||||
"code": "a11y-incorrect-aria-attribute-type",
|
||||
"message": "A11y: The value of 'aria-disabled' must be exactly one of true or false",
|
||||
"start": {
|
||||
"line": 6,
|
||||
"column": 8,
|
||||
"character": 81
|
||||
},
|
||||
"end": {
|
||||
"line": 6,
|
||||
"column": 26,
|
||||
"character": 99
|
||||
},
|
||||
"pos": 81
|
||||
}
|
||||
]
|
@ -0,0 +1,7 @@
|
||||
<div aria-level="yes" />
|
||||
<div aria-level="no" />
|
||||
<div aria-level={`abc`} />
|
||||
<div aria-level={true} />
|
||||
<div aria-level />
|
||||
<div aria-level={"false"} />
|
||||
<div aria-level={!"false"} />
|
@ -0,0 +1,47 @@
|
||||
[
|
||||
{
|
||||
"code": "a11y-incorrect-aria-attribute-type",
|
||||
"message": "A11y: The value of 'aria-level' must be of type integer",
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 5,
|
||||
"character": 5
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 21,
|
||||
"character": 21
|
||||
},
|
||||
"pos": 5
|
||||
},
|
||||
{
|
||||
"code": "a11y-incorrect-aria-attribute-type",
|
||||
"message": "A11y: The value of 'aria-level' must be of type integer",
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 5,
|
||||
"character": 30
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 20,
|
||||
"character": 45
|
||||
},
|
||||
"pos": 30
|
||||
},
|
||||
{
|
||||
"code": "a11y-incorrect-aria-attribute-type",
|
||||
"message": "A11y: The value of 'aria-level' must be of type integer",
|
||||
"start": {
|
||||
"line": 5,
|
||||
"column": 5,
|
||||
"character": 107
|
||||
},
|
||||
"end": {
|
||||
"line": 5,
|
||||
"column": 15,
|
||||
"character": 117
|
||||
},
|
||||
"pos": 107
|
||||
}
|
||||
]
|
@ -0,0 +1,7 @@
|
||||
<div aria-valuemax="yes" />
|
||||
<div aria-valuemax="no" />
|
||||
<div aria-valuemax={`abc`} />
|
||||
<div aria-valuemax={true} />
|
||||
<div aria-valuemax />
|
||||
<div aria-valuemax={'false'} />
|
||||
<div aria-valuemax={!'false'} />
|
@ -0,0 +1,47 @@
|
||||
[
|
||||
{
|
||||
"code": "a11y-incorrect-aria-attribute-type",
|
||||
"message": "A11y: The value of 'aria-valuemax' must be of type number",
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 5,
|
||||
"character": 5
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 24,
|
||||
"character": 24
|
||||
},
|
||||
"pos": 5
|
||||
},
|
||||
{
|
||||
"code": "a11y-incorrect-aria-attribute-type",
|
||||
"message": "A11y: The value of 'aria-valuemax' must be of type number",
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 5,
|
||||
"character": 33
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 23,
|
||||
"character": 51
|
||||
},
|
||||
"pos": 33
|
||||
},
|
||||
{
|
||||
"code": "a11y-incorrect-aria-attribute-type",
|
||||
"message": "A11y: The value of 'aria-valuemax' must be of type number",
|
||||
"start": {
|
||||
"line": 5,
|
||||
"column": 5,
|
||||
"character": 119
|
||||
},
|
||||
"end": {
|
||||
"line": 5,
|
||||
"column": 18,
|
||||
"character": 132
|
||||
},
|
||||
"pos": 119
|
||||
}
|
||||
]
|
@ -0,0 +1,5 @@
|
||||
<div aria-label />
|
||||
<div aria-label={true} />
|
||||
<div aria-label={false} />
|
||||
<div aria-label={1234} />
|
||||
<div aria-label={!true} />
|
@ -0,0 +1,17 @@
|
||||
[
|
||||
{
|
||||
"code": "a11y-incorrect-aria-attribute-type",
|
||||
"message": "A11y: The value of 'aria-label' must be of type string",
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 5,
|
||||
"character": 5
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 15,
|
||||
"character": 15
|
||||
},
|
||||
"pos": 5
|
||||
}
|
||||
]
|
@ -0,0 +1,6 @@
|
||||
<div aria-sort="" />
|
||||
<div aria-sort="descnding" />
|
||||
<div aria-sort />
|
||||
<div aria-sort={true} />
|
||||
<div aria-sort={"false"} />
|
||||
<div aria-sort="ascending descending" />
|
@ -0,0 +1,62 @@
|
||||
[
|
||||
{
|
||||
"code": "a11y-incorrect-aria-attribute-type",
|
||||
"message": "A11y: The value of 'aria-sort' must be exactly one of ascending, descending, none, other",
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 5,
|
||||
"character": 5
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 17,
|
||||
"character": 17
|
||||
},
|
||||
"pos": 5
|
||||
},
|
||||
{
|
||||
"code": "a11y-incorrect-aria-attribute-type",
|
||||
"message": "A11y: The value of 'aria-sort' must be exactly one of ascending, descending, none, other",
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 5,
|
||||
"character": 26
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 26,
|
||||
"character": 47
|
||||
},
|
||||
"pos": 26
|
||||
},
|
||||
{
|
||||
"code": "a11y-incorrect-aria-attribute-type",
|
||||
"message": "A11y: The value of 'aria-sort' must be exactly one of ascending, descending, none, other",
|
||||
"start": {
|
||||
"line": 3,
|
||||
"column": 5,
|
||||
"character": 56
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 14,
|
||||
"character": 65
|
||||
},
|
||||
"pos": 56
|
||||
},
|
||||
{
|
||||
"code": "a11y-incorrect-aria-attribute-type",
|
||||
"message": "A11y: The value of 'aria-sort' must be exactly one of ascending, descending, none, other",
|
||||
"start": {
|
||||
"line": 6,
|
||||
"column": 5,
|
||||
"character": 127
|
||||
},
|
||||
"end": {
|
||||
"line": 6,
|
||||
"column": 37,
|
||||
"character": 159
|
||||
},
|
||||
"pos": 127
|
||||
}
|
||||
]
|
@ -0,0 +1,7 @@
|
||||
<div aria-relevant="" />
|
||||
<div aria-relevant="foobar" />
|
||||
<div aria-relevant />
|
||||
<div aria-relevant={true} />
|
||||
<div aria-relevant={"false"} />
|
||||
<div aria-relevant="additions removalss" />
|
||||
<div aria-relevant="additions removalss " />
|
@ -0,0 +1,77 @@
|
||||
[
|
||||
{
|
||||
"code": "a11y-incorrect-aria-attribute-type",
|
||||
"message": "A11y: The value of 'aria-relevant' must be a space-separated list of one or more of additions, all, removals, text",
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 5,
|
||||
"character": 5
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 21,
|
||||
"character": 21
|
||||
},
|
||||
"pos": 5
|
||||
},
|
||||
{
|
||||
"code": "a11y-incorrect-aria-attribute-type",
|
||||
"message": "A11y: The value of 'aria-relevant' must be a space-separated list of one or more of additions, all, removals, text",
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 5,
|
||||
"character": 30
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 27,
|
||||
"character": 52
|
||||
},
|
||||
"pos": 30
|
||||
},
|
||||
{
|
||||
"code": "a11y-incorrect-aria-attribute-type",
|
||||
"message": "A11y: The value of 'aria-relevant' must be a space-separated list of one or more of additions, all, removals, text",
|
||||
"start": {
|
||||
"line": 3,
|
||||
"column": 5,
|
||||
"character": 61
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 18,
|
||||
"character": 74
|
||||
},
|
||||
"pos": 61
|
||||
},
|
||||
{
|
||||
"code": "a11y-incorrect-aria-attribute-type",
|
||||
"message": "A11y: The value of 'aria-relevant' must be a space-separated list of one or more of additions, all, removals, text",
|
||||
"start": {
|
||||
"line": 6,
|
||||
"column": 5,
|
||||
"character": 144
|
||||
},
|
||||
"end": {
|
||||
"line": 6,
|
||||
"column": 40,
|
||||
"character": 179
|
||||
},
|
||||
"pos": 144
|
||||
},
|
||||
{
|
||||
"code": "a11y-incorrect-aria-attribute-type",
|
||||
"message": "A11y: The value of 'aria-relevant' must be a space-separated list of one or more of additions, all, removals, text",
|
||||
"start": {
|
||||
"line": 7,
|
||||
"column": 5,
|
||||
"character": 188
|
||||
},
|
||||
"end": {
|
||||
"line": 7,
|
||||
"column": 41,
|
||||
"character": 224
|
||||
},
|
||||
"pos": 188
|
||||
}
|
||||
]
|
@ -0,0 +1,8 @@
|
||||
<script>
|
||||
const abc = 'abc';
|
||||
</script>
|
||||
|
||||
<div aria-checked="yes" />
|
||||
<div aria-checked="no" />
|
||||
<div aria-checked={1234} />
|
||||
<div aria-checked={`${abc}`} />
|
@ -0,0 +1,32 @@
|
||||
[
|
||||
{
|
||||
"code": "a11y-incorrect-aria-attribute-type",
|
||||
"message": "A11y: The value of 'aria-checked' must be exactly one of true, false, or mixed",
|
||||
"start": {
|
||||
"line": 5,
|
||||
"column": 5,
|
||||
"character": 48
|
||||
},
|
||||
"end": {
|
||||
"line": 5,
|
||||
"column": 23,
|
||||
"character": 66
|
||||
},
|
||||
"pos": 48
|
||||
},
|
||||
{
|
||||
"code": "a11y-incorrect-aria-attribute-type",
|
||||
"message": "A11y: The value of 'aria-checked' must be exactly one of true, false, or mixed",
|
||||
"start": {
|
||||
"line": 6,
|
||||
"column": 5,
|
||||
"character": 75
|
||||
},
|
||||
"end": {
|
||||
"line": 6,
|
||||
"column": 22,
|
||||
"character": 92
|
||||
},
|
||||
"pos": 75
|
||||
}
|
||||
]
|
Loading…
Reference in new issue