-
Notifications
You must be signed in to change notification settings - Fork 173
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add button_has_type rule (#1350)
* feat: add button_has_type rule * fix: clippy * fix: update schemas * fix: update docs * typo Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com> * typo Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com> * message Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com> * chore: clean up indentation * update docs --------- Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
- Loading branch information
1 parent
b465b6a
commit c9b8aec
Showing
5 changed files
with
404 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
Checks that a `<button>` JSX element has a valid `type` attribute. The default | ||
value is `"submit"` which is often not the desired behavior. | ||
|
||
### Invalid: | ||
|
||
```tsx | ||
<button /> | ||
<button type="foo" /> | ||
<button type={condition ? "foo" : "bar"} /> | ||
<button type={foo} /> | ||
<button type={2} /> | ||
``` | ||
|
||
### Valid: | ||
|
||
```tsx | ||
<button type="submit" /> | ||
<button type="button" /> | ||
<button type="reset" /> | ||
<button type={condition ? "button" : "submit"} /> | ||
``` |
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
Oops, something went wrong.