xslint-lsp
v0.0.8
Published
Language Server Protocol server for xslint
Readme
xslint-lsp
A Language Server Protocol server that surfaces xslint's diagnostics as you type — squiggles in your editor instead of a failed build.
xslint lints XSL/XSLT stylesheets — malformed XML, invalid XPath, and stylistic defects — but only in the terminal and CI. This wraps xslint's engine in an LSP server, so the same defects light up in any LSP-capable editor: VS Code, Neovim, and JetBrains IDEs (via LSP4IJ or their built-in LSP support).
Because it is a thin transport over xslint — it calls xslint's lint(sources)
in-process and maps each defect onto an LSP Diagnostic — there is no second
rule engine to keep in sync.
How it works
editor ──(LSP over stdio)──▶ src/server.js
│ lint(buffer) → @xslint/xslint
│ diagnostics(defects) → src/diagnostics.js
▼
editor ◀──(publishDiagnostics)── { range, severity, code: rule, message }The server keeps open documents in sync, re-lints on every change (checking the
live buffer, not the saved file), and clears a file's diagnostics when it
closes. Each xslint defect {name, severity, message, line, pos} becomes an LSP
diagnostic whose code is the rule name and whose source is xslint.
It also offers code actions: a quick-fix on each fixable defect and a
fix all action for the safe fixes. Both are computed by xslint's own fixed
engine, so an editor fix is byte-for-byte identical to a command-line --fix.
Run it
The server speaks LSP over stdio:
npm install
node src/server.js --stdioPoint any LSP client at that command for .xsl/.xslt files.
Editor extension
A VS Code-compatible extension lives in client/; it bundles and
launches this server. It's published to
Open VSX and
attached as a .vsix to every
release — it is not
on the Microsoft VS Code Marketplace.
- Cursor, VSCodium, Windsurf, Gitpod — search xslint in the Extensions view (they install from Open VSX).
- VS Code —
code --install-extension xslint-vscode-<version>.vsix, or Extensions →⋯→ Install from VSIX… with the release's.vsix.
See client/README.md for the full guide. To hack on the
extension, open this repo and press F5; to build a .vsix, run
cd client && npm run package. Releases publish it automatically (see
RELEASING.md).
Development
npm test # unit tests + an end-to-end LSP round-trip
npm run coverage # the same, under c8 with a 100% gate
npm run lint # eslint (google + @stylistic)Tests run on Node's built-in runner (node --test). test/diagnostics.test.js
covers the defect→diagnostic mapping; test/server.test.js spawns the server
and drives it through open/change/close, asserting the diagnostics it publishes
— and it exits the server cleanly so its subprocess coverage is captured.
License
MIT — see LICENSE.txt.
