# enum-no-allow-alias

Source: https://api-genie.dev/docs/linter/protobuf/rules/enum-no-allow-alias

A rule of the Protobuf linter, which reads proto3 files; the reader rejects proto2 and editions files. Since 0.9.0. In the rulesets: Recommended at warning, Strict at error, All at error.

This rule checks whether any enum sets the `allow_alias` option.

## Rule details

With `option allow_alias = true;`, several values of an enum can share a number. Only one of the
names survives serialization, though: the JSON and text formats always write the first name of
the number, so a client that sends one name may read back another. Aliases also make renaming
values harder than it looks, since both names have to be kept in sync with every consumer.

The `enum-no-allow-alias` rule reports `Enum '<enum>' should not allow aliases` at the
`allow_alias` option of every enum that sets it to `true`.

Turn the rule off while renaming enum values: an alias lets the old and the new name coexist until
all clients have moved to the new one. To allow a single enum, add an `// apigenie-lint-disable
enum-no-allow-alias` comment to the enum.

## Examples

**Good**.

```proto
syntax = "proto3";

package acme.pets.v1;

enum PetKind {
  PET_KIND_UNSPECIFIED = 0;
  PET_KIND_DOG = 1;
  PET_KIND_CAT = 2;
}
```

**Bad**. The linter reports `Enum 'PetKind' should not allow aliases`.

```proto
syntax = "proto3";

package acme.pets.v1;

enum PetKind {
  option allow_alias = true;
  PET_KIND_UNSPECIFIED = 0;
  PET_KIND_DOG = 1;
  PET_KIND_HOUND = 1;
  PET_KIND_CAT = 2;
}
```
