babel/packages/babel-code-frame
Simon Lydell 6af4ba1937 babel-code-frame: Update type annotation
The code allows omitting the column number, but the type annotation for that
parameter didn't.
2016-03-23 17:13:07 +01:00
..
2015-11-10 14:26:40 -08:00
2016-03-08 22:33:23 -05:00
2016-03-22 20:37:46 -07:00
2015-10-29 19:57:48 -07:00

babel-code-frame

Generate errors that contain a code frame that point to source locations.

Install

$ npm install babel-code-frame

Usage

import codeFrame from 'babel-code-frame';

const rawLines = `class Foo {
  constructor()
}`;
const lineNumber = 2;
const colNumber = 16;

const result = codeFrame(rawLines, lineNumber, colNumber, { /* options */ });

console.log(result);
  1 | class Foo {
> 2 |   constructor()
    |                ^
  3 | }