コンテンツにスキップ

noAutofocus

このコンテンツはまだ日本語訳がありません。

Diagnostic Category: lint/a11y/noAutofocus

Since: v1.0.0

Sources:

Enforce that autoFocus prop is not used on elements.

Autofocusing elements can cause usability issues for sighted and non-sighted users, alike.

<input autoFocus />
code-block.jsx:1:8 lint/a11y/noAutofocus  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Avoid the autoFocus attribute.

> 1 │ <input autoFocus />
^^^^^^^^^
2 │

Unsafe fix: Remove the autoFocus attribute.

1 │ <input·autoFocus·/>
----------
<input autoFocus="true" />
code-block.jsx:1:8 lint/a11y/noAutofocus  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Avoid the autoFocus attribute.

> 1 │ <input autoFocus=“true” />
^^^^^^^^^^^^^^^^
2 │

Unsafe fix: Remove the autoFocus attribute.

1 │ <input·autoFocus=true·/>
-----------------
<input autoFocus={"false"} />
code-block.jsx:1:8 lint/a11y/noAutofocus  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Avoid the autoFocus attribute.

> 1 │ <input autoFocus={“false”} />
^^^^^^^^^^^^^^^^^^^
2 │

Unsafe fix: Remove the autoFocus attribute.

1 │ <input·autoFocus={false}·/>
--------------------
<input autoFocus={undefined} />
code-block.jsx:1:8 lint/a11y/noAutofocus  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Avoid the autoFocus attribute.

> 1 │ <input autoFocus={undefined} />
^^^^^^^^^^^^^^^^^^^^^
2 │

Unsafe fix: Remove the autoFocus attribute.

1 │ <input·autoFocus={undefined}·/>
----------------------
<input />
<div />
<button />
// `autoFocus` prop in user created component is valid
<MyComponent autoFocus={true} />