0.7.0 • Published 9 years ago

semicolon-less v0.7.0

Weekly downloads
4
License
ISC
Repository
github
Last release
9 years ago

NPM version Build status Test coverage Codacy badge Downloads

;-less.js // Make your JavaScript Code Semicolon-less

Rationale

You don't need semicolons in most cases

Write semicolons in ONLY 5 cases

  • ;-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.

Usage

Install

npm install -g semicolon-less

CLI

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

API

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)

Gulp friendly

var gulp = require('gulp')
var less = require('semicolon-less/gulpplugin')

gulp.src('*.js').pipe(less())

Bugs and limitations

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.

I want to convert semicolon-less style back to semicolon-itis style

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.

I don't agree with you; semicolons are REQUIRED!

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;

0.7.0

9 years ago

0.6.1

9 years ago

0.6.0

9 years ago

0.5.2

9 years ago

0.5.0

9 years ago

0.3.0

9 years ago