babel/packages/babel-code-frame
Sebastian McKenzie 03383bdf31 v6.1.4
2015-11-11 02:04:26 -08:00
..
2015-11-10 14:26:40 -08:00
2015-11-11 02:04:26 -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 | }