Skip to main content

avoid-unnecessary-enum-prefix

has auto-fix
pro+

Suggests removing unnecessary enum prefixes.

Example

❌ Bad:

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

const MyEnum();

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

✅ Good:

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

const MyEnum();

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