avoid-banned-names
- Group
- Suspicious
- Path
lint/suspicious/avoid-banned-names- Default
- Off, opt in
- Origin
- Falcon
- Rule
- 19 of 512
Ban declaration names, exempting references, initializing/super formals, and
@override-annotated members and their parameters.
Invalid
import 'dart:math' as legacy;
void example() {
var legacyValue = 1;
print(legacyValue);
}
class legacyClass {
int legacyField = 0;
void legacyMethod() {}
}
void loopsAndCatches(List<int> items) {
for (final legacyItem in items) {
print(legacyItem);
}
try {
throw 0;
} catch (legacyError, legacyStack) {
print(legacyError);
}
}
class Model {
final int legacyField;
Model(this.legacyField);
Model.legacyNamed(this.legacyField);
}
class Base {
Base({int? legacyKey});
void method({int? legacyArg}) {}
}
class Child extends Base {
Child({super.legacyKey});
@override
void method({int? legacyArg}) {}
}import 'dart:math' as legacy;void example() { var legacyValue = 1; class legacyClass {class legacyClass { int legacyField = 0; int legacyField = 0; void legacyMethod() {}void loopsAndCatches(List<int> items) { for (final legacyItem in items) { throw 0; } catch (legacyError, legacyStack) { throw 0; } catch (legacyError, legacyStack) {class Model { final int legacyField; Model(this.legacyField); Model.legacyNamed(this.legacyField);class Base { Base({int? legacyKey}); Base({int? legacyKey}); void method({int? legacyArg}) {}Valid
import 'dart:math' as modern;
import 'support.dart';
// legacyValue in comments and strings is not an identifier.
void example() {
var modernValue = 'legacyValue';
print(modernValue);
var LegacyValue = 1;
}
class Derived {
@override
String toString() => 'Derived';
}
class Model {
final int modernField;
Model(this.modernField);
Model.modernNamed(this.modernField);
}
class Child extends Base {
Child({super.modernKey});
@override
void method({int? legacyArg}) {}
}
void loopsAndCatches(List<int> items, int modernItem) {
for (final currentItem in items) {}
for (modernItem in items) {}
try {
throw 0;
} catch (modernError, modernStack) {}
}Configure avoid-banned-names
Set its severity in falcon.json. See the configuration guide.
{
"linter": {
"rules": {
"suspicious": {
"avoid-banned-names": "error"
}
}
}
}Or silence one occurrence with a suppression comment; the reason is required.
// falcon-ignore lint/suspicious/avoid-banned-names: <reason>More suspicious rules
- avoid-banned-types
Ban resolved explicit type annotations, including nested generic arguments.
- 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.