match-class-name-pattern
Configure class names to match the given pattern.
note
This rule requires configuration in order to highlight any issues.
⚙️ Config
Set entries
(default is empty) to configure a list of entries for class names to match.
Each entry is an object with 4 fields: path
, pattern
, ignore-private
and severity
.
Set path
(can be a regular expression) to configure the path to trigger on.
Set pattern
(can be a regular expression) to configure a pattern that all class names in the given file should match.
Set ignore-private
to exclude private classes from the rule's check.
Set severity
to override default severity for the given entry.
dart_code_metrics:
...
rules:
...
- match-class-name-pattern:
entries:
- path: '.*state.dart'
pattern: 'State$'
ignore-private: true
severity: error
warning
For Windows devices, ensure that the path
config works with Windows path separators.
Example
❌ Bad:
// LINT
class SomeClass {
...
}
class MyState {}
✅ Good:
class SomeState {
...
}
class MyState {}