Skip to content

Commit

Permalink
Add no-action-on-submit-button rule documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Joao committed Aug 13, 2021
1 parent ed5a054 commit 0bbe945
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ Each rule has emojis denoting:
| [no-accesskey-attribute](./docs/rule/no-accesskey-attribute.md) || | ⌨️ | 🔧 |
| [no-action](./docs/rule/no-action.md) || | | |
| [no-action-modifiers](./docs/rule/no-action-modifiers.md) | | | | |
| [no-action-on-submit-button](./docs/rule/no-action-on-submit-button.md) | | | | |
| [no-args-paths](./docs/rule/no-args-paths.md) || | | |
| [no-arguments-for-html-elements](./docs/rule/no-arguments-for-html-elements.md) || | | |
| [no-aria-hidden-body](./docs/rule/no-aria-hidden-body.md) || | ⌨️ | 🔧 |
Expand Down
35 changes: 35 additions & 0 deletions docs/rule/no-action-on-submit-button.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# no-action-on-submit-button

This rule requires all `<button>` elements with a `type="submit"` attribute to not have any action.

When the `type` attribute of `<button>` elements is `submit`, the action should be on the `<form>` element instead of directly on the button.

By default, the `type` attribute of `<button>` elements is `submit`.

## Examples

This rule **forbids** the following:

```hbs
<button type="submit" {{on "click" "handleClick"}} />
<button type="submit" {{action "handleClick"}} />
<button {{on "click" "handleClick"}} />
<button {{action "handleClick"}} />
```

This rule **allows** the following:

```hbs
<button type="button" {{on "click" "handleClick"}} />
<button type="button" {{action "handleClick"}} />
<button type="submit" />
<button />
```

## Related Rules

- [require-button-type](require-button-type.md)

## References

- Red [HTML spec - the button element](https://html.spec.whatwg.org/multipage/form-elements.html#attr-button-type)

0 comments on commit 0bbe945

Please sign in to comment.