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.3 node_modules/babel-code-frame/README.md
babel-schmooze-sprockets-0.1.2 node_modules/babel-code-frame/README.md
babel-schmooze-sprockets-0.1.1 node_modules/babel-helper-regex/node_modules/babel-code-frame/README.md
babel-schmooze-sprockets-0.1.1 node_modules/babel-plugin-transform-es2015-modules-amd/node_modules/babel-code-frame/README.md
babel-schmooze-sprockets-0.1.1 node_modules/babel-plugin-transform-es2015-modules-commonjs/node_modules/babel-code-frame/README.md
babel-schmooze-sprockets-0.1.1 node_modules/babel-plugin-transform-es2015-parameters/node_modules/babel-code-frame/README.md
babel-schmooze-sprockets-0.1.1 node_modules/babel-plugin-transform-es2015-shorthand-properties/node_modules/babel-code-frame/README.md
babel-schmooze-sprockets-0.1.1 node_modules/babel-plugin-transform-es2015-sticky-regex/node_modules/babel-code-frame/README.md
babel-schmooze-sprockets-0.1.1 node_modules/babel-plugin-transform-regenerator/node_modules/babel-code-frame/README.md
babel-schmooze-sprockets-0.1.1 node_modules/babel-plugin-transform-strict-mode/node_modules/babel-code-frame/README.md
babel-schmooze-sprockets-0.1.1 node_modules/babel-template/node_modules/babel-code-frame/README.md
babel-schmooze-sprockets-0.1.1 node_modules/babel-code-frame/README.md
babel-schmooze-sprockets-0.1.1 node_modules/babel-core/node_modules/babel-code-frame/README.md
babel-schmooze-sprockets-0.1.1 node_modules/babel-generator/node_modules/babel-code-frame/README.md
babel-schmooze-sprockets-0.1.1 node_modules/babel-helper-call-delegate/node_modules/babel-code-frame/README.md
babel-schmooze-sprockets-0.1.1 node_modules/babel-helper-define-map/node_modules/babel-code-frame/README.md
babel-schmooze-sprockets-0.1.1 node_modules/babel-helper-function-name/node_modules/babel-code-frame/README.md
babel-schmooze-sprockets-0.1.1 node_modules/babel-helper-get-function-arity/node_modules/babel-code-frame/README.md
babel-schmooze-sprockets-0.1.1 node_modules/babel-helper-hoist-variables/node_modules/babel-code-frame/README.md
babel-schmooze-sprockets-0.1.1 node_modules/babel-helper-optimise-call-expression/node_modules/babel-code-frame/README.md