Skip to content
Latchkey

protolint: Lint and Auto-Fix .proto Files in CI

protolint lints .proto files against configurable style rules and, with -fix, rewrites many violations automatically.

protolint is a standalone proto linter (no full buf toolchain needed). It is a lightweight CI gate that, unlike buf, can also auto-fix a subset of issues.

What it does

protolint runs a set of rules (indentation, naming conventions, ordering, enum/field rules) against each .proto and reports violations as file:line:col message. Rules are toggled in a .protolint.yaml. protolint lint -fix automatically corrects the fixable rules in place.

Common usage

Terminal
# lint a directory tree
protolint lint proto/

# auto-fix what can be fixed
protolint lint -fix proto/

# use a config and emit JUnit for CI
protolint lint -config_path .protolint.yaml \
  -reporter junit -output junit.xml proto/

Flags and options

FlagWhat it does
lint <paths>Lint the given files or directories
-fixAutomatically fix violations that support it
-config_path <file>Use a specific .protolint.yaml
-config_dir_path <dir>Directory to search for the config
-reporter <name>Output format: plain, json, junit, unix
-output <file>Write the report to a file
-vVerbose output

In CI

Run protolint lint (no -fix) in CI so it reports and fails rather than mutating files; keep -fix for local use or a dedicated formatting job. The -reporter junit -output junit.xml combo surfaces violations in test-report UIs.

Common errors in CI

Typical lines: "EnumFieldNamesUpperSnakeCase: ... should be CapitalSnakeCase" and "FieldNamesLowerSnakeCase: Field name "userId" must be ...". "[ERROR] failed to parse, due to ... unexpected token" means the file does not compile; fix syntax first. "no such file or directory" for the config means -config_path is wrong; protolint falls back to defaults if no config is found.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →