Package Exports
- esformatter-quotes
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (esformatter-quotes) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
esformatter-quotes
esformatter plugin for single/double quotes normalization.
Usage
install it:
npm install esformatter-quotes
and add to your esformatter config file:
{
"plugins": [
"esformatter-quotes"
],
"quotes": {
"type": "single",
"avoidEscape": false
}
}
Options
- type:String
- if code should use "single" or "double" quotes.
- avoidEscape:Boolean
true
if you want to avoid escaping quotes when possible.
// register plugin
esformatter.register(require('esformatter-quotes'));
// pass options as second argument
var output = esformatter.format(str, {
"quotes": {
"type": "single",
"avoidEscape": false
}
});
Examples
Given this input program:
var singleQuote = 'single';
var doubleQuote = "double";
var avoidSingle = 'single "quote"';
var avoidDouble = "double 'quote'";
var lorem = "ipsum \"dolor\" sit 'amet'";
var maecennas = 'ipsum \'dolor\' sit "amet"';
Will you get the following output based on the config options:
{type: 'single'}
var singleQuote = 'single';
var doubleQuote = 'double';
var avoidSingle = 'single "quote"';
var avoidDouble = 'double \'quote\'';
var lorem = 'ipsum "dolor" sit \'amet\'';
var maecennas = 'ipsum \'dolor\' sit "amet"';
{type: 'single', avoidEscape: true}
var singleQuote = 'single';
var doubleQuote = 'double';
var avoidSingle = 'single "quote"';
var avoidDouble = "double 'quote'";
var lorem = 'ipsum "dolor" sit \'amet\'';
var maecennas = 'ipsum \'dolor\' sit "amet"';
{type: 'double'}
var singleQuote = "single";
var doubleQuote = "double";
var avoidSingle = "single \"quote\"";
var avoidDouble = "double 'quote'";
var lorem = "ipsum \"dolor\" sit 'amet'";
var maecennas = "ipsum 'dolor' sit \"amet\"";
{type: 'double', avoidEscape: true}
var singleQuote = "single";
var doubleQuote = "double";
var avoidSingle = 'single "quote"';
var avoidDouble = "double 'quote'";
var lorem = "ipsum \"dolor\" sit 'amet'";
var maecennas = "ipsum 'dolor' sit \"amet\"";
License
Released under the MIT License.