Skip to content

Commit 88ccca2

Browse files
authored
Merge pull request #621 from 43081j/meta-lints
chore: update rule meta to satisfiy lint rules
2 parents 4832156 + def8cea commit 88ccca2

32 files changed

+183
-55
lines changed

README.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -117,17 +117,17 @@ This config will be interpreted in the following way:
117117

118118
| Name                                        | Description | 💼 | 🔧 ||
119119
| :------------------------------------------------------------------------------------------------------- | :----------------------------------------------------------------------------------------------------------------------- | :- | :- | :- |
120-
| [a11y-aria-label-is-well-formatted](docs/rules/a11y-aria-label-is-well-formatted.md) | [aria-label] text should be formatted as you would visual text. | ⚛️ | | |
120+
| [a11y-aria-label-is-well-formatted](docs/rules/a11y-aria-label-is-well-formatted.md) | enforce [aria-label] text to be formatted as you would visual text. | ⚛️ | | |
121121
| [a11y-no-generic-link-text](docs/rules/a11y-no-generic-link-text.md) | disallow generic link text | | ||
122-
| [a11y-no-title-attribute](docs/rules/a11y-no-title-attribute.md) | Guards against developers using the title attribute | ⚛️ | | |
123-
| [a11y-no-visually-hidden-interactive-element](docs/rules/a11y-no-visually-hidden-interactive-element.md) | Ensures that interactive elements are not visually hidden | ⚛️ | | |
124-
| [a11y-role-supports-aria-props](docs/rules/a11y-role-supports-aria-props.md) | Enforce that elements with explicit or implicit roles defined contain only `aria-*` properties supported by that `role`. | ⚛️ | | |
125-
| [a11y-svg-has-accessible-name](docs/rules/a11y-svg-has-accessible-name.md) | SVGs must have an accessible name | ⚛️ | | |
122+
| [a11y-no-title-attribute](docs/rules/a11y-no-title-attribute.md) | disallow using the title attribute | ⚛️ | | |
123+
| [a11y-no-visually-hidden-interactive-element](docs/rules/a11y-no-visually-hidden-interactive-element.md) | enforce that interactive elements are not visually hidden | ⚛️ | | |
124+
| [a11y-role-supports-aria-props](docs/rules/a11y-role-supports-aria-props.md) | enforce that elements with explicit or implicit roles defined contain only `aria-*` properties supported by that `role`. | ⚛️ | | |
125+
| [a11y-svg-has-accessible-name](docs/rules/a11y-svg-has-accessible-name.md) | require SVGs to have an accessible name | ⚛️ | | |
126126
| [array-foreach](docs/rules/array-foreach.md) | enforce `for..of` loops over `Array.forEach` || | |
127127
| [async-currenttarget](docs/rules/async-currenttarget.md) | disallow `event.currentTarget` calls inside of async functions | 🔍 | | |
128128
| [async-preventdefault](docs/rules/async-preventdefault.md) | disallow `event.preventDefault` calls inside of async functions | 🔍 | | |
129129
| [authenticity-token](docs/rules/authenticity-token.md) | disallow usage of CSRF tokens in JavaScript | 🔐 | | |
130-
| [filenames-match-regex](docs/rules/filenames-match-regex.md) | ensure filenames match a regex naming convention | | | |
130+
| [filenames-match-regex](docs/rules/filenames-match-regex.md) | require filenames to match a regex naming convention | | | |
131131
| [get-attribute](docs/rules/get-attribute.md) | disallow wrong usage of attribute names | 🔍 | 🔧 | |
132132
| [js-class-name](docs/rules/js-class-name.md) | enforce a naming convention for js- prefixed classes | 🔐 | | |
133133
| [no-blur](docs/rules/no-blur.md) | disallow usage of `Element.prototype.blur()` | 🔍 | | |

docs/rules/a11y-aria-label-is-well-formatted.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# [aria-label] text should be formatted as you would visual text (`github/a11y-aria-label-is-well-formatted`)
1+
# Enforce [aria-label] text to be formatted as you would visual text (`github/a11y-aria-label-is-well-formatted`)
22

33
💼 This rule is enabled in the ⚛️ `react` config.
44

docs/rules/a11y-no-title-attribute.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Guards against developers using the title attribute (`github/a11y-no-title-attribute`)
1+
# Disallow using the title attribute (`github/a11y-no-title-attribute`)
22

33
💼 This rule is enabled in the ⚛️ `react` config.
44

docs/rules/a11y-no-visually-hidden-interactive-element.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Ensures that interactive elements are not visually hidden (`github/a11y-no-visually-hidden-interactive-element`)
1+
# Enforce that interactive elements are not visually hidden (`github/a11y-no-visually-hidden-interactive-element`)
22

33
💼 This rule is enabled in the ⚛️ `react` config.
44

docs/rules/a11y-svg-has-accessible-name.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# SVGs must have an accessible name (`github/a11y-svg-has-accessible-name`)
1+
# Require SVGs to have an accessible name (`github/a11y-svg-has-accessible-name`)
22

33
💼 This rule is enabled in the ⚛️ `react` config.
44

docs/rules/filenames-match-regex.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Ensure filenames match a regex naming convention (`github/filenames-match-regex`)
1+
# Require filenames to match a regex naming convention (`github/filenames-match-regex`)
22

33
<!-- end auto-generated rule header -->
44

eslint.config.js

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ module.exports = [
3232
'eslint-plugin/prefer-placeholders': 'off',
3333
'eslint-plugin/test-case-shorthand-strings': 'off',
3434
'eslint-plugin/require-meta-docs-url': 'off',
35+
'eslint-plugin/require-meta-default-options': 'off',
3536
},
3637
},
3738
]

lib/rules/a11y-aria-label-is-well-formatted.js

+7-2
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,16 @@ const {getProp} = require('jsx-ast-utils')
22

33
module.exports = {
44
meta: {
5+
type: 'problem',
56
docs: {
6-
description: '[aria-label] text should be formatted as you would visual text.',
7+
description: 'enforce [aria-label] text to be formatted as you would visual text.',
78
url: require('../url')(module),
9+
recommended: false,
810
},
911
schema: [],
12+
messages: {
13+
formatting: '[aria-label] text should be formatted the same as you would visual text. Use sentence case.',
14+
},
1015
},
1116

1217
create(context) {
@@ -22,7 +27,7 @@ module.exports = {
2227
if (ariaLabel.match(/^[a-z]+.*$/)) {
2328
context.report({
2429
node,
25-
message: '[aria-label] text should be formatted the same as you would visual text. Use sentence case.',
30+
messageId: 'formatting',
2631
})
2732
}
2833
},

lib/rules/a11y-no-generic-link-text.js

+10-5
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,20 @@ const stripAndDowncaseText = text => {
1414

1515
module.exports = {
1616
meta: {
17+
type: 'problem',
1718
docs: {
1819
description: 'disallow generic link text',
1920
url: require('../url')(module),
21+
recommended: false,
2022
},
2123
deprecated: true,
2224
replacedBy: ['jsx-a11y/anchor-ambiguous-text'],
2325
schema: [],
26+
messages: {
27+
avoidGenericLinkText:
28+
'Avoid setting generic link text like `Here`, `Click here`, `Read more`. Make sure that your link text is both descriptive and concise.',
29+
ariaLabelDescriptive: 'When using ARIA to set a more descriptive text, it must fully contain the visible label.',
30+
},
2431
},
2532

2633
create(context) {
@@ -47,23 +54,21 @@ module.exports = {
4754
if (bannedLinkText.includes(cleanAriaLabelValue)) {
4855
context.report({
4956
node,
50-
message:
51-
'Avoid setting generic link text like `Here`, `Click here`, `Read more`. Make sure that your link text is both descriptive and concise.',
57+
messageId: 'avoidGenericLinkText',
5258
})
5359
}
5460
if (cleanTextContent && !cleanAriaLabelValue.includes(cleanTextContent)) {
5561
context.report({
5662
node,
57-
message: 'When using ARIA to set a more descriptive text, it must fully contain the visible label.',
63+
messageId: 'ariaLabelDescriptive',
5864
})
5965
}
6066
} else {
6167
if (cleanTextContent) {
6268
if (!bannedLinkText.includes(cleanTextContent)) return
6369
context.report({
6470
node: jsxTextNode,
65-
message:
66-
'Avoid setting generic link text like `Here`, `Click here`, `Read more`. Make sure that your link text is both descriptive and concise.',
71+
messageId: 'avoidGenericLinkText',
6772
})
6873
}
6974
}

lib/rules/a11y-no-title-attribute.js

+7-2
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,16 @@ const ifSemanticElement = (context, node) => {
4040

4141
module.exports = {
4242
meta: {
43+
type: 'problem',
4344
docs: {
44-
description: 'Guards against developers using the title attribute',
45+
description: 'disallow using the title attribute',
4546
url: require('../url')(module),
47+
recommended: false,
4648
},
4749
schema: [],
50+
messages: {
51+
titleAttribute: 'The title attribute is not accessible and should never be used unless for an `<iframe>`.',
52+
},
4853
},
4954

5055
create(context) {
@@ -56,7 +61,7 @@ module.exports = {
5661
if (titleProp) {
5762
context.report({
5863
node,
59-
message: 'The title attribute is not accessible and should never be used unless for an `<iframe>`.',
64+
messageId: 'titleAttribute',
6065
})
6166
}
6267
}

lib/rules/a11y-no-visually-hidden-interactive-element.js

+8-3
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,17 @@ const checkIfVisuallyHiddenAndInteractive = (context, options, node, isParentVis
5757

5858
module.exports = {
5959
meta: {
60+
type: 'problem',
6061
docs: {
61-
description: 'Ensures that interactive elements are not visually hidden',
62+
description: 'enforce that interactive elements are not visually hidden',
6263
url: require('../url')(module),
64+
recommended: false,
6365
},
6466
schema: [schema],
67+
messages: {
68+
avoid:
69+
'Avoid visually hidding interactive elements. Visually hiding interactive elements can be confusing to sighted keyboard users as it appears their focus has been lost when they navigate to the hidden element.',
70+
},
6571
},
6672

6773
create(context) {
@@ -75,8 +81,7 @@ module.exports = {
7581
if (checkIfVisuallyHiddenAndInteractive(context, {className, componentName}, node, false)) {
7682
context.report({
7783
node,
78-
message:
79-
'Avoid visually hidding interactive elements. Visually hiding interactive elements can be confusing to sighted keyboard users as it appears their focus has been lost when they navigate to the hidden element.',
84+
messageId: 'avoid',
8085
})
8186
}
8287
},

lib/rules/a11y-role-supports-aria-props.js

+11-2
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,17 @@ const {getRole} = require('../utils/get-role')
55

66
module.exports = {
77
meta: {
8+
type: 'problem',
89
docs: {
910
description:
10-
'Enforce that elements with explicit or implicit roles defined contain only `aria-*` properties supported by that `role`.',
11+
'enforce that elements with explicit or implicit roles defined contain only `aria-*` properties supported by that `role`.',
1112
url: require('../url')(module),
13+
recommended: false,
1214
},
1315
schema: [],
16+
messages: {
17+
notSupported: 'The attribute {{attr}} is not supported by the role {{role}}.',
18+
},
1419
},
1520

1621
create(context) {
@@ -51,7 +56,11 @@ module.exports = {
5156
if (prohibitedProps?.includes(propName(prop))) {
5257
context.report({
5358
node,
54-
message: `The attribute ${propName(prop)} is not supported by the role ${role}.`,
59+
messageId: 'notSupported',
60+
data: {
61+
attr: propName(prop),
62+
role,
63+
},
5564
})
5665
}
5766
}

lib/rules/a11y-svg-has-accessible-name.js

+8-3
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,17 @@ const {getElementType} = require('../utils/get-element-type')
33

44
module.exports = {
55
meta: {
6+
type: 'problem',
67
docs: {
7-
description: 'SVGs must have an accessible name',
8+
description: 'require SVGs to have an accessible name',
89
url: require('../url')(module),
10+
recommended: false,
911
},
1012
schema: [],
13+
messages: {
14+
accessibleName:
15+
'`<svg>` must have an accessible name. Set `aria-label` or `aria-labelledby`, or nest a `<title>` element. However, if the `<svg>` is purely decorative, hide it with `aria-hidden="true"` or `role="presentation"`.',
16+
},
1117
},
1218

1319
create(context) {
@@ -35,8 +41,7 @@ module.exports = {
3541
if (elementType === 'svg' && !hasAccessibleName && !isDecorative && !hasNestedTitleAsFirstChild) {
3642
context.report({
3743
node,
38-
message:
39-
'`<svg>` must have an accessible name. Set `aria-label` or `aria-labelledby`, or nest a `<title>` element. However, if the `<svg>` is purely decorative, hide it with `aria-hidden="true"` or `role="presentation"`.',
44+
messageId: 'accessibleName',
4045
})
4146
}
4247
},

lib/rules/array-foreach.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,19 @@ module.exports = {
44
docs: {
55
description: 'enforce `for..of` loops over `Array.forEach`',
66
url: require('../url')(module),
7+
recommended: true,
78
},
89
schema: [],
10+
messages: {
11+
preferForOf: 'Prefer for...of instead of Array.forEach',
12+
},
913
},
1014

1115
create(context) {
1216
return {
1317
CallExpression(node) {
1418
if (node.callee.property && node.callee.property.name === 'forEach') {
15-
context.report({node, message: 'Prefer for...of instead of Array.forEach'})
19+
context.report({node, messageId: 'preferForOf'})
1620
}
1721
},
1822
}

lib/rules/async-currenttarget.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,12 @@ module.exports = {
44
docs: {
55
description: 'disallow `event.currentTarget` calls inside of async functions',
66
url: require('../url')(module),
7+
recommended: false,
78
},
89
schema: [],
10+
messages: {
11+
asyncCurrentTarget: 'event.currentTarget inside an async function is error prone',
12+
},
913
},
1014

1115
create(context) {
@@ -23,7 +27,7 @@ module.exports = {
2327
if (scopeDidWait.has(scope)) {
2428
context.report({
2529
node,
26-
message: 'event.currentTarget inside an async function is error prone',
30+
messageId: 'asyncCurrentTarget',
2731
})
2832
break
2933
}

lib/rules/async-preventdefault.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,12 @@ module.exports = {
44
docs: {
55
description: 'disallow `event.preventDefault` calls inside of async functions',
66
url: require('../url')(module),
7+
recommended: false,
78
},
89
schema: [],
10+
messages: {
11+
eventPreventDefault: 'event.preventDefault() inside an async function is error prone',
12+
},
913
},
1014

1115
create(context) {
@@ -23,7 +27,7 @@ module.exports = {
2327
if (scopeDidWait.has(scope)) {
2428
context.report({
2529
node,
26-
message: 'event.preventDefault() inside an async function is error prone',
30+
messageId: 'eventPreventDefault',
2731
})
2832
break
2933
}

lib/rules/authenticity-token.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,21 @@ module.exports = {
44
docs: {
55
description: 'disallow usage of CSRF tokens in JavaScript',
66
url: require('../url')(module),
7+
recommended: false,
78
},
89
schema: [],
10+
messages: {
11+
authenticityTokenUsage:
12+
'Form CSRF tokens (authenticity tokens) should not be created in JavaScript and their values should not be used directly for XHR requests.',
13+
},
914
},
1015

1116
create(context) {
1217
function checkAuthenticityTokenUsage(node, str) {
1318
if (str.includes('authenticity_token')) {
1419
context.report({
1520
node,
16-
message:
17-
'Form CSRF tokens (authenticity tokens) should not be created in JavaScript and their values should not be used directly for XHR requests.',
21+
messageId: 'authenticityTokenUsage',
1822
})
1923
}
2024
}

lib/rules/filenames-match-regex.js

+11-3
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ module.exports = {
99
meta: {
1010
type: 'problem',
1111
docs: {
12-
description: 'ensure filenames match a regex naming convention',
12+
description: 'require filenames to match a regex naming convention',
1313
url: require('../url')(module),
14+
recommended: true,
1415
},
1516
schema: {
1617
type: 'array',
@@ -22,6 +23,9 @@ module.exports = {
2223
},
2324
],
2425
},
26+
messages: {
27+
regex: "Filename '{{name}}' does not match the regex naming convention.",
28+
},
2529
},
2630

2731
create(context) {
@@ -42,8 +46,12 @@ module.exports = {
4246
if (shouldIgnore) return
4347
if (ignoreExporting && isExporting) return
4448
if (!matchesRegex) {
45-
context.report(node, "Filename '{{name}}' does not match the regex naming convention.", {
46-
name: parsed.base,
49+
context.report({
50+
node,
51+
messageId: 'regex',
52+
data: {
53+
name: parsed.base,
54+
},
4755
})
4856
}
4957
},

0 commit comments

Comments
 (0)