Skip to main content

tag-name

added in: 1.6.0
⚙️🛠

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 none) 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.

dart_code_metrics:
...
rules:
...
- tag-name:
var-names: [_kTag]
strip-prefix: _
strip-postfix: State
...

Example

❌ Bad:

class Apple {
static const _kTag = 'Orange'; // LINT
}

class _OrangeState {
static const _kTag = 'Apple'; // LINT
}

✅ Good:

class Apple {
static const _kTag = 'Apple';
}

class _OrangeState {
static const _kTag = 'Orange';
}