From def8ceae07bd07784a80069cf4d1cd873c1f480c Mon Sep 17 00:00:00 2001 From: James Garbutt <43081j@users.noreply.github.com> Date: Wed, 19 Mar 2025 12:30:17 +0000 Subject: [PATCH] chore: update rule meta to satisfiy lint rules Updates a few things in rule meta so the linter is happy: - Some descriptions didn't follow the naming convention (`enforce`, `require`, etc) - Some rules had no `type`, so these were set to `problem` - Some rules had no `recommended`, so these were set to if they are in the recommended config or not - Message IDs have been used instead of messages --- README.md | 12 ++++++------ docs/rules/a11y-aria-label-is-well-formatted.md | 2 +- docs/rules/a11y-no-title-attribute.md | 2 +- ...11y-no-visually-hidden-interactive-element.md | 2 +- docs/rules/a11y-svg-has-accessible-name.md | 2 +- docs/rules/filenames-match-regex.md | 2 +- eslint.config.js | 1 + lib/rules/a11y-aria-label-is-well-formatted.js | 9 +++++++-- lib/rules/a11y-no-generic-link-text.js | 15 ++++++++++----- lib/rules/a11y-no-title-attribute.js | 9 +++++++-- ...11y-no-visually-hidden-interactive-element.js | 11 ++++++++--- lib/rules/a11y-role-supports-aria-props.js | 13 +++++++++++-- lib/rules/a11y-svg-has-accessible-name.js | 11 ++++++++--- lib/rules/array-foreach.js | 6 +++++- lib/rules/async-currenttarget.js | 6 +++++- lib/rules/async-preventdefault.js | 6 +++++- lib/rules/authenticity-token.js | 8 ++++++-- lib/rules/filenames-match-regex.js | 14 +++++++++++--- lib/rules/get-attribute.js | 6 +++++- lib/rules/js-class-name.js | 9 +++++++-- lib/rules/no-blur.js | 6 +++++- lib/rules/no-d-none.js | 6 +++++- lib/rules/no-dataset.js | 6 +++++- lib/rules/no-dynamic-script-tag.js | 8 ++++++-- lib/rules/no-implicit-buggy-globals.js | 9 ++++++++- lib/rules/no-inner-html.js | 6 +++++- lib/rules/no-innerText.js | 6 +++++- lib/rules/no-then.js | 16 ++++++++++++++-- lib/rules/no-useless-passive.js | 7 ++++++- lib/rules/prefer-observers.js | 7 ++++++- lib/rules/require-passive-events.js | 6 +++++- lib/rules/unescaped-html-literal.js | 9 ++++++--- 32 files changed, 183 insertions(+), 55 deletions(-) diff --git a/README.md b/README.md index baf32798..8c3bf397 100644 --- a/README.md +++ b/README.md @@ -117,17 +117,17 @@ This config will be interpreted in the following way: | Name                                        | Description | 💼 | 🔧 | ❌ | | :------------------------------------------------------------------------------------------------------- | :----------------------------------------------------------------------------------------------------------------------- | :- | :- | :- | -| [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. | ⚛️ | | | +| [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. | ⚛️ | | | | [a11y-no-generic-link-text](docs/rules/a11y-no-generic-link-text.md) | disallow generic link text | | | ❌ | -| [a11y-no-title-attribute](docs/rules/a11y-no-title-attribute.md) | Guards against developers using the title attribute | ⚛️ | | | -| [a11y-no-visually-hidden-interactive-element](docs/rules/a11y-no-visually-hidden-interactive-element.md) | Ensures that interactive elements are not visually hidden | ⚛️ | | | -| [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`. | ⚛️ | | | -| [a11y-svg-has-accessible-name](docs/rules/a11y-svg-has-accessible-name.md) | SVGs must have an accessible name | ⚛️ | | | +| [a11y-no-title-attribute](docs/rules/a11y-no-title-attribute.md) | disallow using the title attribute | ⚛️ | | | +| [a11y-no-visually-hidden-interactive-element](docs/rules/a11y-no-visually-hidden-interactive-element.md) | enforce that interactive elements are not visually hidden | ⚛️ | | | +| [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`. | ⚛️ | | | +| [a11y-svg-has-accessible-name](docs/rules/a11y-svg-has-accessible-name.md) | require SVGs to have an accessible name | ⚛️ | | | | [array-foreach](docs/rules/array-foreach.md) | enforce `for..of` loops over `Array.forEach` | ✅ | | | | [async-currenttarget](docs/rules/async-currenttarget.md) | disallow `event.currentTarget` calls inside of async functions | 🔍 | | | | [async-preventdefault](docs/rules/async-preventdefault.md) | disallow `event.preventDefault` calls inside of async functions | 🔍 | | | | [authenticity-token](docs/rules/authenticity-token.md) | disallow usage of CSRF tokens in JavaScript | 🔐 | | | -| [filenames-match-regex](docs/rules/filenames-match-regex.md) | ensure filenames match a regex naming convention | | | | +| [filenames-match-regex](docs/rules/filenames-match-regex.md) | require filenames to match a regex naming convention | | | | | [get-attribute](docs/rules/get-attribute.md) | disallow wrong usage of attribute names | 🔍 | 🔧 | | | [js-class-name](docs/rules/js-class-name.md) | enforce a naming convention for js- prefixed classes | 🔐 | | | | [no-blur](docs/rules/no-blur.md) | disallow usage of `Element.prototype.blur()` | 🔍 | | | diff --git a/docs/rules/a11y-aria-label-is-well-formatted.md b/docs/rules/a11y-aria-label-is-well-formatted.md index 9c2f164a..a833c6ed 100644 --- a/docs/rules/a11y-aria-label-is-well-formatted.md +++ b/docs/rules/a11y-aria-label-is-well-formatted.md @@ -1,4 +1,4 @@ -# [aria-label] text should be formatted as you would visual text (`github/a11y-aria-label-is-well-formatted`) +# Enforce [aria-label] text to be formatted as you would visual text (`github/a11y-aria-label-is-well-formatted`) 💼 This rule is enabled in the ⚛️ `react` config. diff --git a/docs/rules/a11y-no-title-attribute.md b/docs/rules/a11y-no-title-attribute.md index 29b382d1..1c0006ba 100644 --- a/docs/rules/a11y-no-title-attribute.md +++ b/docs/rules/a11y-no-title-attribute.md @@ -1,4 +1,4 @@ -# Guards against developers using the title attribute (`github/a11y-no-title-attribute`) +# Disallow using the title attribute (`github/a11y-no-title-attribute`) 💼 This rule is enabled in the ⚛️ `react` config. diff --git a/docs/rules/a11y-no-visually-hidden-interactive-element.md b/docs/rules/a11y-no-visually-hidden-interactive-element.md index 52fdbc12..f5518982 100644 --- a/docs/rules/a11y-no-visually-hidden-interactive-element.md +++ b/docs/rules/a11y-no-visually-hidden-interactive-element.md @@ -1,4 +1,4 @@ -# Ensures that interactive elements are not visually hidden (`github/a11y-no-visually-hidden-interactive-element`) +# Enforce that interactive elements are not visually hidden (`github/a11y-no-visually-hidden-interactive-element`) 💼 This rule is enabled in the ⚛️ `react` config. diff --git a/docs/rules/a11y-svg-has-accessible-name.md b/docs/rules/a11y-svg-has-accessible-name.md index 088e918b..000d05c4 100644 --- a/docs/rules/a11y-svg-has-accessible-name.md +++ b/docs/rules/a11y-svg-has-accessible-name.md @@ -1,4 +1,4 @@ -# SVGs must have an accessible name (`github/a11y-svg-has-accessible-name`) +# Require SVGs to have an accessible name (`github/a11y-svg-has-accessible-name`) 💼 This rule is enabled in the ⚛️ `react` config. diff --git a/docs/rules/filenames-match-regex.md b/docs/rules/filenames-match-regex.md index 4d153880..586e9acd 100644 --- a/docs/rules/filenames-match-regex.md +++ b/docs/rules/filenames-match-regex.md @@ -1,4 +1,4 @@ -# Ensure filenames match a regex naming convention (`github/filenames-match-regex`) +# Require filenames to match a regex naming convention (`github/filenames-match-regex`) diff --git a/eslint.config.js b/eslint.config.js index 94e32e6d..19699bd4 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -32,6 +32,7 @@ module.exports = [ 'eslint-plugin/prefer-placeholders': 'off', 'eslint-plugin/test-case-shorthand-strings': 'off', 'eslint-plugin/require-meta-docs-url': 'off', + 'eslint-plugin/require-meta-default-options': 'off', }, }, ] diff --git a/lib/rules/a11y-aria-label-is-well-formatted.js b/lib/rules/a11y-aria-label-is-well-formatted.js index 3e9ace86..22061550 100644 --- a/lib/rules/a11y-aria-label-is-well-formatted.js +++ b/lib/rules/a11y-aria-label-is-well-formatted.js @@ -2,11 +2,16 @@ const {getProp} = require('jsx-ast-utils') module.exports = { meta: { + type: 'problem', docs: { - description: '[aria-label] text should be formatted as you would visual text.', + description: 'enforce [aria-label] text to be formatted as you would visual text.', url: require('../url')(module), + recommended: false, }, schema: [], + messages: { + formatting: '[aria-label] text should be formatted the same as you would visual text. Use sentence case.', + }, }, create(context) { @@ -22,7 +27,7 @@ module.exports = { if (ariaLabel.match(/^[a-z]+.*$/)) { context.report({ node, - message: '[aria-label] text should be formatted the same as you would visual text. Use sentence case.', + messageId: 'formatting', }) } }, diff --git a/lib/rules/a11y-no-generic-link-text.js b/lib/rules/a11y-no-generic-link-text.js index 93277949..54377f0d 100644 --- a/lib/rules/a11y-no-generic-link-text.js +++ b/lib/rules/a11y-no-generic-link-text.js @@ -14,13 +14,20 @@ const stripAndDowncaseText = text => { module.exports = { meta: { + type: 'problem', docs: { description: 'disallow generic link text', url: require('../url')(module), + recommended: false, }, deprecated: true, replacedBy: ['jsx-a11y/anchor-ambiguous-text'], schema: [], + messages: { + avoidGenericLinkText: + 'Avoid setting generic link text like `Here`, `Click here`, `Read more`. Make sure that your link text is both descriptive and concise.', + ariaLabelDescriptive: 'When using ARIA to set a more descriptive text, it must fully contain the visible label.', + }, }, create(context) { @@ -47,14 +54,13 @@ module.exports = { if (bannedLinkText.includes(cleanAriaLabelValue)) { context.report({ node, - message: - 'Avoid setting generic link text like `Here`, `Click here`, `Read more`. Make sure that your link text is both descriptive and concise.', + messageId: 'avoidGenericLinkText', }) } if (cleanTextContent && !cleanAriaLabelValue.includes(cleanTextContent)) { context.report({ node, - message: 'When using ARIA to set a more descriptive text, it must fully contain the visible label.', + messageId: 'ariaLabelDescriptive', }) } } else { @@ -62,8 +68,7 @@ module.exports = { if (!bannedLinkText.includes(cleanTextContent)) return context.report({ node: jsxTextNode, - message: - 'Avoid setting generic link text like `Here`, `Click here`, `Read more`. Make sure that your link text is both descriptive and concise.', + messageId: 'avoidGenericLinkText', }) } } diff --git a/lib/rules/a11y-no-title-attribute.js b/lib/rules/a11y-no-title-attribute.js index cc3ec1d0..5d758e44 100644 --- a/lib/rules/a11y-no-title-attribute.js +++ b/lib/rules/a11y-no-title-attribute.js @@ -40,11 +40,16 @@ const ifSemanticElement = (context, node) => { module.exports = { meta: { + type: 'problem', docs: { - description: 'Guards against developers using the title attribute', + description: 'disallow using the title attribute', url: require('../url')(module), + recommended: false, }, schema: [], + messages: { + titleAttribute: 'The title attribute is not accessible and should never be used unless for an `