Skip to content

stefanvanburen/buf-check-reserved-keywords

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

63 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

buf-check-reserved-keywords

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.

Usage

You can find usage instructions on the BSR at svanburenorg/reserved-keywords, but to summarize:

  1. Add the following to your buf.yaml's plugins: stanza:
- plugin: buf.build/svanburenorg/reserved-keywords:main
  1. Run the following command to download the plugin to your local environment:
$ buf plugin update
  1. If you have any lint.use rules specified (you probably have DEFAULT already added from the default buf config init), you'll need to explicitly add the lint rule to your lint.use stanza:
lint:
  use:
    - DEFAULT
+   - PLUGIN_PACKAGE_NO_LANGUAGE_RESERVED_KEYWORDS
+   - PLUGIN_FIELD_NO_LANGUAGE_RESERVED_KEYWORDS

Options

buf-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
      - python

Why?

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

Supported Languages

About

buf check plugin to check for language reserved keywords in protobuf files

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Contributors