From 91e39b45ade789c86ae14df869a86b0ea468ed95 Mon Sep 17 00:00:00 2001 From: michael faith Date: Wed, 25 Dec 2024 15:11:08 -0600 Subject: [PATCH] [patch] `no-autofocus`: don't report error if autoFocus is set to false This change adjusts the error condition for `no-autofocus` to allow for manually disabling `autoFocus`. Now, any usage of `autoFocus="false"` or `autoFocus={false}` will not report. --- README.md | 2 +- __tests__/src/rules/no-autofocus-test.js | 6 +++--- docs/rules/no-autofocus.md | 4 ++-- src/rules/no-autofocus.js | 10 +++++----- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 494a57841..3ec1ecaf3 100644 --- a/README.md +++ b/README.md @@ -263,7 +263,7 @@ To restrict polymorphic linting to specified components, additionally set `polym | [mouse-events-have-key-events](docs/rules/mouse-events-have-key-events.md) | Enforce that `onMouseOver`/`onMouseOut` are accompanied by `onFocus`/`onBlur` for keyboard-only users. | ☑️ 🔒 | | | | | [no-access-key](docs/rules/no-access-key.md) | Enforce that the `accessKey` prop is not used on any element to avoid complications with keyboard commands used by a screen reader. | ☑️ 🔒 | | | | | [no-aria-hidden-on-focusable](docs/rules/no-aria-hidden-on-focusable.md) | Disallow `aria-hidden="true"` from being set on focusable elements. | | | | | -| [no-autofocus](docs/rules/no-autofocus.md) | Enforce autoFocus prop is not used. | ☑️ 🔒 | | | | +| [no-autofocus](docs/rules/no-autofocus.md) | Enforce autoFocus prop is not enabled. | ☑️ 🔒 | | | | | [no-distracting-elements](docs/rules/no-distracting-elements.md) | Enforce distracting elements are not used. | ☑️ 🔒 | | | | | [no-interactive-element-to-noninteractive-role](docs/rules/no-interactive-element-to-noninteractive-role.md) | Interactive elements should not be assigned non-interactive roles. | ☑️ 🔒 | | | | | [no-noninteractive-element-interactions](docs/rules/no-noninteractive-element-interactions.md) | Non-interactive elements should not be assigned mouse or keyboard event listeners. | ☑️ 🔒 | | | | diff --git a/__tests__/src/rules/no-autofocus-test.js b/__tests__/src/rules/no-autofocus-test.js index 13bddc724..5bdcfb595 100644 --- a/__tests__/src/rules/no-autofocus-test.js +++ b/__tests__/src/rules/no-autofocus-test.js @@ -19,7 +19,7 @@ import rule from '../../../src/rules/no-autofocus'; const ruleTester = new RuleTester(); const expectedError = { - message: 'The autoFocus prop should not be used, as it can reduce usability and accessibility for users.', + message: 'The autoFocus prop should not be enabled, as it can reduce usability and accessibility for users.', type: 'JSXAttribute', }; @@ -43,6 +43,8 @@ ruleTester.run('no-autofocus', rule, { { code: '
;' }, { code: ';' }, { code: '' }, + { code: '
' }, + { code: '
' }, { code: '', options: ignoreNonDOMSchema }, { code: '
', options: ignoreNonDOMSchema }, { code: '