Vanilla Prettier Setup in Blueprints
Summary
This RFC proposes to migrate to a vanilla Prettier setup in the blueprints, instead of running Prettier via ESLint and Stylelint.
Motivation
- Because we run Prettier via ESLint and Stylelint, we only run the files these linters support through Prettier - Using a vanilla Prettier setup, would format all files Prettier supports, ensuring even more consistency in projects
- Less dependencies in the blueprints -
eslint-plugin-prettier
andstylelint-prettier
would not be needed anymore - The Prettier team recommends running Prettier directly, and not via linters:
- Running Prettier directly is faster than running Prettier via ESLint and Stylelint
- ESLint and Stylelint show red squiggly lines in editors (when using the corresponding extensions), while the idea behind Prettier is to make developers forget about formatting
3.
is mostly taken from Integrating with Linters > Notes
Detailed Design
We would add the following scripts to the package.json
file in the app
blueprint:
+ "format": "prettier . --cache --write",
+ "lint:format": "prettier . --cache --check",
lint:format
would check the formatting of all files Prettier supportslint:format
would also run when running thelint
scriptformat
would format all files Prettier supportsformat
would also run when running thelint:fix
script
NOTE: We use
format
instead oflint:format:fix
, because we don't want to run Prettier parallel to ESLint and Stylelint when fixing lint errors. Thelint:fix
script will be updated to always runformat
last.
We would remove the following dependencies from the package.json
file in the app
blueprint:
- "eslint-plugin-prettier": "*",
- "stylelint-prettier": "*",
As these would not be needed anymore.
NOTE: We will keep
eslint-config-prettier
installed, as we need this package to turn off the stylistic ESLint rules that might conflict with Prettier.
We would update the .prettierignore
file in the app
blueprint:
+ /pnpm-lock.yaml
To make sure Prettier does not format pnpm's lockfile.
We would also need to make sure that every file generated by the app
blueprint is formatted correctly.
How We Teach This
N/A
Drawbacks
- Some developers or teams prefer running Prettier via ESLint and Stylelint
Alternatives
N/A
Unresolved Questions
N/A