alexanderweiss / nova-prettier

Prettier extension for Nova
MIT License
35 stars 6 forks source link

Code Changed on save #46

Closed bugcafe closed 3 years ago

bugcafe commented 3 years ago

Is it intended that the formatting will change my code?

Its a little disconcerting when the code is changed and not just formatted. In this particular case its changed the code so a parse error occurs after save that doesnt occur otherwise.

Before Save: Screen Shot 2020-10-26 at 11 14 26 AM

After Save: Screen Shot 2020-10-26 at 11 14 43 AM

You will notice that the $stmt->execute(array( has changed to $stmt->execute([

There is also now a trailing } at the end which is more of a concern as it causes a parse error.

But I wasnt expecting that the code would change, I was expecting it to be tidied up but not changed.

IS this a bug, or is it an intentional thing, alternately , is there a way to prevent it from changing the code and just tidying it up instead?

This is in a PHP file.

alexanderweiss commented 3 years ago

The issue with the extra trailing } is a bug that's been fixed in the latest release (v1.8.2). Thanks for reporting that!

The array changing is the expected behaviour of the PHP plugin for Prettier. If you want the old style syntax I believe you have to change the phpVersion option: https://github.com/prettier/plugin-php#configuration