portfolio / work / yrest-vscode.mdoc

yRest for VS Code

Write db.yml with an editor that understands it.

A VS Code extension for yRest files — syntax highlighting, hover documentation, context-aware autocompletion and diagnostics for db.yml and *.yrest.yml, also inside yrest tagged templates in TypeScript and JavaScript.

At a glance

Problem
Mistakes in db.yml conventions, like a missing collection or a key without its _, only showed up when the server ran.
My part
Built and published it alone: grammars, providers, validation rules, tests and the release pipeline.
What I delivered
  • Published on the VS Code Marketplace, from version tags.
  • Highlighting, hover docs, autocompletion and diagnostics, also inside yrest tagged templates.
  • Unit tests cover the validation rules.
Reconstruction of VS Code editing a yRest db.yml: an error underlines the unknown collection “reviews”, with the hover documentation for _rel, the relation-type suggestions and the extension’s icon beside it.
Reconstruction with the extension’s real grammar, messages and documentation.
Type
Open source
Period
June 2026
Status
Active
Role
  • Development
  • Documentation

Problem

yRest's db.yml format grew its own conventions: relations (_rel), custom routes (_routes), a compact relation DSL and template variables. Without editor support, a typo in a collection name or a key without its _ prefix only showed up when the server ran.

Solution

  • Highlighting for reserved keys, relation types and aliases, cardinalities, the relation DSL, template variables and path parameters.
  • Hover documentation for every reserved key, with a short description and a YAML example.
  • Autocompletion in ten contexts, such as collection names for relation targets or HTTP methods for _method.
  • Diagnostics on every keystroke: YAML errors with exact position, relations pointing to collections that don't exist, invalid relation types or cardinalities, and _routes keys written without their _ prefix.
  • The same help inside tests: hover and diagnostics also work in yrest`...` tagged templates in TypeScript and JavaScript.

Technical decisions

Diagnostics scoped to their section

Problem
Errors were reported on the first occurrence of a word anywhere in the file, causing false positives.
Decision
Scope each diagnostic to its section, searching from the _rel: or _routes: offset.
Alternatives
Highlight the whole line, or skip positions.
Trade-off
The validator has to track section offsets.
Evidence
Fixed in v0.2.2; a field named status inside _schema is no longer flagged.

Quality

Unit tests cover the validation rules and the shared constants. CI compiles, lints and packages the extension on every push; tags publish to the VS Code Marketplace.

Stack

LayerTechnologyWhy
InterfaceVS Code Extension APIHover, completion and diagnostics providers.
InterfaceTextMate grammarsHighlighting for yRest files, injected into plain YAML and into TS/JS tagged templates.
RuntimeTypeScript + yamlValidation logic on top of the same YAML parser yRest uses.
QualityVitestUnit tests for the validation rules and shared constants.

Have a product in mind? Let’s talk.

An idea on a napkin, a process that slows your team down, a product that needs another pair of hands: tell me about it. I read every message and answer with honest questions, not a sales pitch.