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

Bump Prettier to v3 #4264

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft

Bump Prettier to v3 #4264

wants to merge 2 commits into from

Conversation

mcmire
Copy link
Contributor

@mcmire mcmire commented May 7, 2024

Explanation

Prettier 3 has the ability to read from both .gitignore and .prettierignore. This allows us to finetune what we exclude from Prettier vs. Git in a consistent manner (using configuration files instead of passing arguments to prettier). We will make use of this in a future commit.

However as v3 makes some backward-incompatible changes to the formatting rules, this commit applies fixes to all files so that they pass lint again.

References

Prerequisite to #4261.

Changelog

(N/A)

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've highlighted breaking changes using the "BREAKING" category above as appropriate

Prettier 3 has the ability to read from both `.gitignore` and
`.prettierignore`. This allows us to finetune what we exclude from
Prettier vs. Git in a consistent manner (using configuration files
instead of passing arguments to `prettier`). We will make use of this in
a future commit.

However as v3 makes some backward-incompatible changes to the formatting
rules, this commit applies fixes to all files so that they pass lint
again.
@mcmire mcmire requested review from a team as code owners May 7, 2024 17:07
Copy link

socket-security bot commented May 7, 2024

New dependencies detected. Learn more about Socket for GitHub ↗︎

Package New capabilities Transitives Size Publisher
npm/eslint-config-prettier@9.1.0 None 0 20.8 kB lydell
npm/eslint-plugin-prettier@5.1.3 None 0 33.9 kB jounqin
npm/prettier@3.2.5 environment, filesystem, unsafe 0 8.39 MB prettier-bot
npm/synckit@0.8.8 environment 0 54.5 kB jounqin

View full report↗︎

@@ -2,6 +2,7 @@
* @type {import('prettier').Options}
*/
module.exports = {
plugins: ['prettier-plugin-packagejson'],
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It appears that Prettier no longer autodetects plugins in v3. I couldn't find any mention of this in the release notes, but I found this necessary to add to format package.json correctly.

@mcmire
Copy link
Contributor Author

mcmire commented May 7, 2024

Sigh.

Upgrading to Prettier 3 isn't possible to do right now because when running tests for scripts/create-package I get this error:

Error: You need to run with a version of node that supports ES Modules in the VM API. See https://jestjs.io/docs/ecmascript-modules

This is happening because Prettier is now written in ESM and their CommonJS implementation mistakenly imports their ESM implementation. Modern versions of Node seems to be able to cope with this just fine, but not Jest. This is because Jest tests run in a VM, and their ES module support is still under an experimental flag (source). This is an ongoing issue that's being tracked here and to some extent here.

Besides this, there's also an issue with snapshots. This will be resolved in Jest 30.

@mcmire mcmire marked this pull request as draft May 7, 2024 18:08
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.

None yet

1 participant