How to use the babel-code-frame.codeFrameColumns 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 babel / babel / packages / babel-core / src / transformation / file / index.js View on Github external
throw err;
      } else {
        err._babel = true;
      }

      let message = (err.message = `${this.opts.filename}: ${err.message}`);

      const loc = err.loc;
      if (loc) {
        const location = {
          start: {
            line: loc.line,
            column: loc.column + 1,
          },
        };
        err.codeFrame = codeFrameColumns(code, location, this.opts);
        message += "\n" + err.codeFrame;
      }

      if (process.browser) {
        // chrome has it's own pretty stringifier which doesn't use the stack property
        // https://github.com/babel/babel/issues/2175
        err.message = message;
      }

      if (err.stack) {
        const newStack = err.stack.replace(err.message, message);
        err.stack = newStack;
      }

      throw err;
    }

babel-code-frame

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

MIT
Latest version published 7 years ago

Package Health Score

82 / 100
Full package analysis

Popular babel-code-frame functions

Similar packages