How to use the @babel/code-frame function in @babel/code-frame

To help you get started, we’ve selected a few @babel/code-frame examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github PassFort / json-schema-to-flow-type / src / __tests__ / FlowTypeGenerator.spec.js View on Github external
try {
    return babylon.parse(code, {
      sourceType: 'module',
      plugins: [
        'flow',
      ]
    });
  } catch(err) {
    if (!(err instanceof SyntaxError)) {
      throw err;
    }

    const posData = err.message.match(/ \((\d+):(\d+)\)$/);

    if (posData !== null) {
      err.message += `\n${codeFrame(code, ...posData.slice(1, 3))}`;
    }

    throw err;
  }
};

@babel/code-frame

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

MIT
Latest version published 18 days ago

Package Health Score

95 / 100
Full package analysis

Popular @babel/code-frame functions

Similar packages