Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rule for first value of enum should have numeric value zero? #423

Open
jordanbbaker opened this issue Jul 11, 2024 · 3 comments
Open

Rule for first value of enum should have numeric value zero? #423

jordanbbaker opened this issue Jul 11, 2024 · 3 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@jordanbbaker
Copy link

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?

@yoheimuta
Copy link
Owner

@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.

@yoheimuta yoheimuta added the question Further information is requested label Jul 13, 2024
@jordanbbaker
Copy link
Author

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.

@yoheimuta
Copy link
Owner

I see your point, so I'm willing to accept this feature when someone can prepare for it.

@yoheimuta yoheimuta added enhancement New feature or request good first issue Good for newcomers and removed question Further information is requested labels Jul 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants