Skip to main content

avoid-banned-names

added in: 1.21.0
⚙️
Pro+

Warns against using banned names (e.g. a variable or class name).

note

This rule requires configuration in order to highlight any issues.

⚙️ Config

Set entries (default is empty) to configure the list of entries for usages to ban.

Each entry is an object with 3 fields: name (or name-pattern), path and severity.

Set name to configure the identifier name (to pass a regular expression, set name-pattern instead).

Set name-pattern (optional) to configure a regular expression for the identifier name.

Set severity (optional) to override default severity for the given entry.

Set paths (optional) to configure the list of regular expressions that the entry will apply to.

dart_code_metrics:
...
rules:
...
- avoid-banned-names:
entries:
- name: strangeMethod
- name: StrangeClass
- name: strangeName

Example

❌ Bad:

void func() {
var strangeName = 42; // LINT
}

void strangeName() {} // LINT

// LINT
class StrangeClass {
late var strangeName; // LINT

bool strangeMethod() {} // LINT
}

✅ Good:

void func() {
var another = 42;
}

void method() {}

class SomeClass {

bool strangeMethod() {}
}