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-prettierandstylelint-prettierwould 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:formatwould check the formatting of all files Prettier supportslint:formatwould also run when running thelintscriptformatwould format all files Prettier supportsformatwould also run when running thelint:fixscript
NOTE: We use
formatinstead oflint:format:fix, because we don't want to run Prettier parallel to ESLint and Stylelint when fixing lint errors. Thelint:fixscript will be updated to always runformatlast.
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-prettierinstalled, 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