Skip to content

Commit

Permalink
chore: add .prettierignore
Browse files Browse the repository at this point in the history
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
  • Loading branch information
chancancode committed Dec 13, 2024
1 parent e4d9c21 commit 4a17ddb
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -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/

0 comments on commit 4a17ddb

Please sign in to comment.