Lint Protobuf API files using API Linter in Visual Studio Code.
API Linter is a linter developed by Google for linting APIs written in Protocol Buffers. It enforces the Google API Improvement Proposals (AIPs), a set of design guidelines for APIs.
This extension integrates api-linter directly into VS Code, providing inline diagnostics as you edit and save .proto files.
You must have one of the following available:
api-linterinstalled and on yourPATH, or- A custom proxy command (e.g.
bazel run api-linter --) configured viaapiLinter.command.
Install this extension from the Visual Studio Code Marketplace by searching for "API Linter" (publisher: mathematic).
Alternatively, install the api-linter CLI tool by following the official installation instructions.
- Automatic linting on save: The extension automatically lints the active
.protofile whenever it is saved. - Manual lint command: Run the
API Linter: Lint the current filecommand from the Command Palette (Ctrl+Shift+P/Cmd+Shift+P) to lint on demand. - Inline diagnostics: Violations are shown as inline errors and warnings directly in the editor.
- Configurable: All functional flags are exposed through the extension's configuration settings.
The following settings are available under the apiLinter namespace in VS Code settings:
| Setting | Type | Default | Description |
|---|---|---|---|
apiLinter.command |
array |
["api-linter"] |
Command to run for API linter. Use this to specify a custom binary or proxy command. |
apiLinter.configFile |
string |
".apilinter.yml" |
Path to a config file for API linter. If the file does not exist, no config will be used. |
apiLinter.protoPaths |
array |
[] |
Include paths to use for proto imports. |
{
"apiLinter.command": ["bazel", "run", "//tools:api-linter", "--"]
}{
"apiLinter.protoPaths": ["vendor/proto", "third_party/proto"]
}- Open a
.protofile in VS Code. - The extension activates automatically for
protoandproto3language files. - Save the file to trigger automatic linting, or use the Command Palette to run
API Linter: Lint the current file. - Lint violations appear as diagnostics in the editor and in the Problems panel.
Source code is available at github.com/mathematic-inc/vscode-api-linter.
Issues and feature requests can be filed at github.com/mathematic-inc/vscode-api-linter/issues.
Start with a Discussion instead of opening a pull request. If we accept the proposal, a Mathematic maintainer or agent will implement it. When we implement your proposal, the pull request will link to the Discussion and credit you as the proposal's original author. GitHub restricts pull request creation to Mathematic maintainers and repository collaborators with write, maintain, or admin access, plus authorized maintenance agents. See CONTRIBUTING.md for the full process.
This project is free and open-source work by a 501(c)(3) non-profit. If you find it useful, please consider donating.