match_class_name_pattern
This rule flags a class, mixin, enum or extension type whose name does not match the configured pattern.
This is the general form of use_class_prefix and use_class_suffix: a project that wants one naming shape, or wants every class in one folder to end in Page, states it once as a regular expression rather than as a list of affixes.
The pattern must match the whole name, so [A-Z][A-Za-z0-9]*Page rejects HomePageExtra. An invalid pattern is ignored rather than throwing, like every other malformed option.
Narrow it to a subtree with the per-rule include, which is where this rule earns its place:
rules: match_class_name_pattern: pattern: '[A-Z][A-Za-z0-9]*Page' include: ['lib/**/presentation/**']This rule is in no preset.
class Home {} // with pattern '[A-Z][A-Za-z0-9]*Page'class HomePage {}Enabling this rule
Section titled “Enabling this rule”This rule reports nothing until you set a pattern:
rules: match_class_name_pattern: pattern: '[A-Z][A-Za-z0-9]*Page'Options
Section titled “Options”many_lints: rules: match_class_name_pattern: pattern: '[A-Z][A-Za-z0-9]*Page'rules: match_class_name_pattern: pattern: '[A-Z][A-Za-z0-9]*Page'| Option | Type | Default | Description |
|---|---|---|---|
pattern |
string | — |
A regular expression the whole name must match. Unset means the rule is silent |
Turning this rule off
Section titled “Turning this rule off”To disable this rule:
rules: match_class_name_pattern: falseTo keep the rule on but skip certain paths, use per-rule exclude.
Related rules
Section titled “Related rules”prefer_correct_type_name— Keep type names within a sensible length and correctly capitalised.use_class_prefix— Require a name prefix for classes deriving from a configured type.use_class_suffix— Require a name suffix for classes deriving from a configured type.prefer_correct_identifier_length— Keep identifier length within bounds.