Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: infer prettier parser from file extension #435

Merged
merged 2 commits into from
Nov 17, 2024

Conversation

mikavilpas
Copy link
Contributor

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:

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:

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.

@justinmk
Copy link
Member

Thanks, mind rebasing?

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
neovim@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.
@mikavilpas
Copy link
Contributor Author

Just rebased to master - I kept the new printWidth prettier setting you added in #444

I also ran npx prettier --write . in another commit to keep things simple.

@justinmk justinmk changed the title chore: infer prettier parser from file extension build: infer prettier parser from file extension Nov 17, 2024
@justinmk justinmk merged commit 366d6a7 into neovim:master Nov 17, 2024
10 checks passed
@mikavilpas mikavilpas deleted the fix-prettier-parser branch November 17, 2024 13:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants