WebAssembly & npm
malt compiles to WebAssembly and is published to npm as malt-wasm, so you can lint MATLAB code in the browser, in Node.js, or embed the linter in your own tooling. The same engine powers the Playground and the CLI.
Installing
npm install malt-wasmUsage
import init, { Linter } from 'malt-wasm';
await init();
const linter = new Linter({
disable: ['NOSEMI'],
});
// Lint MATLAB content — returns a JSON array of warnings.
const warnings = JSON.parse(linter.check('x = 1'));
// Apply all auto-fixes.
const fixed = linter.fix('x = 1');
// Or start from a `.malt.toml` string (full fidelity: severities,
// categories, rule params, exclude). Throws on invalid TOML.
const configured = Linter.from_toml('[lint.rules]\nNOSEMI = "off"\n');See the package README for the full API reference (warning format, browser/Node usage, configuration).
Building locally
The malt-wasm package is built with wasm-pack. Development tools are managed by mise:
mise install # install wasm-pack, node, clang
mise run setup-wasi # download the WASI SDK (compiles the tree-sitter C parser)
mise run build-wasm # produce crates/malt_wasm/pkg (the npm package contents)
mise run test-wasm # run the host-side binding testsWhy the WASI SDK? The
tree-sitter-matlabgrammar ships a C parser that must be cross-compiled towasm32-unknown-unknown. malt uses the WASI SDK'sclangand sysroot headers, with__wasi__defined to skip the host-onlyduppath in tree-sitter's C runtime. The resulting module is a standard browser wasm with no WASI imports.
The built package lands in crates/malt_wasm/pkg/. Releases are published automatically: when a pull request into main is merged, release.yml stamps the version, builds the package, and publishes it with npm publish through npm trusted publishing (OIDC, no long-lived token; provenance is attached automatically). See CONTRIBUTING.
Local docs build
The Playground runs the WebAssembly build that ships inside the site: the Docs workflow builds it from the same commit as the documentation, so the playground always matches the rules documented next to it. To preview the docs locally, build it once:
mise run build-wasm
mise run serve-local-wasm # copies crates/malt_wasm/pkg -> docs/public/assets/malt-wasm
bun run docs:dev