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

feat: upgrade to prettier 3 and prettier-plugin-svelte 3 #10410

Merged
merged 17 commits into from
Nov 13, 2023
Merged

Conversation

benmccann
Copy link
Member

@benmccann benmccann commented Jul 19, 2023

This will give users the new versions via create-svelte. The rest of the change is internal

closes #10751
closes #10716

@changeset-bot
Copy link

changeset-bot bot commented Jul 19, 2023

🦋 Changeset detected

Latest commit: 2954e8b

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
create-svelte Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@benmccann benmccann requested a review from dummdidumm July 19, 2023 16:00
@dummdidumm
Copy link
Member

This needs some additional adjustments which i wrote down here. TLDR config file adjustments, needs --plugin prettier-plugin-svelte in the package.json script.

Given all this is quite new we may want to wait a few more weeks, maybe Prettier fixes the upstream bug by then.

@benmccann
Copy link
Member Author

Okay. Seems this is blocked by prettier/prettier#15079. There's a PR for it, so hopefully we don't have to wait too long: prettier/prettier#15155

@benmccann
Copy link
Member Author

benmccann commented Sep 26, 2023

prettier/prettier#15433 was merged with the fix. It's not been released yet though. It looks like it will be included in prettier 3.1 (prettier/prettier#15462)

@polyzen
Copy link

polyzen commented Nov 13, 2023

Prettier 3.1 has been released with the fix 🚀

@@ -25,7 +25,7 @@
"adapters.js"
],
"scripts": {
"lint": "prettier --check . --config ../../.prettierrc --ignore-path .gitignore",
Copy link
Member

Choose a reason for hiding this comment

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

I saw these were removed - could someone clarify why? Or why they were needed before? (probably related to the major version bump?)

Copy link
Member Author

Choose a reason for hiding this comment

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

Prettier now ignores files in .gitignore by default. It will also search up the directory tree for a config file, so you don't need to point at the config file

@dummdidumm dummdidumm merged commit cbd60cc into master Nov 13, 2023
14 checks passed
@dummdidumm dummdidumm deleted the prettier-3 branch November 13, 2023 20:13
@github-actions github-actions bot mentioned this pull request Nov 13, 2023
@hyunbinseo
Copy link
Contributor

Finally! A migration guide would be nice for existing projects.

# jsconfig.json, tsconfig.json
+ "moduleResolution": "bundler"
# package.json
- "lint": "prettier --plugin-search-dir . --check . && eslint .",
- "format": "prettier --plugin-search-dir . --write ."
+ "lint": "prettier --check . && eslint .",
+ "format": "prettier --write ."
# package.json
- "prettier": "^2.8.8",
- "prettier-plugin-svelte": "^2.10.1",
+ "prettier": "^3.1.0",
+ "prettier-plugin-svelte": "^3.1.0",
# .prettierrc
- "pluginSearchDirs": ["."],

@@ -3,7 +3,7 @@
"eslint-config-prettier": "^8.5.0"
Copy link
Contributor

Choose a reason for hiding this comment

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

Can't eslint-config-prettier be bumped to v9? It does not depend on Prettier v3, but it is the only outdated package as of now. Changelog

Copy link
Member Author

Choose a reason for hiding this comment

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

yes. thanks for the suggestion. PR here: #11037

@benmccann
Copy link
Member Author

Thanks for the suggestion of the migration guide. I'm not sure where such a migration guide would live though? Maybe your comment serves as a migration guide?

@hyunbinseo
Copy link
Contributor

The comment can work as a guide, but it should be added to the documentation.

Similar case: migration to eslint-plugin-svelte docs links to a GitHub comment.


I do wish there was an official guide to bumping packages' major versions.

If the user started with create-svelte@3.0.0, these packages are outdated.

Package Current Latest Migration
@typescript-eslint/eslint-plugin (dev) 5.62.0 6.11.0 None
@typescript-eslint/parser (dev) 5.62.0 6.11.0 None
eslint-config-prettier (dev) 8.10.0 9.0.0 None - PR in process
prettier (dev) 2.8.8 3.1.0 pacakge.json scripts, .prettierrc
prettier-plugin-svelte (dev) 2.10.1 3.1.0 pacakge.json scripts, .prettierrc
svelte (dev) 3.59.2 4.2.3 Reference Svelte docs
typescript (dev) 4.9.5 5.2.2 Mention moduleResolution: bundler
eslint-plugin-svelte3 4.0.0 - Should be uninstalled
eslint-plugin-svelte - 2.35.0 Should be installed, migration

This will allows users to update their dependencies with confidence.

@dummdidumm
Copy link
Member

The place to add that documentation would be the prettier-plugin-svelte repository. It already contains a small section at the bottom of the readme. Happy to accept a PR with more migration instructions.

velut added a commit to velut/videospeedup.com that referenced this pull request Nov 26, 2023
Upgrade prettier and plugins.
Update scripts.
Format files.

See sveltejs/kit#10410 (comment).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants