Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
P

protolint

> 开发工具
Open source

A pluggable linter and fixer to enforce Protocol Buffer style and conventions.

696 stars0 likes0 views
WebsiteGitHub

About

A pluggable linter and fixer to enforce Protocol Buffer style and conventions.

protolint

protolint is the pluggable linting/fixing utility for Protocol Buffer files (proto2+proto3):

  • Runs fast because this works without compiler.
  • Easy to follow the official style guide. The rules and the style guide correspond to each other exactly.
    • Fixer automatically fixes all the possible official style guide violations.
  • Allows to disable rules with a comment in a Protocol Buffer file.
    • It is useful for projects which must keep API compatibility while enforce the style guide as much as possible.
    • Some rules can be automatically disabled by inserting comments to the spotted violations.
  • Loads plugins to contain your custom lint rules.
  • Undergone testing for all rules.
  • Many integration supports.
    • protoc plugin
    • Editor integration
    • GitHub Action
    • CI Integration

Demo

Once MCP server configured, you can ask any MCP clients like Claude Desktop to lint and fix your Protocol Buffer files like this:

Also, vim-protolint works like the following.

MCP Server

protolint now includes support for the Model Context Protocol (MCP), which allows AI models to interact with protolint directly.

Usage

bash
protolint --mcp

For detailed documentation on how to use and integrate protolint's MCP server functionality, see the MCP documentation.

Installation

Via Homebrew

protolint can be installed for Mac or Linux using Homebrew via the yoheimuta/protolint tap.

bash
brew tap yoheimuta/protolint
brew install protolint

Since homebrew-core includes protolint, you can also install it by just brew install protolint. This is the default tap that is installed by default. It's easier, but not maintained by the same author. To keep it updated, I recommend you run brew tap yoheimuta/protolint first.

Via GitHub Releases

You can also download a pre-built binary from this release page:

  • https://github.com/yoheimuta/protolint/releases

In the downloads section of each release, you can find pre-built binaries in .tar.gz packages.

Use the maintained Docker image

protolint ships a Docker image yoheimuta/protolint that allows you to use protolint as part of your Docker workflow.

❯❯❯ docker run --volume "$(pwd):/workspace" --workdir /workspace yoheimuta/protolint lint _example/proto
[_example/proto/invalidFileName.proto:1:1] File name should be lower_snake_case.proto.
[_example/proto/issue_88/oneof_options.proto:11:5] Found an incorrect indentation style "    ". "  " is correct.
[_example/proto/issue_88/oneof_options.proto:12:5] Found an incorrect indentation style "    ". "  " is correct.

From Source

The binary can be installed from source if Go is available. However, I recommend using one of the pre-built binaries instead because it doesn't include the version info.

bash
go install github.com/yoheimuta/protolint/cmd/protolint@latest

Within JavaScript / TypeScript

You can use protolint using your nodejs package manager like npm or yarn.

bash
$ npm install protolint --save-dev

This will add a reference to a development dependency to your local package.json.

During install, the postinstall.js script will be called. It will download the matching protolint from github. Just like @electron/get, you can bypass the download using the following environment variables:

Environment Variable Default value Description
PROTOLINT_MIRROR_HOST https://github.com HTTP/Web server base url hosting the binaries
PROTOLINT_MIRROR_REMOTE_PATH yoheimuta/protolint/releases/download Path to the archives on the remote host
PROTOLINT_MIRROR_USERNAME HTTP Basic auth user name
PROTOLINT_MIRROR_PASSWORD HTTP Basic auth password
PROTOLINT_PROXY HTTP(S) Proxy with optional auth data

Within the remote path, the archives from the releases page must be mirrored.

After that, you can use npx protolint (with all supplied protolint arguments) within your dev-scripts.

json
{
  ...
  "scripts": {
    "protoc": "....",
    "preprotoc": "npx protolint"
  },
  ...
}

You can add a protolint node to your package.json which may contain the content of protolint.yml below the lint node, i.e. the root element of the configuration will be protolint.

If you want to get an output that matches the TSC compiler, use reporter tsc.

Within Python projects

You can use protolint as a linter within your python projects, the wheel protolint-bin on pypi contains the pre-compiled binaries for various platforms. Just add the desired version to your pyproject.toml or requirements.txt.

The wheels downloaded will contain the compiled go binaries for protolint and protoc-gen-protolint. Your platform must be compatible with the supported binary platforms.

You can add the linter configuration to the tools.protolint package in pyproject.toml.

Usage

…

protolint does not require configuration by default, for the majority of projects it should work out of the box.

Version Control Integration

protolint is available as a pre-commit hook. Add this to your .pre-commit-config.yaml in your repository to run protolint with Go:

yaml
repos:
  - repo: https://github.com/yoheimuta/protolint
    rev: v0.56.3 # Select a release here
    hooks:
      - id: protolint

For Docker-based execution, use the protolint-docker hook:

yaml
repos:
  - repo: https://github.com/yoheimuta/protolint
    hooks:
      - id: protolint-docker # Uses yoheimuta/protolint:latest by default

Important: For Docker hooks, the rev parameter is meaningless for versioning per pre-commit's design. To pin to a specific protolint version, specify the Docker image tag in the entry:

yaml
repos:
  - repo: https://github.com/yoheimuta/protolint
    hooks:
      - id: protolint-docker
        entry: yoheimuta/protolint:v0.55.6 lint # Pin to specific version

Editor Integration

Visual Studio Code

  • vscode-protolint
  • protolint-vscode

JetBrains IntelliJ IDEA, GoLand, WebStorm, PHPStorm, PyCharm...

  • intellij-protolint

Vim(ALE engine)

  • ale's built-in support

Vim(Syntastic)

  • vim-protolint

GitHub Action

A GitHub Action to run protolint in your workflows

  • github/super-linter
  • plexsystems/protolint-action
  • yoheimuta/action-protolint - Integrated with reviewdog

CI Integration

Jenkins Plugins

  • warnings-ng and any that use violatons-lib

Linters aggregator

  • MegaLinter runs protolint out of the box among its many embedded linters

Environment specific output

It is possible to format your linting according to the formatting of the CI/CD environment. The environment must be set using the output format. Currently, the following output is realized:

Environment Command Line Value Description Example
Github Actions ci-gh Github Help ::warning file=example.proto,line=10,col=20,title=ENUM_NAMES_UPPER_CAMEL_CASE::EnumField name \"SECOND.VALUE\" must be CAPITALS_WITH_UNDERSCORES
Azure DevOps ci-az Azure DevOps Help ##vso[task.logissue type=warning;sourcepath=example.proto;linenumber=10;columnnumber=20;code=ENUM_NAMES_UPPER_CAMEL_CASE;]EnumField name \"SECOND.VALUE\" must be CAPITALS_WITH_UNDERSCORES
Gitlab CI/CD ci-glab Reverse Engineered from Examples WARNING: ENUM_NAMES_UPPER_CAMEL_CASE example.proto(10,20) : EnumField name \"SECOND.VALUE\" must be CAPITALS_WITH_UNDERSCORES

You can also use the generic ci formatter, which will create a generic problem matcher.

With the ci-env value, you can specify the template from the following environment variables:

Environment Variable Priority Meaning
PROTOLINT_CIREPORTER_TEMPLATE_STRING 1 String containing a Go-template
PROTOLINT_CIREPORTER_TEMPLATE_FILE 2 Path to a file containing a Go-template

The resulting line-feed must not be added, as it will be added automatically.

The following fields are available:

Severity : The severity as string (either note, warning or error)

File : Path to the file containing the error

Line : Line within the file containing the error (starting position)

Column : Column within the file containing the error (starting position)

Rule : The name of the rule that is faulting

Message : The error message that descibes the error

Producing an output file and an CI/CD Error stream

You can create a specific output matching your CI/CD environment and also create an output file, e.g. for your static code analysis tools like github CodeQL or SonarQube.

This can be done by adding the --add-reporter flag. Please note, that the value must be formatted : (omitting ``).

bash
$ protolint --reporter ci-gh --add-reporter sarif:/path/to/my/output.sarif.json proto/*.proto

Use as a protoc plugin

protolint also maintains a binary protoc-gen-protolint that performs the lint functionality as a protoc plugin. See cmd/protoc-gen-protolint/README.md in detail.

This is useful in situations where you already have a protoc plugin workflow.

Call from Go code

You can also use protolint from Go code. See Go Documentation and lib/lint_test.go in detail.

go
import (
    "bytes"

    "github.com/yoheimuta/protolint/lib"
)

func main() {
    args := []string{"-config_path", "path/to/your_protolint.yaml", "."}
    var stdout bytes.Buffer
    var stderr bytes.Buffer

    err := lib.Lint(args, &stdout, &stderr)
    if err != nil {
        // Handle error
    }

    // Process output in stdout and stderr
}

Rules

See internal/addon/rules in detail.

The rule set follows:

  • Official Style Guide. This

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

Goclifixergolanglint

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category开发工具
PricingOpen source

> Related tools

V
VS Code
流行的开源代码编辑器
G
Git
分布式版本控制系统
V
Vite
下一代前端构建工具