Plugin-php: Unable to use plugin with Prettier 2.0 (TypeError: locEnd is not a function)

Created on 22 Mar 2020  路  8Comments  路  Source: prettier/plugin-php

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.

bug high-pri

Most helpful comment

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

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

All 8 comments

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 :wink:

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

It works for me. Thank you very much !

@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

@entozoon Thats probably because the brach has been merged and deleted. Until a new version has been released, you鈥檒l have to install the master branch. I鈥檓 on my phone right now so I can鈥檛 test, but it鈥檚 probably

yarn add @prettier/plugin-php#master

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

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

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

:blush: 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! :100:

Was this page helpful?
0 / 5 - 0 ratings

Related issues

hawkrives picture hawkrives  路  3Comments

alexander-akait picture alexander-akait  路  5Comments

nikulis picture nikulis  路  5Comments

czosel picture czosel  路  5Comments

sgruetter picture sgruetter  路  5Comments