Rename quotes config option to

master
James Long 2017-01-05 10:01:43 -05:00
parent f1feb24dff
commit 9596695a12
3 changed files with 6 additions and 9 deletions

View File

@ -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) {

View File

@ -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.

View File

@ -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);
}
}