fix buildCodeFrameError empty code frames
This commit is contained in:
committed by
James Kyle
parent
49775e2f12
commit
c3f6f7fe28
@@ -179,8 +179,8 @@ export default class File {
|
||||
|
||||
buildCodeFrameError(
|
||||
node: ?{
|
||||
loc?: { line: number, column: number },
|
||||
_loc?: { line: number, column: number },
|
||||
loc?: { start: { line: number, column: number } },
|
||||
_loc?: { start: { line: number, column: number } },
|
||||
},
|
||||
msg: string,
|
||||
Error: typeof Error = SyntaxError,
|
||||
@@ -212,8 +212,8 @@ export default class File {
|
||||
this.code,
|
||||
{
|
||||
start: {
|
||||
line: loc.line,
|
||||
column: loc.column + 1,
|
||||
line: loc.start.line,
|
||||
column: loc.start.column + 1,
|
||||
},
|
||||
},
|
||||
{ highlightCode },
|
||||
|
||||
@@ -39,8 +39,8 @@ export default class PluginPass {
|
||||
|
||||
buildCodeFrameError(
|
||||
node: ?{
|
||||
loc?: { line: number, column: number },
|
||||
_loc?: { line: number, column: number },
|
||||
loc?: { start: { line: number, column: number } },
|
||||
_loc?: { start: { line: number, column: number } },
|
||||
},
|
||||
msg: string,
|
||||
Error?: typeof Error,
|
||||
|
||||
16
packages/babel-core/test/fixtures/plugins/build-code-frame-error/exec.js
vendored
Normal file
16
packages/babel-core/test/fixtures/plugins/build-code-frame-error/exec.js
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
var code = "function f() {}";
|
||||
transform(code, {
|
||||
plugins: [
|
||||
function() {
|
||||
return {
|
||||
visitor: {
|
||||
FunctionDeclaration: function(path) {
|
||||
throw path.buildCodeFrameError("someMsg");
|
||||
},
|
||||
},
|
||||
};
|
||||
},
|
||||
],
|
||||
// hard to assert on ANSI escape codes
|
||||
highlightCode: false,
|
||||
});
|
||||
3
packages/babel-core/test/fixtures/plugins/build-code-frame-error/options.json
vendored
Normal file
3
packages/babel-core/test/fixtures/plugins/build-code-frame-error/options.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"throws": "undefined: someMsg\n> 1 | function f() {}"
|
||||
}
|
||||
Reference in New Issue
Block a user