Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit da91d7d

Browse filesBrowse files
authored
docs(eslint-plugin): add rationale for button-has-type rule (#2527)
1 parent 315c24a commit da91d7d
Copy full SHA for da91d7d

File tree

Expand file treeCollapse file tree

2 files changed

+11
-0
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+11
-0
lines changed

‎packages/eslint-plugin-template/docs/rules/button-has-type.md

Copy file name to clipboardExpand all lines: packages/eslint-plugin-template/docs/rules/button-has-type.md
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ Ensures that a button has a valid type specified
2121

2222
<br>
2323

24+
## Rationale
25+
26+
Buttons default to `type="submit"` when no type is specified. If placed inside a form, the button triggers a form submission on click. Enforcing the type attribute clarifies the code's intent and prevents unintended form submissions.
27+
28+
<br>
29+
2430
## Rule Options
2531

2632
The rule accepts an options object with the following properties:

‎packages/eslint-plugin-template/src/rules/button-has-type.ts

Copy file name to clipboardExpand all lines: packages/eslint-plugin-template/src/rules/button-has-type.ts
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,11 @@ export default createESLintRule<Options, MessageIds>({
9292
},
9393
});
9494

95+
export const RULE_DOCS_EXTENSION = {
96+
rationale:
97+
'Buttons default to `type="submit"` when no type is specified. If placed inside a form, the button triggers a form submission on click. Enforcing the type attribute clarifies the code\'s intent and prevents unintended form submissions.',
98+
};
99+
95100
function isTypeAttributePresentInElement({
96101
inputs,
97102
attributes,

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.