diff --git a/bin/jscodefmt b/bin/jscodefmt index 362acf9b6..d03d77583 100755 --- a/bin/jscodefmt +++ b/bin/jscodefmt @@ -5,7 +5,7 @@ const minimist = require("minimist"); const jscodefmt = require("../index"); const argv = minimist(process.argv.slice(2), { - boolean: ["write", "useFlowParser", "bracket-spacing", "single-quotes"] + boolean: ["write", "useFlowParser", "bracket-spacing", "single-quote"] }); const filename = argv["_"][0]; @@ -16,7 +16,7 @@ const output = jscodefmt.format(fs.readFileSync(filename, "utf8"), { tabWidth: argv['tab-width'], bracketSpacing: argv['bracket-spacing'], useFlowParser: argv['flow-parser'], - quote: argv["single-quotes"] ? "single" : "double" + singleQuote: argv["single-quote"] }); if(write) { diff --git a/src/options.js b/src/options.js index 90423779e..53b2fc4da 100644 --- a/src/options.js +++ b/src/options.js @@ -7,9 +7,8 @@ var defaults = { // Fit code within this line limit. printWidth: 80, - // If you want to override the quotes used in string literals, specify - // either "single" or "double". - quote: "double", + // If true, will use single instead of double quotes + singleQuote: false, // Controls the printing of trailing commas in object literals, // array expressions and function parameters. diff --git a/src/printer.js b/src/printer.js index d4189fdfd..8bbf03c51 100644 --- a/src/printer.js +++ b/src/printer.js @@ -1923,11 +1923,9 @@ function swapQuotes(str) { function nodeStr(str, options) { isString.assert(str); - switch (options.quote) { - case "single": + if(options.singleQuote) { return swapQuotes(JSON.stringify(swapQuotes(str))); - case "double": - default: + } else { return JSON.stringify(str); } }