Skip to content

Commit ea27073

Browse files
authored
fix: πŸ› singleQuote option does not work on format API (#2303)
* fix: πŸ› singleQuote option does not work on format API * test: πŸ’ add test for singleQuote option from api call * refactor: πŸ’‘ add comment * style: πŸ’„ apply formatter
1 parent 410e292 commit ea27073

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

β€Žsrc/options.mjsβ€Ž

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,11 @@ export default {
4545
{ value: "1tbs", description: "Use 1tbs brace style." },
4646
],
4747
},
48+
singleQuote: {
49+
since: "0.0.0",
50+
category: CATEGORY_PHP,
51+
type: "boolean",
52+
default: false,
53+
description: "Use single quotes instead of double quotes.",
54+
},
4855
};
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import prettier from "prettier/standalone";
2+
import * as prettierPluginPhp from "../../src/index.mjs";
3+
4+
// https://github.com/prettier/plugin-php/issues/2302
5+
test(`singleQuote option on format api`, async () => {
6+
const input = `<?php echo link_to_route("frontend.users.user.show", $users["name"], $users['_id']); ?>`;
7+
const result = await prettier.format(input, {
8+
plugins: [prettierPluginPhp],
9+
singleQuote: true,
10+
parser: "php",
11+
});
12+
13+
const expected = `<?php echo link_to_route(
14+
'frontend.users.user.show',
15+
$users['name'],
16+
$users['_id']
17+
); ?>
18+
`;
19+
20+
expect(result).toEqual(expected);
21+
});

0 commit comments

Comments
Β (0)