esformatter-semicolon-first
esformatter plugin: add semicolon before '[' and '(' if it's the start of a line.
Last updated 9 years ago by millermedeiros .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install esformatter-semicolon-first 
SYNC missed versions from official npm registry.

esformatter-semicolon-first

esformatter plugin to add semicolon before [ and ( if they are the first things on the line.

created mainly to be used by standard-format

Usage

Add to your esformatter config file:

{
  "plugins": [
    "esformatter-semicolon-first"
  ]
}

Or you can manually register the plugin if not using esformatter directly:

// register plugin
esformatter.register(require('esformatter-semicolon-first'));

Config

By default we add at least one line break before the semicolon and remove line breaks afterwards, but you can use the lineBreak.before['esformatter-semicolon-first'] and lineBreak.after['esformatter-semicolon-first'] to configure it tho.

{
  "lineBreak": {
    "before": {
      "esformatter-semicolon-first": ">0"
    },
    "after": {
      "esformatter-semicolon-first": 0
    }
  }
}

Examples

Given this input program:

var x = 2
[1,2,3].map(function() {})

var y = 8
(function() {
  bar()
}())

It will output:

var x = 2
;[1,2,3].map(function() {})

var y = 8
;(function() {
  bar()
}())

For more examples see the test files inside the test/ folder.

License

Released under the MIT License.

Current Tags

  • 1.2.0                                ...           latest (8 years ago)

4 Versions

  • 1.2.0                                ...           8 years ago
  • 1.1.0                                ...           9 years ago
  • 1.0.1                                ...           10 years ago
  • 1.0.0                                ...           10 years ago
Maintainers (1)
Downloads
Total 5
Today 1
This Week 1
This Month 1
Last Day 0
Last Week 0
Last Month 0
Dependencies (3)
Dev Dependencies (2)
Dependents (1)

© 2010 - cnpmjs.org x YWFE | Home | YWFE