Skip to content

Commit

Permalink
chore: infer prettier parser from file extension
Browse files Browse the repository at this point in the history
Issue
=====

The prettier parser was set to `typescript` in the `.prettierrc.json` file. Because prettier was
used for multiple files types, it caused errors when formatting files that were not TypeScript.

Here is an example:

```sh
README.md
[error] README.md: SyntaxError: Invalid character. (1:1)
[error] > 1 | # Neovim node.js client
[error]     | ^
[error]   2 |
[error]   3 | | CI (node >= 14, Linux/macOS/Windows) | Coverage | npm |
[error]   4 | |----------------------------|----------|-----|
```

This seems to cause the build to fail as of the most recent commit
7488014

Solution
========

Automatically infer the parser based on the file extension.

References:
- https://prettier.io/docs/en/configuration.html#setting-the-parserdocsenoptionshtmlparser-option

To make the build pass, run `npx prettier --write .` to format all files. I think it's best that
someone else does this, as it will change the formatting of many files (currently 43), and reviewing
them is very difficult.
  • Loading branch information
mikavilpas committed Nov 17, 2024
1 parent 8702dcd commit 74a6632
Showing 1 changed file with 0 additions and 1 deletion.
1 change: 0 additions & 1 deletion .prettierrc.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"tabWidth": 2,
"trailingComma": "es5",
"parser": "typescript",
"printWidth": 100,
"singleQuote": true,
"arrowParens": "avoid"
Expand Down

0 comments on commit 74a6632

Please sign in to comment.