-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use babel's loadPartialConfig function #44
Comments
@0xdevalias based on the discussion in your issue and the input from the maintainer we should move off of using find-babel-config in favor of the function you mention. I am changing the issue title to reflect this. |
@HeroProtagonist Has there been any updates on this? I ran into an issue with the api argument to the babel config not being defined by find-babel-config and crashing the rule. I was able to get it to pass using loadPartialConfig as mentioned above: // var _findBabelConfig$sync = findBabelConfig.sync(babelDir),
// config = _findBabelConfig$sync.config;
var partialConfig = __babel.loadPartialConfig();
var config = partialConfig.options;
try {
var validPluginNames = new Set(['babel-plugin-module-resolver', 'module-resolver']);
var _config$plugins$filte = config.plugins.filter(function (plugin) {
if (validPluginNames.has(plugin.file.request)) {
return plugin;
}
}),
_config$plugins$filte2 = _slicedToArray(_config$plugins$filte, 1),
moduleResolver = _config$plugins$filte2[0];
alias = moduleResolver.options.alias || {}; I'd be willing to put up a PR if you're down with what I'm doing here |
PR's are definitely welcome. See contributing.md for useful information. |
node_modules/eslint-plugin-module-resolver/dist/rules/use-alias.js
Hacking in some debug logging just before it dies:
It's trying to access
node.arguments[0].loc
, but there are no arguments, which is why it crashes:The snippet of code it appears to be failing on for me is this, nested relatively deep in my jest test:
It doesn't seem to matter what it is/where it's placed though, as the following as the only thing in the file also causes a failure:
Hacking that line of code to use a proper check lets the error complete, and shows it as:
So I'm thinking maybe this has gotten itself into a weird/undesirable edgecase due to the config being unable to be found, and then it's dying based on an unexpected case there.
Getting super hacky with things, I put the following code in place as per the babel docs:
And it seemed to find my config file (though obviously it's not correctly wired into this rule/plugin properly, just enough to proof of concept):
The text was updated successfully, but these errors were encountered: