From 9596695a12d62393700252f7a3bdbef4fd448444 Mon Sep 17 00:00:00 2001 From: James Long Date: Thu, 5 Jan 2017 10:01:43 -0500 Subject: [PATCH] Rename quotes config option to --- bin/jscodefmt | 4 ++-- src/options.js | 5 ++--- src/printer.js | 6 ++---- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/bin/jscodefmt b/bin/jscodefmt index 362acf9b..d03d7758 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 90423779..53b2fc4d 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 d4189fdf..8bbf03c5 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); } }