diff --git a/src/options.mjs b/src/options.mjs index 1600dbd39..93fca45dc 100644 --- a/src/options.mjs +++ b/src/options.mjs @@ -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.", + }, }; diff --git a/tests/single-quote-api/jsfmt.spec.mjs b/tests/single-quote-api/jsfmt.spec.mjs new file mode 100644 index 000000000..c95b4ab03 --- /dev/null +++ b/tests/single-quote-api/jsfmt.spec.mjs @@ -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 = ``; + const result = await prettier.format(input, { + plugins: [prettierPluginPhp], + singleQuote: true, + parser: "php", + }); + + const expected = ` +`; + + expect(result).toEqual(expected); +});