Skip to content

Commit

Permalink
fix: πŸ› singleQuote option does not work on format API (#2303)
Browse files Browse the repository at this point in the history
* fix: πŸ› singleQuote option does not work on format API

* test: πŸ’ add test for singleQuote option from api call

* refactor: πŸ’‘ add comment

* style: πŸ’„ apply formatter
  • Loading branch information
shufo authored Feb 3, 2024
1 parent 410e292 commit ea27073
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/options.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,11 @@ export default {
{ value: "1tbs", description: "Use 1tbs brace style." },
],
},
singleQuote: {
since: "0.0.0",
category: CATEGORY_PHP,
type: "boolean",
default: false,
description: "Use single quotes instead of double quotes.",
},
};
21 changes: 21 additions & 0 deletions tests/single-quote-api/jsfmt.spec.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import prettier from "prettier/standalone";
import * as prettierPluginPhp from "../../src/index.mjs";

// https://github.com/prettier/plugin-php/issues/2302
test(`singleQuote option on format api`, async () => {
const input = `<?php echo link_to_route("frontend.users.user.show", $users["name"], $users['_id']); ?>`;
const result = await prettier.format(input, {
plugins: [prettierPluginPhp],
singleQuote: true,
parser: "php",
});

const expected = `<?php echo link_to_route(
'frontend.users.user.show',
$users['name'],
$users['_id']
); ?>
`;

expect(result).toEqual(expected);
});

0 comments on commit ea27073

Please sign in to comment.