Skip to main content

avoid-unnecessary-enum-prefix

added in: 1.22.0
🛠
Pro+

Suggests removing unnecessary enum prefixes.

Example

❌ Bad:

enum MyEnum {
alpha(),
beta(),
gama();

const MyEnum();

int someFunction() => switch (this) {
MyEnum.alpha => 0, // LINT: This enum prefix matches the declaration name and is unnecessary. Try removing it.
beta => 1,
MyEnum.gama => 2, // LINT: This enum prefix matches the declaration name and is unnecessary. Try removing it.
};
}

✅ Good:

enum MyEnum {
alpha(),
beta(),
gama();

const MyEnum();

int someFunction() => switch (this) {
alpha => 0, // Correct, no prefix
beta => 1,
gama => 2,
};
}