UNPKG

491 BMarkdownView Raw
1# babel-code-frame
2
3> Generate errors that contain a code frame that point to source locations.
4
5## Install
6
7```sh
8$ npm install babel-code-frame
9```
10
11## Usage
12
13```js
14import codeFrame from 'babel-code-frame';
15
16const rawLines = `class Foo {
17 constructor()
18}`;
19const lineNumber = 2;
20const colNumber = 16;
21
22const result = codeFrame(rawLines, lineNumber, colNumber, { /* options */ });
23
24console.log(result);
25```
26
27```sh
28 1 | class Foo {
29> 2 | constructor()
30 | ^
31 3 | }
32```