Add template-require-input-type: reject invalid input types; opt-in requireExplicit#40
Add template-require-input-type: reject invalid input types; opt-in requireExplicit#40
template-require-input-type: reject invalid input types; opt-in requireExplicit#40Conversation
🏎️ Benchmark Comparison
Full mitata output |
There was a problem hiding this comment.
Pull request overview
Adds a new Ember template lint rule to prevent silent <input type="..."> fallback-to-text bugs by validating static type values against the HTML-defined set, with an optional requireExplicit: true mode to enforce explicit type attributes.
Changes:
- Introduces
template-require-input-typerule with autofix totype="text"for invalid/missing types (when opted-in). - Adds comprehensive RuleTester coverage for both
.hbsand.gjsparsing modes. - Documents the new rule and links it from the README rule table.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
lib/rules/template-require-input-type.js |
Implements the new rule, including requireExplicit option and autofixes. |
tests/lib/rules/template-require-input-type.js |
Adds test coverage for valid/invalid cases and both configuration modes across hbs/gjs. |
docs/rules/template-require-input-type.md |
Documents rule purpose, examples, configuration, and references. |
README.md |
Adds the rule to the documented rules list. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Adds a new Ember template ESLint rule to prevent silent fallback bugs from invalid <input type="..."> values, with an optional mode to require explicit type for consistency.
Changes:
- Introduces
template-require-input-typerule to validate static<input type="...">values against the HTML-defined set and auto-fix invalids totype="text". - Adds an opt-in
requireExplicit: trueoption to flag/fix<input>elements missing a statictype. - Adds documentation, tests, and README rule index entry for the new rule.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| lib/rules/template-require-input-type.js | Implements the new rule, including autofix and requireExplicit option. |
| tests/lib/rules/template-require-input-type.js | Adds HBS/GJS test coverage for valid/invalid types and requireExplicit behavior. |
| docs/rules/template-require-input-type.md | Documents the rule behavior, configuration, and examples. |
| README.md | Adds the new rule to the rules table. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
b22fa4c to
3790db6
Compare
There was a problem hiding this comment.
Pull request overview
Adds a new template lint rule to prevent silent fallback-to-text bugs from invalid <input type="..."> values, with an opt-in mode to require explicit type attributes for consistency.
Changes:
- Introduces
template-require-input-typerule with autofix totype="text"for invalid/missing statictype. - Adds
isNativeElementutility to distinguish native elements vs scope-shadowed component invocations in GJS/GTS. - Adds rule documentation, test coverage (HBS + GJS), and README rule index entry.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tests/lib/rules/template-require-input-type.js | Adds HBS/GJS RuleTester coverage for invalid types and optional requireExplicit behavior. |
| lib/utils/is-native-element.js | Adds shared native-element detection utility with optional scope-shadowing check. |
| lib/rules/template-require-input-type.js | Implements the new rule, validation logic, and autofixes. |
| docs/rules/template-require-input-type.md | Documents rule purpose, options, and examples. |
| README.md | Adds the rule to the documentation table of available rules. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Adds a new template lint rule to prevent silent <input type="..."> fallback-to-text bugs, with an optional stricter mode to require explicit type declarations for consistency across codebases.
Changes:
- Introduces
template-require-input-typerule to flag invalid statictypevalues (always) and optionally require explicittypeon<input>(requireExplicit: true). - Adds a shared
isNativeElementutility to distinguish native tags from scope-shadowed component invocations in GJS/GTS. - Adds rule documentation, test coverage, and README rule index entry.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
lib/rules/template-require-input-type.js |
Implements the new rule, including autofixes and requireExplicit option handling. |
lib/utils/is-native-element.js |
Adds shared native-element detection with optional scope-shadowing checks. |
tests/lib/rules/template-require-input-type.js |
Adds RuleTester coverage for both .hbs and .gjs modes, including shadowing cases. |
docs/rules/template-require-input-type.md |
Documents the rule behavior, options, and examples. |
README.md |
Adds the rule to the rules table/index. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
8d686dc to
e3074e8
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
b15038f to
b0067f0
Compare
…pt-in requireExplicit
f0d8fbe to
148a2a3
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| GlimmerElementNode(node) { | ||
| if (node.tag !== 'input') { | ||
| return; | ||
| } | ||
| // In strict GJS, a lowercase local binding can shadow the native | ||
| // `<input>` element. `isNativeElement` consults html/svg/mathml tag | ||
| // lists and checks bindings in the scope chain to filter out | ||
| // scope-shadowed cases. | ||
| if (!isNativeElement(node, sourceCode)) { | ||
| return; | ||
| } | ||
|
|
||
| const typeAttr = node.attributes?.find((attr) => attr.name === 'type'); |
| // to `type="text"`. (Output loses the pre-slash space because the | ||
| // valueless attr range ends at `type`; prettier will re-insert if needed.) |
…, docs inputmode typo, comment fixes
Note
This is part of a series where Claude has audited
eslint-plugin-emberagainst jsx-a11y, vuejs-accessibility, angular-eslint, lit-a11y and html-validate,ember-template-lint, and the HTML and WCAG specs.Summary
Add
template-require-input-type: reject<input type="...">values that aren't one of the 22 defined HTML input types (always on — catches silent fallback-to-text bugs). Also provides an opt-inrequireExplicit: truemode that flags<input>without atypeattribute as a style/consistency check, analogous to the existingtemplate-require-button-type.inputelement defines 22 input type states, and the spec says oftype: "The attribute's missing value default and invalid value default are both the Text state." So<input type="foo">silently falls back totextwithout any error. That's a genuine silent-failure class: the author wrote a value that looks meaningful (or miskeyed a valid one, e.g.tex) and the browser quietly does something else.<input>with notypeattribute is 100% spec-compliant — the missing-value default is Text — so a bare<input>is not a bug per se. Requiring an explicittypeis an authoring-consistency choice analogous to the existingtemplate-require-button-typerule: explicit is easier to grep, easier to review, and signals intent even when the author wantedtext. This half of the rule is style, not correctness.<input type="...">with a value outside the HTML-defined set (correctness, always on). Offer arequireExplicit: trueschema option (defaultfalse) to also flag<input>without a statictype— off by default because the correctness argument for inputs is thinner than for<button>(no accidental-submit footgun), so forcing the style half onto every codebase produces false-positive noise. Skip dynamic (type={{this.t}}) values. Fixable totype="text".Fix
lib/rules/template-require-input-type.js; tests intests/lib/rules/template-require-input-type.js(40 cases, covering both default andrequireExplicit: truemodes).{ requireExplicit: boolean }(defaultfalse). Whenfalse, the rule only flags invalidtypevalues; missingtypeis allowed. Whentrue, also flags<input>without a statictype.template-require-button-typestructure — both meta-shape and visitor. Key difference: inserts thetypeattribute right after<inputrather than trying to parse the open tag (the button rule's regex mis-places attributes past/in self-closing form with other attrs; we don't want that bug).fixer.insertTextBeforeRange([node.range[0] + 6, ...], ' type="text"').Prior art
<input>.button-has-type<button>, not<input>. Same design, different tag.no-implicit-input-type— spec<input>missing atypeattribute. Does NOT validate the value (our rule also rejects unknown values, additive).Peer absence verified by
grep -rli input-has-type\|input-typeacross peer snapshots on 2026-04-22.Flags (default: invalid values only)
Flags (with
requireExplicit: true)Adds missing-
typeto the above:Allows
Notes
requireExplicitalso off by default.--fixtotype="text"(the HTML default).template-require-button-typeflags<button>without type because the default issubmit, which inside a<form>creates an accidental-submit footgun.<input>without type defaults totext, which is benign — hence the split: always flag invalid values (real silent bug), opt-in to flag missing values (style parity with the button rule).