Open tunnckoCore opened 6 years ago
Hey @olstenlarck! We really appreciate you taking the time to report an issue. The collaborators on this project attempt to help as many people as possible, but we're a limited number of volunteers, so it's possible this won't be addressed swiftly.
If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack community that typically always has someone willing to help. You can sign-up here for an invite.
So, after investing it further. The most easy thing is to add check for options.plugins.indexOf('espree')
in Babylon's exported .parse
and move what is found on babel-eslint/lib/babylon-to-espree
folder to Babylon's repo. Then just call babylonToEspree
with the coming ast
from getParser().parse()
.
I'll try to find some time to raise a PR, cuz it is really simple thing. Can i PR without tests? Cuz won't have time for them, but will try it locally to see diffs.
Steps to do that:
p === 'espree'
to the filter function. The check would be: if (
pluginList.indexOf("estree") >= 0 &&
pluginList.indexOf("espree") >= 0
) {
throw new Error("Cannot combine ESTree and ESPree plugins.");
}
getParser(options, input).parse()
in the export function parse
with detectESPree(options, input)
var tt = require("babylon").tokTypes;
var traverse = require("@babel/traverse").default;
var babylonToEspree = require("./babylon-to-espree");
function detectESPree (options, input) {
const ast = getParser(options, input).parse();
if (options.plugins.indexOf("espree") >= 0) {
babylonToEspree(ast, traverse, tt, input);
}
return ast;
}
I don't think we need anything other. I seen the plugin API, but in reality we just need to reshape the final ast, so it not matter in what order the plugin is defined. So we don't need more check in getParserClass
.
Continuation of https://github.com/babel/babylon/issues/651? Still, can't understand what's the problem to move the
babel-eslint
'sespree/
dir as plugin to Babylon, so finally can just passbabylon
as eslint parser and passparserOptions
withplugins: ['espree']
.