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

Support Prettier v3 #125

Closed
angrybacon opened this issue Jul 22, 2023 · 3 comments · Fixed by #124
Closed

Support Prettier v3 #125

angrybacon opened this issue Jul 22, 2023 · 3 comments · Fixed by #124

Comments

@angrybacon
Copy link

angrybacon commented Jul 22, 2023

I notice only now there's already a PR for it #124

Thanks!


Describe the bug

Prettier v3 has some breaking changes: https://prettier.io/blog/2023/07/05/3.0.0.html#api-1

prettier.resolveConfig.sync is removed

Link to M-x prettier-info output

(:emacs-version "GNU Emacs 29.0.90 (build 1, aarch64-apple-darwin22.4.0, NS appkit-2299.50 Version 13.3.1 (Build 22E261))\n of 2023-05-06"
 :prettier-el-version "1.3.0"
 :buffer-file-name "/path/to/project/package.json"
 :remote-id nil
 :major-mode json-ts-mode
 :exec-path
 ("/path/to/user/.nvm/versions/node/v18.14.2/bin/"
  "/opt/homebrew/opt/coreutils/libexec/gnubin/"
  "/usr/local/sbin/"
  "/usr/local/opt/coreutils/libexec/gnubin/"
  "/opt/homebrew/bin/"
  "/opt/homebrew/sbin/"
  "/path/to/user/Scripts/"
  "/usr/local/bin/"
  "/System/Cryptexes/App/usr/bin/"
  "/usr/bin/"
  "/bin/"
  "/usr/sbin/"
  "/sbin/"
  "/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin/"
  "/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin/"
  "/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin/"
  "/path/to/user/.cargo/bin/"
  "/path/to/user/.nvm/versions/node/v18.14.2/bin/"
  "/opt/homebrew/bin/"
  "/opt/homebrew/sbin/"
  "/path/to/user/Scripts/"
  "/path/to/user/Library/Android/sdk/emulator/"
  "/path/to/user/Library/Android/sdk/platform-tools/"
  "/path/to/user/Library/Android/sdk/emulator/"
  "/path/to/user/Library/Android/sdk/platform-tools/"
  "/opt/homebrew/Cellar/emacs-plus@29/29.0.90/libexec/emacs/29.0.90/aarch64-apple-darwin22.4.0/")
 :env
 ("TERM=dumb"
  "ANDROID_HOME=/path/to/user/Library/Android/sdk"
  "MANPATH=/path/to/user/.nvm/versions/node/v18.14.2/share/man:/usr/local/opt/coreutils/libexec/gnuman:/opt/homebrew/share/man::"
  "XPC_FLAGS=0x0"
  "XPC_SERVICE_NAME=application.org.gnu.Emacs.14974635.14974640"
  "__CF_USER_TEXT_ENCODING=0x1F6:0x0:0x0"
  "TMPDIR=/var/folders/c5/n35jrw5x4c57mbg_mzgtd6680000gp/T/"
  "SHELL=/bin/zsh"
  "HOME=/path/to/user"
  "SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.wJ7m28GsrK/Listeners"
  "LOGNAME=user"
  "PATH=/path/to/user/.nvm/versions/node/v18.14.2/bin:/opt/homebrew/opt/coreutils/libexec/gnubin:/usr/local/sbin:/usr/local/opt/coreutils/libexec/gnubin:/opt/homebrew/bin:/opt/homebrew/sbin:/path/to/user/Scripts:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/path/to/user/.cargo/bin:/path/to/user/.nvm/versions/node/v18.14.2/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/path/to/user/Scripts:/path/to/user/Library/Android/sdk/emulator:/path/to/user/Library/Android/sdk/platform-tools:/path/to/user/Library/Android/sdk/emulator:/path/to/user/Library/Android/sdk/platform-tools"
  "__CFBundleIdentifier=org.gnu.Emacs"
  "COMMAND_MODE=unix2003"
  "USER=user")
 :prettier-options nil)

To Reproduce

  1. Make sure project dependencies are installed, in my case "prettier": "3.0.0"
  2. Enable prettier-mode
  3. Edit then save a valid syntax file (in my case, any .json, .ts[x] file)
  4. Notice the error in *prettier-errors* and the file not prettified

/path/to/project/package.json: TypeError: n.resolveConfig.sync is not a function

Expected behavior

The file should be prettified with no error.

Additional context

I'm not sure what the relevant part of prettier.el are so let me know if more clues are necessary.

Downgrading to v2.8.8, then restarting the prettier process removes the error on save with no surprise.

@kuba-orlik
Copy link

For the time being I'm using this to use the version from the fork:

(straight-use-package
 '(prettier  :pre-build (("npm" "install" "--frozen-lockfile")  ("make" "dist/prettier-el.js.gz.base64") ("bash" "-c" "cp ./dist/* .")) :files (:defaults "*.js" "dist/*.base64" "prettier-pkg.el") ;; https://github.com/radian-software/straight.el/issues/621#issuecomment-716221459
			 :repo "asbish/prettier.el" :branch "support-for-prettier3" ) ;; https://github.com/jscheid/prettier.el/pull/124
)

@SamuelBanya
Copy link

@kuba-orlik
What is the 'use-package' with ':straight' version of your command?

I ask because I don't personally use 'straight.el' to manage packages, and just grab the latest stable packages from MELPA with my Emacs config.

Trying to use Prettier, but I'm getting the same exact 'TypeError: n.resolveConfig.sync is not a function' error after attempting to save a Typescript buffer with the 'Prettier.el' package.

@SamuelBanya
Copy link

@kuba-orlik
Nevermind, it seems like you would need 'Straight.el' installed to even get access to install a specific GitHub repo version of a package for a scenario like this.

Probably will just hold off from using this until this gets fixed in the main branch of this project.

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.

3 participants