Highlighting syntax errors in code
This feature allows developers to highlight syntax errors in their code. The code sample shows how to use the codeFrameColumns function to generate a string that highlights the location of an error in the source code.
const { codeFrameColumns } = require('@babel/code-frame');
const rawLines = `class Foo {
constructor()
}
`;
const location = { start: { line: 2, column: 15 } };
const result = codeFrameColumns(rawLines, location, {
highlightCode: true
});
console.log(result);