;-less // line starts with unary - operator
;+less // line starts with unary + opeartor
;/less/ // line starts with regexp literal
;[less] // line starts with array initializer
;(less) // line starts with grouping operator, such as IIFE
NOTE: In real-world, only the last case is common.
npm install -g semicolon-less
Convert test.js
to semicolon-less style
semicolon-less test.js
Convert all js files to semicolon-less and output to dest
directory
semicolon-less --out=dest *.js
Support pipe
echo 'let x = 1' | babel | semicolon-less
Read source code form stdin
semicolon-less -
All semicolon-less
can be replaced by the shortcut -less
, for example, to show the help:
-less --help
var less = require('semicolon-less')
// source can be a string or buffer or stream which contains the source code
var source = require('fs').readFileSync('source.js')
// less() return transformed source
var semicolonlessSource = less(source)
var gulp = require('gulp')
var less = require('semicolon-less/gulpplugin')
gulp.src('*.js').pipe(less())
Currently I'm using yyx990803/semi as underground implementation, and it doesn't support some ES6 syntax (eg. for-of, generators. See the skipped tests). We will solve it in the future.
It's totally unnecessary and not the scope of this project. But if you really want it due to some reasons (ie. your boss/team/IDEs/tools insist on semicolon-itis style), use yyx990803/semi.
In fact, most js code generators will add semicolons as ASI rules. So you could just use uglifyjs to regenerate your codes.
Ok; You must use Issac's awesome semicolons package;
Ensure that all JavaScript programs have the maximum amount of safety; when you require("semicolons"), THEY ARE REQUIRED;