Skip to content

Unable to use plugin with Prettier 2.0 (TypeError: locEnd is not a function) #1352

Closed

Description

@JeffBeltran

Prettier 2.0.1

PHP Plugin 0.13.0

Just happen to have bad timing on my part and was troubleshooting getting the plugin working. In the end i realized that a new version of Prettier was just published and it seems to break this plugin. I didn't see another issue open for this so i hope this isn't a dupe.

Error

yarn prettier tests/Feature/ExampleTest.php --check 
yarn run v1.22.4
$ prettier tests/Feature/ExampleTest.php --check
Checking formatting...
tests/Feature/ExampleTest.php[error] tests/Feature/ExampleTest.php: TypeError: locEnd is not a function
[error]     at getNextNonSpaceNonCommentCharacterIndex (/Users/jeffbeltran/code/foo/node_modules/prettier/index.js:12223:70)
[error]     at handleLastFunctionArgComments (/Users/jeffbeltran/code/foo/node_modules/@prettier/plugin-php/src/comments.js:285:25)
[error]     at handleOwnLineComment (/Users/jeffbeltran/code/foo/node_modules/@prettier/plugin-php/src/comments.js:45:5)
[error]     at /Users/jeffbeltran/code/foo/node_modules/prettier/bin-prettier.js:13942:11
[error]     at Array.forEach (<anonymous>)
[error]     at Object.attach (/Users/jeffbeltran/code/foo/node_modules/prettier/bin-prettier.js:13913:12)
[error]     at attachComments (/Users/jeffbeltran/code/foo/node_modules/prettier/bin-prettier.js:14771:14)
[error]     at coreFormat (/Users/jeffbeltran/code/foo/node_modules/prettier/bin-prettier.js:14802:23)
[error]     at format (/Users/jeffbeltran/code/foo/node_modules/prettier/bin-prettier.js:15024:75)
[error]     at formatWithCursor (/Users/jeffbeltran/code/foo/node_modules/prettier/bin-prettier.js:15040:12)
All matched files use Prettier code style!
error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Fix

downgrading to 1.19.1 fixes this error.

Activity

  1. czosel commented on Mar 23, 2020

    @czosel
    Collaborator

    Thanks for the bug report! I already expected this to happen when I saw the release on twitter the other day, but you're the first to report it 😉

  2. czosel commented on Mar 25, 2020

    @czosel
    Collaborator

    I opened a PR to fix this, if you want to try it run yarn add czosel/plugin-php#prettier-2.0 🎉

  3. kevinpainchaud commented on Mar 28, 2020

    @kevinpainchaud

    It works for me. Thank you very much !

  4. entozoon commented on Mar 29, 2020

    @entozoon

    @czosel Your #prettier-2.0 branch was working when you suggested it a few days ago but isn't anymore.
    And the main repo doesn't fix the problem either

  5. czosel commented on Mar 29, 2020

    @czosel
    Collaborator

    @entozoon Thats probably because the brach has been merged and deleted. Until a new version has been released, you’ll have to install the master branch. I’m on my phone right now so I can’t test, but it’s probably

    yarn add @prettier/plugin-php#master

  6. czosel commented on Mar 31, 2020

    @czosel
    Collaborator

    We just released v0.14.0 which fixes this issue, and many more! 🎉

    https://github.com/prettier/plugin-php/releases

  7. entozoon commented on Apr 1, 2020

    @entozoon

    Fantastic work @czosel, you're a legend. Can confirm it works perfectly!

  8. czosel commented on Apr 1, 2020

    @czosel
    Collaborator

    😊 Thank you so much @entozoon! I'll use this opportunity to forward your praise to everyone else who helped make this happen, especially @ichiriac @loilo and @evilebottnawi: It's fun to work with you on this, you rock! 💯

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions