This repository contains a buf check plugin that checks for use of language reserved keywords in protobuf files.
It is published to the BSR at svanburenorg/reserved-keywords.
You can find usage instructions on the BSR at svanburenorg/reserved-keywords, but to summarize:
- Add the following to your
buf.yaml'splugins:stanza:
- plugin: buf.build/svanburenorg/reserved-keywords:main- Run the following command to download the plugin to your local environment:
$ buf plugin update- If you have any
lint.userules specified (you probably haveDEFAULTalready added from the defaultbuf config init), you'll need to explicitly add the lint rule to yourlint.usestanza:
lint:
use:
- DEFAULT
+ - PLUGIN_PACKAGE_NO_LANGUAGE_RESERVED_KEYWORDS
+ - PLUGIN_FIELD_NO_LANGUAGE_RESERVED_KEYWORDSbuf-check-reserved-keywords currently supports a single option, enabled_languages.
If not specified, the plugin checks for keywords for all supported languages.
If specified, only the specified languages are checked.
For example, the following enables just checking for keywords for go and python.
- plugin: buf.build/svanburenorg/reserved-keywords:main
options:
enabled_languages:
- go
- pythonWhile it's considered best practice to avoid using language reserved keywords for protobuf types,
the default buf linter does not contain any checks to prevent their usage,
as this would require buf to know about the reserved keywords of various languages.
This plugin serves as a place to add these reserved keywords, and prevent their usage in protobuf files.