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

chore: use prettier as default formatter in vscode #13721

Merged
merged 2 commits into from
Jan 3, 2023

Conversation

unional
Copy link
Contributor

@unional unional commented Jan 3, 2023

Summary

This helps contributors to use the right formatter to avoid messing up the style.

For example, I do not use prettier as my default formatter. So when I change code and run formatter through muscle memory,
my vscode uses the default typescript formatter which mess up the styling of the code.

Test plan

None. Project config change only.

This helps contributors to use the right formatter to avoid messing up the style
@SimenB
Copy link
Member

SimenB commented Jan 3, 2023

We run prettier via ESLint - can we configure VS Code to use that?

@unional
Copy link
Contributor Author

unional commented Jan 3, 2023

We run prettier via ESLint - can we configure VS Code to use that?

dbaeumer.vscode-eslint is not a valid formatter (it does not provide that contribution). I check several files and the prettier extension is doing the job correctly. Didn't mess up any files.

I'm going to do one more commit, with:

  "typescript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces": false,
  "typescript.format.semicolons": "insert",

To make organize import "almost" work.

Since prettier is used as the default formatter,
these setting only affects "organize import" command.
Which is what we want.

It doesn't work completely, as this:

```ts
import type {
  JestHookSubscriber,
  UpdateConfigCallback,
  UsageData,
  WatchPlugin,
} from './types';
```

will be formatted as:

```ts
import type {
  JestHookSubscriber,
  UpdateConfigCallback,
  UsageData,
  WatchPlugin   // <-- comma removed
} from './types';
```

Running format doc (prettier) will fix that.
It is better than not having it.
@SimenB
Copy link
Member

SimenB commented Jan 3, 2023

Works for me 🙂 I don't use VS Code, so cannot verify

@SimenB SimenB merged commit 6cd65a1 into jestjs:main Jan 3, 2023
@unional unional deleted the prettier branch January 3, 2023 08:08
@github-actions
Copy link

github-actions bot commented Feb 3, 2023

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 3, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants