-
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
489c6f7
commit 6903867
Showing
9 changed files
with
61 additions
and
13 deletions.
There are no files selected for viewing
Submodule oxc
added at
bb995f
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
src/docs/guide/usage/linter/rules/jsx_a11y/label-has-associated-control.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<!-- This file is auto-generated by tasks/website/src/linter/rules/doc_page.rs. Do not edit it manually. --> | ||
|
||
# jsx_a11y/label-has-associated-control <Badge type="info" text="Correctness" /> | ||
|
||
<div class="rule-meta"> | ||
</div> | ||
|
||
### What it does | ||
|
||
Enforce that a label tag has a text label and an associated control. | ||
|
||
### Why is this bad? | ||
|
||
A form label that either isn't properly associated with a form control (such as an `<input>`), or doesn't contain accessible text, hinders accessibility for users using assistive technologies such as screen readers. The user may not have enough information to understand the purpose of the form control. | ||
|
||
### Examples | ||
|
||
Examples of **incorrect** code for this rule: | ||
|
||
```jsx | ||
function Foo(props) { | ||
return <label {...props} /> | ||
} | ||
|
||
<input type="text" /> | ||
<label>Surname</label> | ||
``` | ||
|
||
Examples of **correct** code for this rule: | ||
|
||
```jsx | ||
function Foo(props) { | ||
const { htmlFor, ...otherProps } = props; | ||
|
||
return <label htmlFor={htmlFor} {...otherProps} />; | ||
} | ||
|
||
<label> | ||
<input type="text" /> | ||
Surname | ||
</label>; | ||
``` | ||
|
||
## References | ||
|
||
- [Rule Source](https://github.com/oxc-project/oxc/blob/main/crates/oxc_linter/src/rules/jsx_a11y/label_has_associated_control.rs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters