Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

automatic-semicolon-insertion

1.0.2 • Public • Published

automatic-semicolon-insertion Build Status

Insert missing semicolons, remove unneeded ones.

Install

$ npm install [--save] automatic-semicolon-insertion

If you're using an AST from babel (babylon) you can also install ast-processor-babylon-config to make it easier. Otherwise you'll have to implement the expected methods yourself.

Usage

import asi from 'automatic-semicolon-insertion';
import buildConfig from 'ast-processor-babylon-config';
import { parse } from 'babylon';
 
let source = 'let a = class {}'; // should have a semicolon after it
let ast = parse(source);
let config = buildConfig(source, ast);
 
asi(config);
let { insertions, removals } = config;
console.log({ insertions, removals });
 
/*
prints:
 
{ insertions: [ { index: 16, content: ';' } ], removals: [] }
*/

Keywords

install

npm i automatic-semicolon-insertion

Downloadsweekly downloads

2,864

version

1.0.2

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar