backstage-plugin-confluence
backstage-plugin-confluence copied to clipboard
Enforce Prettier Format; Format All
When pulling in a few patches (first, second), I was encountering merge conflicts because both do significant auto-formatting. This patch makes a few changes:
- Adds installing pre-commit hooks to the README, so everyone should have consistent formatting (1 formats to removing spaces in
import {Thing} from package
, which having the pre-commit hooks installed would fix) - Enforces prettier code style in CI, by adding a
yarn lint:prettier
target and running itconcurrently
withyarn lint:all
- Fixes existing non-compliant code by running a full pass of
prettier --ignore-path .gitignore --write .
- Adds YAML files to
lint-staged
config
Together, this should make sure future patches are much smaller.
I chose to use --ignore-path
to set the .gitignore
as the .prettierignore
. This is a tradeoff. Editors are not aware of this option, as it is set in the package.json
scripts and not in the prettier config (https://github.com/prettier/prettier/issues/8192). Since Prettier 3 is not released, stable Prettier can't have multiple ignore paths (https://github.com/prettier/prettier/pull/14332). Since there is no .prettierignore
in this project, I figured having just the one set to .gitignore
should be fine.
(The alternative, which we do, is duplicating all of .gitignore
in .prettierignore
, and then having additional things that we want checked into git but not linted also specified in .prettierignore
. This is very annoying to me, and I hope https://github.com/prettier/prettier/issues/8192 is done so we can have .gitignore
and a non-duplicated .prettierignore
set as ignore files in config and auto-picked up by editors and CLI prettier
.)
The only significant changes made are in README.md
and package.json
-- everything else is formatting, and isolated to a formatting commit.