avoid-banned-annotations
Configure annotations that you want to ban.
⚙️ Config
Set entries
(default is empty) to configure a list of entries to ban.
Each entry is an object with 3 fields: paths
, annotations
and message
.
Set paths
(can be a regular expression) to configure the list of paths for entry to trigger on.
Set annotations
(can be a regular expression) to configure the list of annotations to ban.
Set message
to configure a user-facing message for each issue created from this config entry.
dart_code_metrics:
...
rules:
...
- avoid-banned-annotations:
entries:
- paths: ['some/folder/.*\.dart', 'another/folder/.*\.dart']
annotations: ['visibleForTesting']
message: 'Do not use visibleForTesting here.'
note
By default, the 'visibleForTesting' RegExp will match any annotation name containing this string. For exact matches, use ^
and $
.
note
This rule requires configuration in order to highlight any issues.
Example
❌ Bad:
// LINT
class Person {
Person({
required this.value,
this.another,
});
final int value;
final int? another;
// LINT
void method() {}
}
✅ Good:
class Person {
Person({
required this.value,
this.another,
});
final int value;
final int? another;
void method() {}
}