@astroapps/prettier-plugin-evaluator
v0.1.0
Published
Prettier plugin for evaluator expressions (.al files)
Readme
@astroapps/prettier-plugin-evaluator
Prettier plugin for evaluator expressions (.al files), built on the Lezer grammar from @astroapps/evaluator.
Install
npm install --save-dev prettier @astroapps/prettier-plugin-evaluatorPrettier is a peer dependency: 3.8 or a later 3.x.
Usage
Add the plugin to your Prettier config. The override keeps it to .al files:
{
"overrides": [
{
"files": "*.al",
"options": {
"plugins": ["@astroapps/prettier-plugin-evaluator"]
}
}
]
}Prettier then picks the evaluator parser for .al files by extension. Formatting other file types, or a string through the API, needs parser: "evaluator":
import { format } from "prettier";
import plugin from "@astroapps/prettier-plugin-evaluator";
await format("$sum( $a , [1,2] )", { parser: "evaluator", plugins: [plugin] });
// "$sum($a, [1, 2])\n"The standard layout options (printWidth, useTabs, tabWidth) apply. Comments are kept.
Development
rushx testruns the formatting tests againstsrc/, so they need no build.rushx buildtypechecks, then compilessrc/tolib/withtsc.rushx test:distchecks that the built package loads by name on plain Node and formats. Run it afterbuild.sample.alis a file to try the formatter on.
The source only uses erasable syntax (erasableSyntaxOnly) and imports local files with their .ts extension, which the build rewrites to .js. The config is TypeScript 7 ready (no moduleResolution: node). Check with npx -p typescript@7 tsc.
