Gathering detailed insights and metrics for @stedi/prettier-plugin-jsonata
Gathering detailed insights and metrics for @stedi/prettier-plugin-jsonata
Gathering detailed insights and metrics for @stedi/prettier-plugin-jsonata
Gathering detailed insights and metrics for @stedi/prettier-plugin-jsonata
npm install @stedi/prettier-plugin-jsonata
Typescript
Module System
Node Version
NPM Version
76.7
Supply Chain
97.5
Quality
76.2
Maintenance
100
Vulnerability
99.6
License
TypeScript (98.4%)
JavaScript (1.6%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
13 Stars
744 Commits
2 Forks
3 Watchers
5 Branches
11 Contributors
Updated on Jun 05, 2025
Latest Version
2.1.3
Package Id
@stedi/prettier-plugin-jsonata@2.1.3
Unpacked Size
8.12 MB
Size
2.08 MB
File Count
71
NPM Version
9.9.3
Node Version
18.20.0
Published on
Apr 05, 2024
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
1
1
21
Format your JSONata expressions using Prettier.
A Prettier plugin must first parse the source code of the target language into a traversable data structure (Usually an Abstract Syntax Tree) and then print out that data structure in a "pretty" style.
prettier-plugin-jsonata uses the JSONata parser available as part of the jsonata package.
printWidth
, tabWidth
, and useTabs
formatting options are supported.1# Install locally in a project 2npm install --save-dev @stedi/prettier-plugin-jsonata prettier 3 4# Or globally 5npm install -g @stedi/prettier-plugin-jsonata prettier
Once you installed prettier
and prettier-plugin-jsonata
as dev dependencies in your project,
you can format your code using Prettier CLI.
npx prettier --write ./**/*.jsonata
You can format your JSONata expressions using Prettier's own format
method like this:
1import * as prettier from "prettier"; 2import * as prettierPlugin from "@stedi/prettier-plugin-jsonata"; 3 4const expression = "($myVar:=foo.bar[]; $reverse($myVar))"; 5const formattedExpression = prettier.format(expression, { 6 parser: prettierPlugin.AST_PARSER_NAME, 7 plugins: [prettierPlugin], 8 printWidth: 150, 9 tabWidth: 2, 10 useTabs: false, 11}); 12 13console.log(formattedExpression);
Alternatively, you can use the formatJsonata
function:
1import { formatJsonata } from "@stedi/prettier-plugin-jsonata/dist/lib"; 2 3async function format() { 4 const expression = "($myVar:=foo.bar[]; $reverse($myVar))"; 5 const formattedExpression = await formatJsonata(expression); 6 7 console.log(formattedExpression); 8} 9 10format().catch((e) => { 11 console.log(e); 12});
If you parse JSONata as part of your business logic and only need to print JSONata AST tree as a formatted string,
you can use serializeJsonata
function:
1import jsonata from "jsonata"; 2import { serializeJsonata } from "@stedi/prettier-plugin-jsonata/dist/lib"; 3 4async function serialize() { 5 const jsonataAST = jsonata("($myVar:=foo.bar[]; $reverse($myVar))").ast(); 6 const formattedExpression = await serializeJsonata(jsonataAST); 7 8 console.log(formattedExpression); 9} 10 11serialize().catch((e) => { 12 console.log(e); 13});
No vulnerabilities found.
No security vulnerabilities found.