fix: remove filename annotation in buildCodeFrameError (#10539)

This commit is contained in:
Huáng Jùnliàng 2019-10-14 12:19:55 -04:00 committed by Nicolò Ribaudo
parent 1b19608a5a
commit dcf7d89b8e
3 changed files with 17 additions and 20 deletions

View File

@ -259,8 +259,6 @@ export default class File {
): Error {
let loc = node && (node.loc || node._loc);
msg = `${this.opts.filename ?? "unknown"}: ${msg}`;
if (!loc && node) {
const state = {
loc: null,

View File

@ -1,16 +1,18 @@
var code = "function f() {}";
transform(code, {
plugins: [
function() {
return {
visitor: {
FunctionDeclaration: function(path) {
throw path.buildCodeFrameError("someMsg");
expect(() => {
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,
});
};
},
],
// hard to assert on ANSI escape codes
highlightCode: false,
});
}).toThrow(/^unknown: someMsg\s+> 1 \| function f\(\) {}/);

View File

@ -1,3 +0,0 @@
{
"throws": "unknown: someMsg\n> 1 | function f() {}"
}