protolint
protolint copied to clipboard
Rule for first value of enum should have numeric value zero?
Did I miss this ? Did not see it in the list of rules but I came away from the protobuf.dev best practices guides thinking that is is important.
Do I need to create a custom rule for this?
@jordanbbaker protolint doesn't have the rule for first value of enum should have numeric value zero.
I understand that proto enums require the first value to be zero, and so the following file cannot be compiled.
syntax = "proto3";
package examplePb;
enum enumAllowingAlias {
UNKNOWN = 1;
STARTED = 2;
RUNNING = 3;
}
$ protoc -I=./ --go_out=./ ./_example/proto/simple.proto
_example/proto/simple.proto:7:15: The first enum value must be zero for open enums.
protolint does not have support for the checks that protoc does.
Thanks very much for the detailed response.
It makes sense in the context of the scope of protolint.
The context in my case is in establishing some automated pre-commit hook for protobufs. It sounds like it would be best to use both protolint and protoc to verify the sanity of the committed files.
I see your point, so I'm willing to accept this feature when someone can prepare for it.