🔧 This rule is automatically fixable by the --fix CLI option.
This rule rejects <input type="..."> values that are not one of the input
types defined by the HTML spec, and (optionally) requires every <input> to
declare a type attribute.
An invalid value like <input type="foo"> silently falls back to the Text
state — the browser reports no error, but the author's intent (validation,
inputmode hint, platform keyboard) is lost. That's a genuine silent-failure
class, which this rule always flags and auto-fixes to type="text".
A missing type attribute (<input />) is spec-compliant — the
missing-value default is the Text state — so flagging it is a style /
consistency choice, not a correctness one. Opt in with requireExplicit: true
if your team wants parity with template-require-button-type.
This rule forbids the following (always):
With requireExplicit: true the rule also forbids:
This rule allows the following:
Dynamic values such as type={{this.inputType}} are not flagged at lint time.
requireExplicit(boolean, defaultfalse): when true, also flag<input>elements that have notypeattribute. Auto-fix insertstype="text".
module.exports = {
rules: {
'ember/template-require-input-type': ['error', { requireExplicit: true }],
},
};- HTML spec — the input element
- Adapted from
html-validate'sno-implicit-input-type(MIT).