stackblitz / starters

StackBlitz Starter Project
MIT License
37 stars 16 forks source link

Add Prettier code formatting for starter templates #11

Closed fvsch closed 1 year ago

fvsch commented 1 year ago

StackBlitz uses Prettier 2.x by default on most common frontend code, defaulting to format files on save.

When users fork a starter template such as the react-ts template and then edit a file and save, that file may get reformatted by Prettier with different settings than what was used to produce that starter template. This can look a bit glitchy, because the end user only changed a few characters but potentially many more characters are going to be modified by Prettier.

To avoid this issue, the starter templates in this repository should be formatted using Prettier, with default settings that are identical to the default settings used on stackblitz.com.

As far as I can tell, stackblitz.com:

In this PR I'm adding:

  1. A .prettierrc config suitable to mimic what stackblitz.com uses by default;
  2. Prettier as a dev dependency;
  3. A GitHub action checking PRs for correct formatting.

So far I have not reformatted all templates. As a proof of concept, I only reformatted the EngineBlock templates, and have added all other templates to .prettierignore. We could reformat all templates in this PR, or in a subsequent PR.