← All projects
Open source πŸ“… 2026 GitHub

Prettier Plugin for ObjectScript

Opinionated code formatter for InterSystems ObjectScript as a Prettier 3 plugin, powered by Tree-sitter AST parsing. A personal open source project bringing modern tooling to a niche language.

✦ Open source, MIT✦ Full VS Code integration✦ Idempotence and parsing tests on every fixture

Context

ObjectScript is a proprietary InterSystems language, widely used in healthcare but almost without modern tooling: no decent automatic formatter, no standardisation. At Healthy Reply ObjectScript code is everywhere, and code quality and readability are a daily concern.

So I designed and implemented an opinionated code formatter as a plugin for Prettier 3 β€” the de-facto standard formatter of the JavaScript ecosystem β€” extending it to a completely different language.

What it does

  • Canonical command casing and optional abbreviation expansion (s β†’ Set).
  • Smart indentation for classes, methods, blocks, commands and JSON literals.
  • Formatting of ObjectScript expressions, arguments, types and object references.
  • Optional strict parsing: throws when Tree-sitter reports ERROR or missing nodes (great for CI).
  • Selective AST debugging on stderr, with filters for node types and source ranges β€” never contaminates the formatted output.
  • VS Code integration: works with the official Prettier extension + InterSystems’ ObjectScript extension, with format-on-save.

Architecture

flowchart LR
  S["Source code<br/>MyClass.cls"] --> TS["tree-sitter-objectscript<br/>(AST parsing)"]
  TS --> P["Prettier plugin<br/>(print AST)"]
  P --> O["Formatted output"]
  O --> T1["Test: expected output"]
  O --> T2["Test: idempotence"]
  O --> T3["Test: no parse<br/>diagnostics"]

From ObjectScript source to formatted code

Parsing is delegated to the tree-sitter-objectscript grammar (maintained by InterSystems), pinned to a specific commit: local and CI use the same parser. The plugin is a regular Prettier 3 plugin: custom options (objectScriptCommandCase, objectScriptExpandCommands, objectScriptStrictParsing, …) and AST printing following Prettier rules.

Design choices

  • Pin the grammar: versioned package-lock.json and pinned grammar = reproducible results between local and CI. No surprises from upstream updates.
  • Strict parsing opt-in: the upstream grammar can still report errors on valid legacy constructs; to avoid breaking people working on old code, strict mode is a flag.
  • Debug on stderr with filters: while developing a formatter you need to see the AST; instead of polluting the output, everything goes to stderr with filter options (--object-script-debug-nodes, range, max).
  • Four-level testing for every fixture: reviewed expected output, idempotence (formatting twice = no changes), syntactic validity of the generated output, option behaviour. The update script refuses to write expected files if the output is not idempotent or introduces parse diagnostics.

Results

  • Plugin ready for npm publication (installable today from GitHub: npm install prettier git+https://github.com/FilippoGalli001/prettier-plugin-objectscript.git).
  • Step-by-step documented VS Code integration, usable in other ObjectScript workspaces too.
  • A tool that improves daily life for anyone touching ObjectScript at work β€” automatic syntax standardisation.

Notes

Implementation language: JavaScript/TypeScript, Node 18.14+. MIT project, public repo: FilippoGalli001/prettier-plugin-objectscript.

Links