Skip to content

v0.9.0

Choose a tag to compare

@reteps reteps released this 22 Apr 23:35
· 65 commits to master since this release
0f3b1e9

New: browser entry point

@reteps/tree-sitter-htmlmustache/browser — bundler-friendly ESM entry exposing createLinter({ locateWasm, prettier? }) with lint() and format(). Targets in-browser editors (e.g. an Ace/CodeMirror editor running lint on every keystroke, format on a button click). No Node built-ins in the shipped path; consumers host and resolve the grammar WASM via the locateWasm callback or URL.

import { createLinter, DEFAULT_CONFIG } from '@reteps/tree-sitter-htmlmustache/browser';

const linter = await createLinter({ locateWasm, prettier });
const diagnostics = linter.lint(source, DEFAULT_CONFIG);
const formatted = await linter.format(source);

Exports Diagnostic, Config, CustomRule, CustomTag, PrettierLike, DEFAULT_CONFIG, and createLinter. Full parity with htmlmustache check (all 8 built-in rules, custom rules, inline htmlmustache-disable directives, parse errors, HTML balance). Embedded <script>/<style> formatting is opt-in via injected prettier.

Internal reorg

  • The rule engine, formatter, selector matcher, and schema types move from lsp/server/src/ to a browser-safe src/core/. Node-only helpers (config-file discovery, .editorconfig lookup) stay under lsp/server/src/.
  • Selector parsing in collectErrors is now memoized — per-keystroke lint no longer re-parses the same custom-rule selectors.
  • FormatDocumentParams drops the internal configFile/editorConfig fields; callers pre-resolve FormattingOptions via the exported mergeOptions.
  • Shared helpers: src/core/diagnostic.ts (toDiagnostic), src/core/formatting/embedded.ts (prettier-based embedded region formatter + PrettierLike), src/core/grammar.ts (GRAMMAR_WASM_FILENAME).

Compatibility

No breaking changes for existing consumers — the native binding (bindings/node), the htmlmustache CLI, and the grammar WASM are unchanged. LSP extension bumped to 0.9.0 alongside the parser.