Sha256: b913bac9b4c3797ba67819d235aebca7e097e1edba915a642acdc841f102a227

Contents?: true

Size: 851 Bytes

Versions: 34

Compression:

Stored size: 851 Bytes

Contents

# babel-code-frame

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

## Install

```sh
$ npm install babel-code-frame
```

## Usage

```js
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);
```

```sh
  1 | class Foo {
> 2 |   constructor()
    |                ^
  3 | }
```

If the column number is not known, you may pass `null` instead.

## Options

name                   | type     | default         | description
-----------------------|----------|-----------------|------------------------------------------------------
highlightCode          | boolean  | `false`         | Syntax highlight the code as JavaScript for terminals

Version data entries

34 entries across 6 versions & 1 rubygems

Version Path
babel-schmooze-sprockets-0.1.1 node_modules/babel-helper-remap-async-to-generator/node_modules/babel-code-frame/README.md
babel-schmooze-sprockets-0.1.1 node_modules/babel-helper-replace-supers/node_modules/babel-code-frame/README.md
babel-schmooze-sprockets-0.1.1 node_modules/babel-plugin-transform-es2015-block-scoping/node_modules/babel-code-frame/README.md
babel-schmooze-sprockets-0.1.1 node_modules/babel-plugin-transform-es2015-classes/node_modules/babel-code-frame/README.md
babel-schmooze-sprockets-0.1.1 node_modules/babel-plugin-transform-es2015-duplicate-keys/node_modules/babel-code-frame/README.md
babel-schmooze-sprockets-0.1.1 node_modules/babel-plugin-transform-es2015-function-name/node_modules/babel-code-frame/README.md
babel-schmooze-sprockets-0.1.0 node_modules/babel-helper-remap-async-to-generator/node_modules/babel-code-frame/README.md
babel-schmooze-sprockets-0.1.0 node_modules/babel-helpers/node_modules/babel-code-frame/README.md
babel-schmooze-sprockets-0.1.0 node_modules/babel-plugin-transform-es2015-modules-amd/node_modules/babel-code-frame/README.md
babel-schmooze-sprockets-0.1.0 node_modules/babel-generator/node_modules/babel-code-frame/README.md
babel-schmooze-sprockets-0.1.0 node_modules/babel-core/node_modules/babel-code-frame/README.md
babel-schmooze-sprockets-0.1.0 node_modules/babel-code-frame/README.md
babel-schmooze-sprockets-0.1.0.alpha.3 node_modules/babel-code-frame/README.md
babel-schmooze-sprockets-0.1.0.alpha.2 node_modules/babel-code-frame/README.md