Skip to content

Commit 440f6f3

Browse files
committed
Rename rule
1 parent a083b52 commit 440f6f3

File tree

7 files changed

+43
-26
lines changed

7 files changed

+43
-26
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ This config will be interpreted in the following way:
8484

8585
| Name                        | Description | 💼 | 🔧 ||
8686
| :----------------------------------------------------------------------- | :----------------------------------------------------------------------------------------------------------------------- | :- | :- | :- |
87-
| [a11y-aria-label-is-readable](docs/rules/a11y-aria-label-is-readable.md) | [aria-label] text should be formatted as you would visible text, in a human-readable format. | ⚛️ | | |
87+
| [a11y-aria-label-is-well-formatted](docs/rules/a11y-aria-label-is-well-formatted.md) | [aria-label] text should be formatted as you would visible text, in a human-readable format. | ⚛️ | | |
8888
| [a11y-no-generic-link-text](docs/rules/a11y-no-generic-link-text.md) | disallow generic link text | | ||
8989
| [array-foreach](docs/rules/array-foreach.md) | enforce `for..of` loops over `Array.forEach` || | |
9090
| [async-currenttarget](docs/rules/async-currenttarget.md) | disallow `event.currentTarget` calls inside of async functions | 🔍 | | |

docs/rules/a11y-aria-label-is-readable.md

Lines changed: 0 additions & 18 deletions
This file was deleted.
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# [aria-label] text should be formatted as you would visible text, in a human-readable format (`github/a11y-aria-label-is-well-formatted`)
2+
3+
💼 This rule is enabled in the ⚛️ `react` config.
4+
5+
<!-- end auto-generated rule header -->
6+
7+
## Rule Details
8+
9+
`[aria-label]` content should be formatted in the same way you would visible text.
10+
11+
Please use sentence case, and avoid using hyphens like you would an ID.
12+
13+
## Resources
14+
15+
## Examples
16+
17+
### **Incorrect** code for this rule 👎
18+
19+
```html
20+
<a href="..." aria-label="learn more"></a>
21+
```
22+
23+
```html
24+
<a href="..." aria-label="go-to-link"></a>
25+
```
26+
27+
### **Correct** code for this rule 👍
28+
29+
```html
30+
<a href="..." aria-label="Learn more"></a>
31+
```
32+
33+
```html
34+
<a href="..." aria-label="Homepage"></a>
35+
```
36+
37+
## Version

lib/configs/react.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ module.exports = {
99
extends: ['plugin:jsx-a11y/recommended'],
1010
rules: {
1111
'jsx-a11y/role-supports-aria-props': 'off', // Override with github/role-supports-aria-props until https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/issues/910 is resolved
12-
'github/a11y-aria-label-is-readable': 'error',
12+
'github/a11y-aria-label-is-well-formatted': 'error',
1313
'github/role-supports-aria-props': 'error',
1414
'jsx-a11y/no-aria-hidden-on-focusable': 'error',
1515
'jsx-a11y/anchor-ambiguous-text': [

lib/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module.exports = {
22
rules: {
33
'a11y-no-generic-link-text': require('./rules/a11y-no-generic-link-text'),
4-
'a11y-aria-label-is-readable': require('./rules/a11y-aria-label-is-readable'),
4+
'a11y-aria-label-is-well-formatted': require('./rules/a11y-aria-label-is-well-formatted'),
55
'array-foreach': require('./rules/array-foreach'),
66
'async-currenttarget': require('./rules/async-currenttarget'),
77
'async-preventdefault': require('./rules/async-preventdefault'),

tests/a11y-aria-label-is-readable.js renamed to tests/a11y-aria-label-is-well-formatted.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const rule = require('../lib/rules/a11y-aria-label-is-readable')
1+
const rule = require('../lib/rules/a11y-aria-label-is-well-formatted')
22
const RuleTester = require('eslint').RuleTester
33

44
const ruleTester = new RuleTester({
@@ -14,14 +14,12 @@ const ruleTester = new RuleTester({
1414
const errorMessage =
1515
'[aria-label] text should be formatted the same as you would visible text. Use sentence case and make sure you are not using hyphens.'
1616

17-
ruleTester.run('a11y-aria-label-is-readable', rule, {
17+
ruleTester.run('a11y-aria-label-is-well-formatted', rule, {
1818
valid: [
1919
{code: "<a aria-labelledby='someId' href='#'>Read more</a>;"},
2020
{code: "<a aria-label={someName} href='#'>Read more</a>;"},
2121
{code: "<a aria-label='This is a label'></a>;"},
22-
{
23-
code: '<Link as="button" href="#">Read more</Link>',
24-
},
22+
{code: '<Link aria-label="Valid" href="#">Read more</Link>'},
2523
],
2624
invalid: [
2725
{code: "<a aria-label='close modal'></a>;", errors: [{message: errorMessage}]},

0 commit comments

Comments
 (0)