nene / prettier-plugin-sql-cst

Prettier SQL plugin that uses sql-parser-cst

Home Page:https://nene.github.io/prettier-sql-playground/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Automate checking the completeness of Cst -> Doc functions

nene opened this issue · comments

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.