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 { ): Error {
let loc = node && (node.loc || node._loc); let loc = node && (node.loc || node._loc);
msg = `${this.opts.filename ?? "unknown"}: ${msg}`;
if (!loc && node) { if (!loc && node) {
const state = { const state = {
loc: null, loc: null,

View File

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

View File

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