Require form control names to match a specific pattern
- Rule ID:
- name-pattern
- Category:
- Style
- Standards:
- -
Requires all names on form controls to match a given pattern.
Rule details
Examples of incorrect code for this rule:
<input name="foo-bar">
Examples of correct code for this rule:
<input name="fooBar">
Array brackets are ignored by this rule:
<input name="fooBar[]">
Options
This rule takes an optional object:
{
"pattern": "camelcase"
}
Pattern
- type:
string | string[]
- default:
"camelcase"
Either one of the presets or a custom regular expression.
"kebabcase"
matches lowercase letters, digits and hyphen (e.g.kebab-case
)) (default)"camelcase"
matches lowercase letter followed by letters and digits (e.g.camelCase
)"snakecase"
matches lowercase letters, digits and underscore (e.g.snake_case
)"bem"
matches BEM naming convention (e.g.block__elem--modifier
)
Read more about details and examples of predefined patterns.
Multiple patterns can be set as an array. If value matches either of the patterns it is considered valid.
Version history
- 8.18.0 - Support
snakecase
(previouslyunderscore
) andbem
. - 8.17.0 - Rule added.