Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

esformatter-quotes

Package Overview
Dependencies
Maintainers
2
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

esformatter-quotes

esformatter plugin: enforces coding style that string literals are delimited with single or double quotes.

  • 1.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
2
Created
Source

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.

Keywords

FAQs

Package last updated on 05 Jun 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc