Closed shufo closed 7 months ago
$ yarn list | grep prettier ├─ @prettier/plugin-php@0.22.1 ... ├─ prettier@3.1.1
In recent release (at least 0.22.1), prettier.format API call like below does not respect singleQuote option. Other options are respected as like before.
0.22.1
prettier.format
singleQuote
$ cat test.js import prettier from "prettier/standalone"; import prettierPluginPhp from "@prettier/plugin-php/standalone"; console.log((await prettier.format(`<?php echo link_to_route("frontend.users.user.show", $users["name"], $users['_id']); ?>`, { plugins: [prettierPluginPhp], singleQuote: true, parser: "php", })));
It will outputs like below. You can see double quote is still double quote.
$ node test.js <?php echo link_to_route( "frontend.users.user.show", $users["name"], $users['_id'] ); ?>
Respect singleQuote option as like before.
0.19.7 is OK. I think this regression is introduced since v0.20.0
$ cat package.json { "dependencies": { "@prettier/plugin-php": "0.19.7", "prettier": "^2.0.0" } } $ cat test.mjs import prettier from "prettier/standalone.js"; import prettierPluginPhp from "@prettier/plugin-php/standalone.js"; console.log((prettier.format(`<?php echo link_to_route("frontend.users.user.show", $users["name"], $users['_id']); ?>`, { plugins: [prettierPluginPhp], singleQuote: true, parser: "php", })));
$ node test.mjs <?php echo link_to_route( 'frontend.users.user.show', $users['name'], $users['_id'] ); ?>
I tried some fix and found adding default option could solve the issue. I'll create the PR.
Environment
Current behaviour
In recent release (at least
0.22.1
),prettier.format
API call like below does not respectsingleQuote
option. Other options are respected as like before.It will outputs like below. You can see double quote is still double quote.
Expected behaviour
Respect
singleQuote
option as like before.0.19.7 is OK. I think this regression is introduced since v0.20.0
I tried some fix and found adding default option could solve the issue. I'll create the PR.