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

Prettier 3.0 #171

Closed
mattbrannon opened this issue Jul 6, 2023 · 62 comments · Fixed by #199
Closed

Prettier 3.0 #171

mattbrannon opened this issue Jul 6, 2023 · 62 comments · Fixed by #199
Assignees

Comments

@mattbrannon
Copy link
Contributor

mattbrannon commented Jul 6, 2023

Prettier just released a new major version which includes some breaking changes to the API. Currently Prettier 3.0 causes the extension to throw a type error:

Error: Expected `input` to be a `string`, got `object` 
TypeError: Expected `input` to be a `string`, got `object`

I haven't looked into the source code for Prettier or this extension for a while so I don't know how difficult of a fix this is.

If anyone is having this same issue, the short term solution is to explicitly install a version of prettier before 3.0.

@mattbrannon
Copy link
Contributor Author

More info in this PR

@Catatomik
Copy link

Any update on this ?
Is there a roadmap ?

@github-actions
Copy link

This issue is stale because it has been open for 14 days with no activity.

@github-actions github-actions bot added the stale label Aug 31, 2023
@HoltMansfield
Copy link

Please fix this. I can no longer use your plugin and I have severe health problems. I need this automation.

@github-actions github-actions bot removed the stale label Sep 8, 2023
@zhangjie1314
Copy link

Please fix it, thank you.

@PrinceGuidon
Copy link

Any update on this?

@danielwerg
Copy link

prettier/prettier-eslint#901 just got merged.

@arange
Copy link

arange commented Oct 18, 2023

Any update? Much appreciated

@maxkostow
Copy link

Seems like this should be fixed by #187

@idahogurl
Copy link
Owner

idahogurl commented Oct 27, 2023

Sorry for the lack of response. I've been dealing with medical issues in addition to everything else. Someone created a PR to update everything (#189) but it needs some changes and I don't have much time to help. Also, the automated deploy isn't working and could use some help there.

@idahogurl
Copy link
Owner

idahogurl commented Oct 27, 2023

I did a little testing of #189 and upgrading to Prettier 3 is not an option at this time. I am getting the same error as prettier/prettier-vscode#3114 describes when I try to run my extension. Prettier 3 added a dynamic import() in its .cjs file, making ESM support required. VS Code only supports CommonJS (CJS) however. Basically we are stuck with Prettier 2 unless I decide to bundle Prettier 3 and somehow get the bundler to process the dynamic import.

@KillDozerX2
Copy link

Sorry for the lack of response. I've been dealing with medical issues in addition to everything else. Someone created a PR to update everything (#189) but it needs some changes and I don't have much time to help. Also, the automated deploy isn't working and could use some help there.

Do you still need help resolving automated deploys?

@idahogurl
Copy link
Owner

@KillDozerX2 I do still need help with automated deploys. I'm using Auto (docs) to automate the deploys. I think I have it setup wrong. When I run the release workflow it should see there is a new version and publish the extension, but it doesn't. Here is their example: https://intuit.github.io/auto/docs/build-platforms/github-actions

I think it only works with this workflow: https://intuit.github.io/auto/docs/generated/shipit#release-pipeline

@JounQin
Copy link

JounQin commented Nov 22, 2023

I would recommend to migrate to changesets instead.

And it maybe great to migrate this repo into the prettier org just like prettier-eslint, how do you think?

@exceptionptr
Copy link

exceptionptr commented Nov 25, 2023

I created something based on your work @idahogurl.
The key was to use worker_threads. Prettier is doing this as well for their VSCode extension.

Tested with:

"prettier": "3.1.0"
"prettier-eslint": "16.1.2"
"@typescript-eslint/parser": "6.12.0"
"typescript": "5.3.2"

(https://github.com/0x2aff/vscode-prettier-eslint)
(https://marketplace.visualstudio.com/items?itemName=exceptionptr.vscode-prettier-eslint)

@idahogurl
Copy link
Owner

@0x2aff I actually tried using worker threads as well but it wasn't applying the Prettier config in my tests. I'll have to try your code and see if I can't get my tests to pass.

@JounQin
Copy link

JounQin commented Nov 27, 2023

Or you can try https://github.com/un-ts/synckit to simplify.

@idahogurl
Copy link
Owner

@0x2aff I tried your extension and it has the same problem with my test file. I'll create an issue in your repository and provide the files needed to reproduce.

@DucNg
Copy link

DucNg commented Dec 1, 2023

Here is a PR attempting to fix the issue, does it works for you? #198

@idahogurl idahogurl self-assigned this Dec 1, 2023
Copy link

Click here to create a branch for this issue

Copy link

Branch 171-prettier-3-0
created for this issue. Run command below in your terminal to checkout branch.
git fetch && git checkout 171-prettier-3-0

@idahogurl
Copy link
Owner

idahogurl commented Dec 1, 2023

I do have a beta version of the extension working with Prettier 3. It has some breaking changes:

  • prettier-eslint is now required as a dev dependency
  • Prettier v3.0 is now required
  • ESLint >= v8.52.0 is now required

Download and install the extension from here:
vs-code-prettier-eslint-6.0.0-beta.vsix.zip

Once I have enough people testing it, I will making it available as a general release. Let me know if you find any issues with it.

@mattbrannon
Copy link
Contributor Author

@idahogurl The latest beta version works great for me. I'm not seeing any noticeable delay when formatting.

@idahogurl
Copy link
Owner

@netux @jaschaephraim Try this version. I preloaded the worker.
vs-code-prettier-eslint-6.0.0-beta.2.vsix.zip

@jaschaephraim
Copy link

@idahogurl beta 2 performs just like beta 1, still a short delay on the first run only

@jaulz
Copy link

jaulz commented Dec 12, 2023

@DucNg Did you install prettier-eslint locally?

I installed prettier-eslint both globally as well as locally in my project but still I see the issue:

Error: Cannot find module 'prettier-eslint'
Require stack:
- /Users/julian/.vscode/extensions/rvest.vs-code-prettier-eslint-6.0.0-beta.2/dist/extension.js
- /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/loader.js
- /Applications/Visual Studio Code.app/Contents/Resources/app/out/bootstrap-amd.js
- /Applications/Visual Studio Code.app/Contents/Resources/app/out/bootstrap-fork.js
- 
	at Module._resolveFilename (node:internal/modules/cjs/loader:1129:15)
	at s._resolveFilename (node:electron/js2c/utility_init:2:2786)
	at h.resolve (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/loader.js:4:709)

Any idea what else could be missing?

@idahogurl
Copy link
Owner

@jaulz All I can think of is having you restart VS Code and creating a minimal reproduction project.

@Jmyerzzz
Copy link

what versions of prettier and prettier-eslint can I downgrade to to restore format on save functionality?

@uberubert
Copy link

I've been struggling with lack of format on save all day and haven't found a solution. I'll just add my +1.

@idahogurl
Copy link
Owner

idahogurl commented Dec 14, 2023

@Jmyerzzz @uberubert Format on save should be working. Can you provide further information as to exactly isn't working and perhaps a minimal reproduction project? Also, what version of VS Code are you running? I've been using the beta for a while now and haven't had issues. Last thing, have you checked the Output (described in the README in the troubleshooting section)? If there is an error it will show up there.

@JU12000
Copy link

JU12000 commented Dec 14, 2023

@idahogurl Using beta 1 at the moment in a mid-sized monorepo and not seeing any issues with formatting. However if I change my prettier or eslint config files I have to reload VSCode in order for the extension to pick up the changes and format properly again. Otherwise it works great, thank you for maintaining this extension 👍.

@Jmyerzzz
Copy link

@idahogurl

VSCode v1.85.1
prettier v3.1.1
prettier-eslint v16.1.2

Output:
TypeError: Expected input to be a string, got object

@idahogurl
Copy link
Owner

@Jmyerzzz You need to download and install the beta 1 version of the extension. Use this link
https://github.com/idahogurl/vs-code-prettier-eslint/files/13621102/vs-code-prettier-eslint-6.0.0-beta.1.vsix.zip

@idahogurl
Copy link
Owner

@netux @jaschaephraim Please try this new version to see if it speeds things up
vs-code-prettier-eslint-6.0.0-beta.3.vsix.zip

@jaschaephraim
Copy link

Still seeing the same short delay on the first format, very fast after that.

@ibussieres
Copy link

ibussieres commented Jan 9, 2024

I've been using beta3 all morning, It seems to be working fine! I'll be using it daily, so unless I report back, it's safe to assume that it's working well for me as well.

"eslint": "^8.52.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.1.2",
"prettier": "^3.1.1",
"prettier-eslint": "^16.2.0",

@AdamGerthel
Copy link

Beta 3 is working well for me

@jinsley8
Copy link

If you go to vscode settings and find Prettier: Prettier Path option, make sure this is empty.

My vscode keeps adding it back somehow then prettier stops working again.

@novarolV
Copy link

novarolV commented Jan 15, 2024

@idahogurl
Beta 3 is throwing this error on Windows for me:

Error: Only URLs with a scheme in: file and data are supported by the default ESM loader. On Windows, absolute paths must be valid file:// URLs. Received protocol 'c:' 
Error [ERR_UNSUPPORTED_ESM_URL_SCHEME]: Only URLs with a scheme in: file and data are supported by the default ESM loader. On Windows, absolute paths must be valid file:// URLs. Received protocol 'c:'
    at new NodeError (node:internal/errors:399:5)
    at throwIfUnsupportedURLScheme (node:internal/modules/esm/resolve:1065:11)
    at defaultResolve (node:internal/modules/esm/resolve:1141:3)
    at nextResolve (node:internal/modules/esm/loader:163:28)
    at ESMLoader.resolve (node:internal/modules/esm/loader:838:30)
    at ESMLoader.getModuleJob (node:internal/modules/esm/loader:424:18)
    at ESMLoader.import (node:internal/modules/esm/loader:525:22)
    at importModuleDynamically (node:internal/modules/esm/translators:110:35)
    at importModuleDynamicallyCallback (node:internal/process/esm_loader:35:14)
    at file:///c:/Users/username/.vscode/extensions/rvest.vs-code-prettier-eslint-6.0.0-beta.3/dist/worker.mjs:1:1394

Beta 1 doesn't have this issue.

VSCode:

Version: 1.85.1 (system setup)
Commit: 0ee08df0cf4527e40edc9aa28f4b5bd38bbff2b2
Date: 2023-12-13T09:49:37.021Z
Electron: 25.9.7
ElectronBuildId: 25551756
Chromium: 114.0.5735.289
Node.js: 18.15.0
V8: 11.4.183.29-electron.0
OS: Windows_NT x64 10.0.19045
"@typescript-eslint/parser": "^6.18.1",
"@vue/eslint-config-prettier": "^8.0.0",
"@vue/eslint-config-typescript": "^12.0.0",
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.1.3",
"eslint-plugin-vue": "^9.20.1",
"prettier": "^3.2.2",
"prettier-eslint": "^16.2.0",
"vue-eslint-parser": "^9.4.0"

@JounQin
Copy link

JounQin commented Jan 15, 2024

@novarolV
Copy link

@JounQin @idahogurl I created a PR with proposed change to fix the file path error on Windows.

@robertheessels
Copy link

Beta 3 works great in my project. Thank you!

@phun-ky
Copy link

phun-ky commented Jan 31, 2024

@idahogurl you are doing an awesome job here <3

Do we have any eta? Stay well!

@idahogurl
Copy link
Owner

idahogurl commented Feb 6, 2024

@phun-ky @ozyx It's been released. Make sure to install the prettier-eslint package or else it won't work :)

@ozyx
Copy link

ozyx commented Feb 6, 2024

@phun-ky @ozyx It's been released.

You're awesome! Thanks!

@JounQin
Copy link

JounQin commented Feb 6, 2024

@idahogurl The v6 tag/release is missing.

@robertheessels
Copy link

Works great. Thank you!

Copy link

Branch 171-prettier-3-0
created for this issue. Run command below in your terminal to checkout branch.
git fetch && git checkout 171-prettier-3-0

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 a pull request may close this issue.