Protoc Plugin

Buf ships a binary protoc-gen-buf-check-lint that performs the lint functionality as a protoc plugin. This is useful in situations where you already have a protoc plugin setup, such as Bazel.

All flags and config are passed as an option to the plugin as JSON. This must be done with the --buf-check-lint_opt flag as opposed to a parameter to --buf_check_lint_out as the option will include the ":" character as part of JSON.

The option for protoc-gen-buf-check-lint has the following shape:

{
"input_config": @string_or_json_config,
"log_level": @string,
"log_format": @string,
"error_format": @string,
"timeout": @duration
}

For example:

{"input_config":{"version":"v1beta1","lint":{"use":["ENUM_NO_ALLOW_ALIAS"]}},"error_format":"json"}

From the example from the tour:

$ protoc -I . --buf-check-lint_out=. $(find . -name '*.proto')
google/maps/roads/v1op/roads.proto:20:1: warning: Import google/api/annotations.proto is unused.
...
--buf-check-lint_out: google/appengine/v1/app_yaml.proto:53:5:Enum option "allow_alias" on enum "ErrorCode" must be false.
google/appengine/v1/app_yaml.proto:264:3:Enum option "allow_alias" on enum "SecurityLevel" must be false.
google/cloud/recommendationengine/v1beta1/catalog.proto:132:5:Enum option "allow_alias" on enum "StockState" must be false.
google/cloud/websecurityscanner/v1beta/scan_config_error.proto:35:5:Enum option "allow_alias" on enum "Code" must be false.
google/storage/v1/storage.proto:1902:5:Enum option "allow_alias" on enum "Values" must be false.

We can instead use a custom configuration as well.

protoc -I . --buf-check-lint_out=. '--buf-check-lint_opt={"input_config":{"version":"v1beta1","lint":{"use":["ENUM_NO_ALLOW_ALIAS"]}}}' $(find . -name '*.proto')
google/maps/roads/v1op/roads.proto:20:1: warning: Import google/api/annotations.proto is unused.
...
--buf-check-lint_out: google/appengine/v1/app_yaml.proto:53:5:Enum option "allow_alias" on enum "ErrorCode" must be false.
google/appengine/v1/app_yaml.proto:264:3:Enum option "allow_alias" on enum "SecurityLevel" must be false.
google/cloud/recommendationengine/v1beta1/catalog.proto:132:5:Enum option "allow_alias" on enum "StockState" must be false.
google/cloud/websecurityscanner/v1beta/scan_config_error.proto:35:5:Enum option "allow_alias" on enum "Code" must be false.
google/storage/v1/storage.proto:1902:5:Enum option "allow_alias" on enum "Values" must be false.