Skip to content
This repository has been archived by the owner on Sep 12, 2020. It is now read-only.

tillig/vscode-spectral

Repository files navigation

Spectral Linter for VS Code

⚠️ DEPRECATED! I worked with the Stoplight team and they've created an official Spectral extension based on my code. Go install it from the marketplace. I won't be enhancing this extension anymore and will, instead, be contributing to theirs.


Extension for VS Code to run linting on OpenAPI, JSON, and YAML documents using Spectral.

Spectral supports linting all types of YAML and JSON documents using configurable rulesets. It ships by default with OpenAPI support, but you can create your own ruleset.

The extension has Spectral embedded, so there's nothing to install.

Features

  • Automatic detection of .spectral.yml or .spectral.json ruleset in the same folder as your documents, just like the CLI.
  • Configure which documents get linted by language identifier (json, yaml) and/or by file glob (**/*.yml).
  • Run linting as you type or on save operations.

Lint as you type

Extension Settings

This extension contributes the following settings:

  • spectral.enable: Controls whether or not Spectral is enabled.
  • spectral.rulesetFile: Location of the ruleset file to use when validating. If omitted, the default is a .spectral.yml/.spectral.json in the same folder as the document being validated. Paths are relative to the workspace.
  • spectral.run: Run the linter on save (onSave) or as you type (onType).
  • spectral.validateFiles: An array of file globs (e.g., **/*.yaml) which should be validated by Spectral. If language identifiers are also specified, the file must match both in order to be validated.
  • spectral.validateLanguages: An array of language IDs (e.g., yaml, json) which should be validated by Spectral. If file globs are also specified, the file must match both in order to be validated.

References