Automatic code formatting via prettier

Feature Request

Is your feature request related to a problem? Please describe.

Code formatting is manual which is tedious, it places increased cognitive load on the developer because formatting is not very consistent. Simply inserting white space causes red errors in your editor, which could easily be auto-fixed.

Describe the solution you’d like

Add prettier

Describe alternatives you’ve considered


(If this is new operator request) describe reason it should be core operator


Additional context

You have a few options:

  • Rip the band aid off. Apply it to whole project, merge master in open PRs at the commit prior to applying it, then merge in the application of prettier to open PRs with strategy –theirs. Conflicts due to formatting will not occur as part of the conversion, and Prettier will tend to decrease formatting related PR friction going forward.
  • Use a tool that incrementally applies the formatting only to lines as they are changed, this avoids the rip the band aid off approach, however this makes things worse for a long time before they become better. There will be increased merge conflicts / PR churn for a long time.

Also consider:

You use formatting that isn’t represented in the AST, eg indenting lines to visually align for marble tests. In these cases, we would lose some manual formatting (but keep in mind this manually formatting can really irk some devs). You’d probably need to fix some marble tests to put the whitespace inside the string so the alignment tokens are part of the AST nodes.

This would actually make things more approachable. Most projects today written in JS/TS are using Prettier, and the maintainers of RxJs are creating tools, like Marble tests, which are less approachable if you’re not manually formatting your code base like the RxJs maintainers are.

1 possible answer(s) on “Automatic code formatting via prettier