brodycj / prettierx

a less opinionated fork of Prettier code formatter
MIT License
209 stars 22 forks source link

[prettierx] make the estree printer (more) pluggable #74

Open brodycj opened 4 years ago

brodycj commented 4 years ago

src/language-js/printer-estree.js seems to be a monolithic set of functions to format all possible elements of an estree that comes in some form from the parser

I wonder if there could be a way to make this functionality more pluggable somehow, in a similar fashion to the way Babel and ESLint can work with parsing, analysis, and formatting plugins.


related (2021):

brodycj commented 3 years ago

related: https://github.com/prettier/prettier/issues/4424 - support library-specific plugin

brodycj commented 3 years ago

quoting my comment in https://github.com/brodybits/prettierx/issues/8#issuecomment-468468549:

I think the ultimate design would be a pipeline-based toolset which uses the Acorn parser data structure, which seems to be how Babel JS works. I really like the general design of remark (https://remark.js.org/), which does Markdown processing in a set of plugins and is based on unifiedjs (https://unified.js.org/).

A step further may be to use a Flow Based Programming paradigm, like they did in noflo/noflo-jekyll (see this article and duplicate article on dzone).