avoid-banned-types
- Group
- Suspicious
- Path
lint/suspicious/avoid-banned-types- Default
- Off, opt in
- Origin
- Falcon
- Rule
- 20 of 512
Ban resolved explicit type annotations, including nested generic arguments. Aliases are expanded; import prefixes and nullability do not change matching. Unknown types are not reported. Match against the declaration's simple name.
Invalid
class Legacy {}
typedef Alias = Legacy;
Legacy? value;
List<Legacy> values = [];
Alias? alias;
class Wrapper<T> {
const Wrapper();
}
void genericConstructions() {
final list = new List<Legacy>.empty();
final wrapper = const Wrapper<Legacy>();
}class Legacy {}typedef Alias = Legacy;typedef Alias = Legacy;Legacy? value;Legacy? value;List<Legacy> values = [];List<Legacy> values = [];Alias? alias;void genericConstructions() { final list = new List<Legacy>.empty(); final list = new List<Legacy>.empty(); final wrapper = const Wrapper<Legacy>();Valid
class Modern {}
Modern? value;
List<Modern> values = [];
// Unknown types cannot establish a forbidden declaration identity.
Unknown? unknown;
class Legacy {
const Legacy();
}
class Box<Legacy> {
Legacy? value;
}
void generic<Legacy>(Legacy value) {
Legacy? local;
}
void outer() {
void nested<Legacy>(Legacy value) {}
}
typedef Callback = void Function<Legacy>(Legacy);
void constructors() {
Legacy();
new Legacy();
const Legacy();
}
class Wrapper<T> {
const Wrapper();
}
void genericConstructions() {
final list = new List<Modern>.empty();
final wrapper = const Wrapper<Modern>();
}Configure avoid-banned-types
Set its severity in falcon.json. See the configuration guide.
{
"linter": {
"rules": {
"suspicious": {
"avoid-banned-types": "error"
}
}
}
}Or silence one occurrence with a suppression comment; the reason is required.
// falcon-ignore lint/suspicious/avoid-banned-types: <reason>More suspicious rules
- avoid-barrel-files
Discourage files containing only re-exports, without declarations or parts.
- avoid-bitwise-operators-with-booleans
Flags
&and|applied to two non-nullable boolean operands. - avoid-commented-out-code
Flags ordinary comments that contain recognizable Dart statements.
- avoid-double-slash-imports
Reject repeated path separators in directive URIs (import, export and part).
- avoid-dynamic
avoid-dynamicFlags explicit
dynamictype annotations. - avoid-empty-else
avoid_empty_elserecommendedFlags an
elseclause whose body is an empty statement (else ;). - avoid-ignoring-return-values
avoid-ignoring-return-valuesFlags a discarded call whose resolved return type is non-void.
- avoid-incorrect-uri
Reject runtime-invalid Uri constructor arguments: conflicting path or query inputs and query parameter values that are neither null, strings nor iterables of strings.