nene / prettier-plugin-sql-cst

Prettier SQL plugin that uses sql-parser-cst
https://nene.github.io/prettier-sql-playground/
GNU General Public License v3.0
123 stars 7 forks source link

Automate checking the completeness of Cst -> Doc functions #20

Closed nene closed 7 months ago

nene commented 7 months ago

A common problem I'm facing is when new properties are added to the Cst nodes, TypeScript won't complain, like when there's a rule like:

alias: (print) => print.spaced(["expr", "asKw", "alias"]),

when a new property is introduced to alias node, it's easy to forget to update the "alias" rule. In particular, it's really hard to be sure that for all nodes, all fields get actually pretty-printed. Forgetting that will result in prettier deleting parts of code, which is really bad because it's a silent error.

It should be possible to automatically check e.g. the strings used inside the expression and compare it to fields defined in the related interface.