avoid-banned-names

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

example.dartdart
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}) {}
}
Use the supported alternative.
1import 'dart:math' as legacy;
Use the supported alternative.
3void example() {
4 var legacyValue = 1;
Use the supported alternative.
7
8class legacyClass {
Use the supported alternative.
8class legacyClass {
9 int legacyField = 0;
Use the supported alternative.
9 int legacyField = 0;
10 void legacyMethod() {}
Use the supported alternative.
13void loopsAndCatches(List<int> items) {
14 for (final legacyItem in items) {
Use the supported alternative.
18 throw 0;
19 } catch (legacyError, legacyStack) {
Use the supported alternative.
18 throw 0;
19 } catch (legacyError, legacyStack) {
Use the supported alternative.
23class Model {
24 final int legacyField;
Use the supported alternative.
25 Model(this.legacyField);
26 Model.legacyNamed(this.legacyField);
Use the supported alternative.
28class Base {
29 Base({int? legacyKey});
Use the supported alternative.
29 Base({int? legacyKey});
30 void method({int? legacyArg}) {}

Valid

example.dartdart
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.

falcon.jsonjson
{
  "linter": {
    "rules": {
      "suspicious": {
        "avoid-banned-names": "error"
      }
    }
  }
}

Or silence one occurrence with a suppression comment; the reason is required.

example.dartdart
// falcon-ignore lint/suspicious/avoid-banned-names: <reason>