Skip to content

mathematic-inc/vscode-api-linter

Repository files navigation

API Linter for Visual Studio Code

Lint Protobuf API files using API Linter in Visual Studio Code.

Overview

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.

Requirements

You must have one of the following available:

  • api-linter installed and on your PATH, or
  • A custom proxy command (e.g. bazel run api-linter --) configured via apiLinter.command.

Installation

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.

Features

  • Automatic linting on save: The extension automatically lints the active .proto file whenever it is saved.
  • Manual lint command: Run the API Linter: Lint the current file command 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.

Configuration

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.

Example: Using a Bazel proxy

{
  "apiLinter.command": ["bazel", "run", "//tools:api-linter", "--"]
}

Example: Custom proto include paths

{
  "apiLinter.protoPaths": ["vendor/proto", "third_party/proto"]
}

Usage

  1. Open a .proto file in VS Code.
  2. The extension activates automatically for proto and proto3 language files.
  3. Save the file to trigger automatic linting, or use the Command Palette to run API Linter: Lint the current file.
  4. Lint violations appear as diagnostics in the editor and in the Problems panel.

Repository

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.

License

Apache-2.0

This project is free and open-source work by a 501(c)(3) non-profit. If you find it useful, please consider donating.

About

VS Code extension that lints Protobuf API files using Google's API Linter (api-linter) with full configuration support

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Packages

 
 
 

Contributors