From 0e0786af7d11c396fc9bb4c73f3ec4cda3deb8c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filiph=20Siitam=20Sandstr=C3=B6m?= Date: Sat, 21 Oct 2023 10:51:45 +0200 Subject: [PATCH] docs: add `package.json` tip to improve a prettier setup Seen a lot of people get this wrong, so let's add a tip explaining the benefits of setting the prettier configuration in `package.json` rather than `.prettierrc` or `prettier.json`. --- .../tips/prettier-config-in-package-json.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 src/content/tips/prettier-config-in-package-json.md diff --git a/src/content/tips/prettier-config-in-package-json.md b/src/content/tips/prettier-config-in-package-json.md new file mode 100644 index 0000000..c33ddc1 --- /dev/null +++ b/src/content/tips/prettier-config-in-package-json.md @@ -0,0 +1,15 @@ +--- +kind: package-json +title: Set package-level Prettier configuration +description: Keep the project's root folder clean from extra configuration files while enforcing an organization-wide codestyle. +contributor: https://github.com/filiphsps +snippet: | + { + "prettier": "@nordcom/prettier", + "scripts": { + "@nordcom/prettier": "0.1.1" + } + } +--- + +By setting the Prettier configuration directly in `package.json`, you avoid both the issue of saturating your workspace's root folder with another config file as well as arguably more importantly also completely eliminating inconsistencies in Prettier rules between projects.