Prettier plugin for FHIRPath language using ANTLR4 grammar
yarn add --dev prettier-plugin-fhirpath
In .prettierrc.js
...
plugins: ["prettier-plugin-fhirpath"]
...
There are no general rules are described for the moment anywhere, so based on the experience of writing quite long and complex expressions there are some rules of formatting introduced for better readability:
- Parentheses content should be split by new lines if the content length is more than N characters or more than one argument is used in the function
Should not be formatted with new lines:
repeats(item)
(1 + 1)
where(code = 'value')
Should be formatted with new lines:
iif(
%var > 1,
1,
2
)
where(
code = %var.very.long.path.to.the.value
)
- Binary operator should be split by new lines if the total length is more than N characters
Should not be formatted with new lines:
code in 'a' | 'b' | 'c'
Should be formatted with new lines:
code in 'very-long-code-first' |
'very-long-code-second' |
'very-long-code-third'
- Spaces around operators and keywords always should be used
where(code = 'value1' or code = 'value2')
1 + 1 / 1
- .fhirpath
- .yaml (embedded inside
expression
)
- .jsx?/.tsx? (embedded inside
fhirpath
template) - FHIRPath Mapping Language embedded support inside
{{ }}
and etc - FSH embedded support inside
[[ ]]
- Initial release