Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
try {
return babylon.parse(code, {
sourceType: 'module',
plugins: [
'flow',
]
});
} catch(err) {
if (!(err instanceof SyntaxError)) {
throw err;
}
const posData = err.message.match(/ \((\d+):(\d+)\)$/);
if (posData !== null) {
err.message += `\n${codeFrame(code, ...posData.slice(1, 3))}`;
}
throw err;
}
};