JsLIGO formatting rules vs Typescript
While ligo pretty print for jsligo is not optimal, I tried to use prettier with typescript conf instead. If you want to test :
- install prettier in your ligo project
npm i -D prettier
- create a config file
.prettierrc.toml
with
[[overrides]]
files = "*.jsligo"
[overrides.options]
parser = "typescript"
- run
npx prettier **/*.jsligo
Seems that current state of pretty printer for typescript is to use prettier (tslint is deprecated, eslint tsplugin does not have style rules / focus on linting). If you don't know prettier, it is very opinionated and their is very few custom rules. So non custom rules have a good chance to be the default style for a js/ts dev.
I tried to use it with jsligo but i detected some frontend incompatibilities.
|
prefix for multiline union
Before:
type planetType =
{ kind: "Tellurian" }
| { kind: "Gaseous" }
| { kind: "Other" };
After:
type planetType =
| { kind: "Tellurian" }
| { kind: "Gaseous" }
| { kind: "Other" };
=> doesn't compile in jsligo (but valid TS)
Use of ;
to separate members of a record type.
Before
type planet = {
name: string,
planetType: planetType,
lord: option<address>
};
after
type planet = {
name: string;
planetType: planetType;
lord: option<address>;
};
=> doesn't compile in jsligo (but valid TS where you can either use ; or , pretty printer rule is ;
for type, ,
for values)
I wrote here to keep as a record