-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
950e2ac
commit a9824d1
Showing
4 changed files
with
48 additions
and
3 deletions.
There are no files selected for viewing
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
45 changes: 45 additions & 0 deletions
45
packages/eslint-plugin/docs/rules/no-base-control-with-label-without-id.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,45 @@ | ||
# Disallow the usage of BaseControl component with a label prop set but omitting the id property (no-base-control-with-label-without-id) | ||
|
||
Base control component ideally should be used together with components providing user input. The label the BaseControl component receives, should be associated with some component providing user via an id attribute. | ||
If a label is provided but the id is omitted it means that the developer missed the id prop or that BaseControl is not a good fit for the use case and a div together with a span can provide the same functionality. | ||
|
||
## Rule details | ||
|
||
Examples of **incorrect** code for this rule: | ||
|
||
```jsx | ||
<BaseControl | ||
label="ok" | ||
> | ||
<b>Child</b> | ||
</BaseControl> | ||
``` | ||
|
||
|
||
```jsx | ||
<BaseControl label="ok" /> | ||
``` | ||
|
||
Examples of **correct** code for this rule: | ||
|
||
|
||
```jsx | ||
<BaseControl /> | ||
``` | ||
|
||
```jsx | ||
<BaseControl | ||
id="my-id" | ||
> | ||
<b>Child</b> | ||
</BaseControl> | ||
``` | ||
|
||
```jsx | ||
<BaseControl | ||
label="ok" | ||
id="my-id" | ||
> | ||
<b>Child</b> | ||
</BaseControl> | ||
``` |
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