babel/packages/babel-code-frame
Amjad Masad de92d632f3 v6.7.2
2016-03-10 14:41:27 -08:00
..
2016-03-03 15:10:59 -08:00
2015-11-10 14:26:40 -08:00
2016-03-08 22:33:23 -05:00
2016-03-10 14:41:27 -08: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 | }