From ca9de44f9e3b7119b5e21f222a30aed48039b13a Mon Sep 17 00:00:00 2001 From: Godfrey Chan Date: Thu, 12 Dec 2024 18:45:06 -0800 Subject: [PATCH] chore: add .prettierignore Currently, this project uses `prettier` to enforce consistent formatting, but only via the `eslint-plugin-prettier` integration, which only covers `*.js` and `*.ts` files in sub-packages with ESLint setup. Notably, this setup is [not recommended by the prettier project][1]. The recommended setup is to use prettier as a standalone tool, and use `eslint-plugin-config` to disable any conflicting rules. In my experience that does result in a better development experience and this is worth revisiting in the future. However, this PR doesn't aim to change that at this moment. The issue I'm trying to address is that prettier as a tool covers a wide variety of file formats beyond JavaScript, including JSON, YAML markdown, and more. When using an editor that comes with prettier integration (such as VSCode + the prettier extension), it will see that the project uses prettier, but it doesn't know the project only uses it via ESLint. Thus, when saving a file not currently covered by our set up, such as CHANGELOG.md, it may attempt to re-format the file according to prettier's conventions, causing unnecessary diffs that then need to be reverted. This solves the issue by adding a `.prettierignore` file that tries to ignore everything that isn't intended to be formatted. This is obtained by trial-and-error, until running `npx prettier -w .` no longer result in any changes. Most of the changes that prettier would have made are actually quite minor, and IMO good. If there is appetite in revisiting the prettier setup and commiting those changes, I am happy to propose that in a different PR. [1]: https://prettier.io/docs/en/integrating-with-linters#notes --- .prettierignore | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 .prettierignore diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000000..8f47b69a38 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,18 @@ +**/*.md +**/*.yaml +**/*.yml +**/*.json +**/*.jsonc +**/.nycrc +**/.eslint.js +**/.eslintrc.js +**/eslint*.js +**/karma*.js +**/benchmark/ +**/examples/ +**/fixtures/ +**/scripts/ +integration-tests/ +selenium-tests/ +semantic-conventions/ +experimental/backwards-compatibility/