Loading docs/rules/__tests__/__snapshots__/no-unknown-attributes.md.spec.ts.snap +1 −28 Original line number Diff line number Diff line // Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing exports[`docs/rules/no-unknown-attributes.md inline validation: correct 1`] = ` [ { "errorCount": 1, "filePath": "inline", "messages": [ { "column": 20, "context": { "attr": "name", "tagName": "input", }, "line": 2, "message": "Attribute "name" is not allowed on <input> element", "offset": 59, "ruleId": "no-unknown-attributes", "ruleUrl": "https://html-validate.org/rules/no-unknown-attributes.html", "selector": "input", "severity": 2, "size": 4, }, ], "source": "<div id="foo" class="bar" hidden></div> <input type="text" name="username" />", "warningCount": 0, }, ] `; exports[`docs/rules/no-unknown-attributes.md inline validation: correct 1`] = `[]`; exports[`docs/rules/no-unknown-attributes.md inline validation: incorrect 1`] = ` [ Loading src/elements/__snapshots__/html5.spec.ts.snap +1070 −1074 File changed.Preview size limit exceeded, changes collapsed. Show changes src/elements/html5.ts +55 −0 Original line number Diff line number Diff line Loading @@ -1573,9 +1573,18 @@ export default { return type === "submit" || type === "image"; }, attributes: { accept: {}, align: { deprecated: true, }, alpha: { boolean: true, }, alt: {}, autocapitalize: { enum: ["off", "none", "on", "sentences", "words", "characters"], }, autocomplete: {}, autofocus: { boolean: true, }, Loading @@ -1586,6 +1595,9 @@ export default { checked: { boolean: true, }, colorspace: { enum: ["limited-srgb", "display-p3"], }, datafld: { deprecated: true, }, Loading @@ -1595,9 +1607,14 @@ export default { datasrc: { deprecated: true, }, dirname: {}, disabled: { boolean: true, }, form: { enum: [validId], reference: "id", }, formaction: { allowed: allowedIfAttributeHasValue("type", ["submit", "image"], { defaultValue: "submit", Loading Loading @@ -1626,6 +1643,9 @@ export default { }), enum: ["/[^_].*/", "_blank", "_self", "_parent", "_top"], }, height: { enum: ["/\\d+/"], }, hspace: { deprecated: true, }, Loading @@ -1639,15 +1659,46 @@ export default { enum: [validId], reference: "id", }, max: { enum: ["/.+/"], }, maxlength: { enum: ["/\\d+/"], }, min: { enum: ["/.+/"], }, minlength: { enum: ["/\\d+/"], }, multiple: { boolean: true, }, name: { enum: ["/.+/"], }, pattern: {}, placeholder: {}, popovertarget: { enum: [validId], reference: "id", }, popovertargetaction: { enum: ["toggle", "show", "hide"], }, readonly: { boolean: true, }, required: { boolean: true, }, size: { enum: ["/\\d+/"], }, src: { enum: ["/.+/"], }, step: {}, type: { enum: [ "button", Loading Loading @@ -1677,9 +1728,13 @@ export default { usemap: { deprecated: true, }, value: {}, vspace: { deprecated: true, }, width: { enum: ["/\\d+/"], }, }, aria: { /* eslint-disable-next-line complexity -- the standard is complicated */ Loading src/rules/input-attributes.ts +76 −1 Original line number Diff line number Diff line Loading @@ -8,10 +8,58 @@ interface RuleContext { const restricted = new Map<string, string[]>([ ["accept", ["file"]], ["alpha", ["color"]], ["alt", ["image"]], [ "autocapitalize", [ "button", "checkbox", "color", "date", "datetime-local", "file", "hidden", "image", "month", "number", "radio", "range", "reset", "search", "submit", "tel", "text", "time", "week", ], ], [ "autocomplete", [ "color", "date", "datetime-local", "email", "file", "hidden", "image", "month", "number", "password", "range", "search", "tel", "text", "time", "url", "week", ], ], ["capture", ["file"]], ["checked", ["checkbox", "radio"]], ["dirname", ["text", "search"]], ["colorspace", ["color"]], ["dirname", ["hidden", "text", "search", "url", "tel", "email"]], ["height", ["image"]], [ "list", Loading @@ -38,6 +86,8 @@ const restricted = new Map<string, string[]>([ ["multiple", ["email", "file"]], ["pattern", ["text", "search", "url", "tel", "email", "password"]], ["placeholder", ["text", "search", "url", "tel", "email", "password", "number"]], ["popovertarget", ["button"]], ["popovertargetaction", ["button"]], [ "readonly", [ Loading Loading @@ -78,6 +128,31 @@ const restricted = new Map<string, string[]>([ ["size", ["text", "search", "url", "tel", "email", "password"]], ["src", ["image"]], ["step", ["date", "month", "week", "time", "datetime-local", "number", "range"]], [ "value", [ "button", "checkbox", "color", "date", "datetime-local", "email", "hidden", "month", "number", "password", "radio", "range", "reset", "search", "submit", "tel", "text", "time", "url", "week", ], ], ["width", ["image"]], ]); Loading test-files/elements/input-invalid.html +0 −4 Original line number Diff line number Diff line Loading @@ -112,10 +112,6 @@ <input type="submit" checked> <input type="image" checked alt="lorem ipsum"> <input type="reset" checked> <input type="hidden" dirname="myname"> <input type="url" dirname="myname"> <input type="tel" dirname="myname"> <input type="email" dirname="myname"> <input type="password" dirname="myname"> <input type="date" dirname="myname"> <input type="month" dirname="myname"> Loading Loading
docs/rules/__tests__/__snapshots__/no-unknown-attributes.md.spec.ts.snap +1 −28 Original line number Diff line number Diff line // Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing exports[`docs/rules/no-unknown-attributes.md inline validation: correct 1`] = ` [ { "errorCount": 1, "filePath": "inline", "messages": [ { "column": 20, "context": { "attr": "name", "tagName": "input", }, "line": 2, "message": "Attribute "name" is not allowed on <input> element", "offset": 59, "ruleId": "no-unknown-attributes", "ruleUrl": "https://html-validate.org/rules/no-unknown-attributes.html", "selector": "input", "severity": 2, "size": 4, }, ], "source": "<div id="foo" class="bar" hidden></div> <input type="text" name="username" />", "warningCount": 0, }, ] `; exports[`docs/rules/no-unknown-attributes.md inline validation: correct 1`] = `[]`; exports[`docs/rules/no-unknown-attributes.md inline validation: incorrect 1`] = ` [ Loading
src/elements/__snapshots__/html5.spec.ts.snap +1070 −1074 File changed.Preview size limit exceeded, changes collapsed. Show changes
src/elements/html5.ts +55 −0 Original line number Diff line number Diff line Loading @@ -1573,9 +1573,18 @@ export default { return type === "submit" || type === "image"; }, attributes: { accept: {}, align: { deprecated: true, }, alpha: { boolean: true, }, alt: {}, autocapitalize: { enum: ["off", "none", "on", "sentences", "words", "characters"], }, autocomplete: {}, autofocus: { boolean: true, }, Loading @@ -1586,6 +1595,9 @@ export default { checked: { boolean: true, }, colorspace: { enum: ["limited-srgb", "display-p3"], }, datafld: { deprecated: true, }, Loading @@ -1595,9 +1607,14 @@ export default { datasrc: { deprecated: true, }, dirname: {}, disabled: { boolean: true, }, form: { enum: [validId], reference: "id", }, formaction: { allowed: allowedIfAttributeHasValue("type", ["submit", "image"], { defaultValue: "submit", Loading Loading @@ -1626,6 +1643,9 @@ export default { }), enum: ["/[^_].*/", "_blank", "_self", "_parent", "_top"], }, height: { enum: ["/\\d+/"], }, hspace: { deprecated: true, }, Loading @@ -1639,15 +1659,46 @@ export default { enum: [validId], reference: "id", }, max: { enum: ["/.+/"], }, maxlength: { enum: ["/\\d+/"], }, min: { enum: ["/.+/"], }, minlength: { enum: ["/\\d+/"], }, multiple: { boolean: true, }, name: { enum: ["/.+/"], }, pattern: {}, placeholder: {}, popovertarget: { enum: [validId], reference: "id", }, popovertargetaction: { enum: ["toggle", "show", "hide"], }, readonly: { boolean: true, }, required: { boolean: true, }, size: { enum: ["/\\d+/"], }, src: { enum: ["/.+/"], }, step: {}, type: { enum: [ "button", Loading Loading @@ -1677,9 +1728,13 @@ export default { usemap: { deprecated: true, }, value: {}, vspace: { deprecated: true, }, width: { enum: ["/\\d+/"], }, }, aria: { /* eslint-disable-next-line complexity -- the standard is complicated */ Loading
src/rules/input-attributes.ts +76 −1 Original line number Diff line number Diff line Loading @@ -8,10 +8,58 @@ interface RuleContext { const restricted = new Map<string, string[]>([ ["accept", ["file"]], ["alpha", ["color"]], ["alt", ["image"]], [ "autocapitalize", [ "button", "checkbox", "color", "date", "datetime-local", "file", "hidden", "image", "month", "number", "radio", "range", "reset", "search", "submit", "tel", "text", "time", "week", ], ], [ "autocomplete", [ "color", "date", "datetime-local", "email", "file", "hidden", "image", "month", "number", "password", "range", "search", "tel", "text", "time", "url", "week", ], ], ["capture", ["file"]], ["checked", ["checkbox", "radio"]], ["dirname", ["text", "search"]], ["colorspace", ["color"]], ["dirname", ["hidden", "text", "search", "url", "tel", "email"]], ["height", ["image"]], [ "list", Loading @@ -38,6 +86,8 @@ const restricted = new Map<string, string[]>([ ["multiple", ["email", "file"]], ["pattern", ["text", "search", "url", "tel", "email", "password"]], ["placeholder", ["text", "search", "url", "tel", "email", "password", "number"]], ["popovertarget", ["button"]], ["popovertargetaction", ["button"]], [ "readonly", [ Loading Loading @@ -78,6 +128,31 @@ const restricted = new Map<string, string[]>([ ["size", ["text", "search", "url", "tel", "email", "password"]], ["src", ["image"]], ["step", ["date", "month", "week", "time", "datetime-local", "number", "range"]], [ "value", [ "button", "checkbox", "color", "date", "datetime-local", "email", "hidden", "month", "number", "password", "radio", "range", "reset", "search", "submit", "tel", "text", "time", "url", "week", ], ], ["width", ["image"]], ]); Loading
test-files/elements/input-invalid.html +0 −4 Original line number Diff line number Diff line Loading @@ -112,10 +112,6 @@ <input type="submit" checked> <input type="image" checked alt="lorem ipsum"> <input type="reset" checked> <input type="hidden" dirname="myname"> <input type="url" dirname="myname"> <input type="tel" dirname="myname"> <input type="email" dirname="myname"> <input type="password" dirname="myname"> <input type="date" dirname="myname"> <input type="month" dirname="myname"> Loading