tag-name
Warns when tag name does not match class name.
note
This rule requires configuration in order to highlight any issues.
⚙️ Config
Set var-names
(default is empty) to configure the list of fields to check.
Set strip-prefix
(default is none) to configure the prefix to ignore.
Set strip-postfix
(default is none) to configure the postfix to ignore.
analysis_options.yaml
dart_code_metrics:
rules:
- tag-name:
var-names: [_kTag]
strip-prefix: _
strip-postfix: State
Example
❌ Bad:
class Apple {
static const _kTag = 'Orange'; // LINT: Tag name is expected to match the class name.
}
class _OrangeState {
static const _kTag = 'Apple'; // LINT: Tag name is expected to match the class name.
}
✅ Good:
class Apple {
static const _kTag = 'Apple';
}
class _OrangeState {
static const _kTag = 'Orange';
}