Skip to content

name-pattern

Reports the name of a form control that does not match the option pattern, a regex that by default means camelCase, with a trailing [] allowed.

The name is the key of the value on the server and in scripts, so a fixed style makes the keys predictable; a name in another style is often a typo that the server never reads.

To fix, rename the control and what reads its value, or change the pattern.

Reported
...
<p id="foo-bar"></p>
...
<input name="fooBar">
<input name="foo_bar">
<input name="foo[]">
...
angular:
lint:
rules:
name-pattern:
level: warn # off (default), warn, error
options:
pattern: "^[a-z][a-zA-Z0-9]*(\\[\\])?$"
html:
lint:
rules:
name-pattern:
level: warn # off (default), warn, error
options:
pattern: "^[a-z][a-zA-Z0-9]*(\\[\\])?$"
svelte:
lint:
rules:
name-pattern:
level: warn # off (default), warn, error
options:
pattern: "^[a-z][a-zA-Z0-9]*(\\[\\])?$"
vue:
lint:
rules:
name-pattern:
level: warn # off (default), warn, error
options:
pattern: "^[a-z][a-zA-Z0-9]*(\\[\\])?$"
Option Type Default Description
pattern string "^[a-z][a-zA-Z0-9]*(\\[\\])?$" The regex the value must match.

Suppress one line with sudsy-disable-next-line name-pattern in a comment of the file’s language.

The same check in other tools; Sudsy reports what each upstream rule reports.

Tool Rule Match
html-validate name-pattern full