Link Babel ESLint Parser to Meteor's Babel settings

I’m updating ESLint in my project, and I’m using @babel/eslint-parser. This parser requires access to Babel’s configuration files.

What I want to do is link the parser to the Babel settings that Meteor uses in the background to compile the code. However, I was unable to find anything to help me figure out how to do this.

It is possible to disable the requirement for a config file with requireConfigFile: false, but the linting of some files break with this. For example, I’m unable to lint .jsx files.

As of right now, my solution was to define babelOptions in the ESLint configs to mimic some Babel settings, but this requires manual setup and is prone to errors. If I could just link to Meteor’s Babel settings file things could work automatically.

Any help with this would be highly appreciated. Thanks!

Use babel-preset-meteor in your .babelrc file

1 Like

@rjdavid you are helping all, you are hero! :index_pointing_at_the_viewer:

Thanks for the suggestion! I’ve added 'meteor' as one of the presets for Babel. Unfortunately, it doesn’t seem to solve the problems I’ve been having. For example, the linting still doesn’t work for .jsx files:

error  Parsing error: This experimental syntax requires enabling one of the following parser plugin(s): "jsx", "flow", "typescript". (29:6)

It’s possible to fix this specific error by adding '@babel/preset-react' to the list of Babel Presets. However, it would be nice if I could automatically load all of Meteor’s settings for babel, so everything can work automatically.

When I was using babel-eslint (the deprecated version of @babel/eslint-parser) these setups weren’t necessary. So I’m thinking if it’s possible for things to work this easily with @babel/estlint-parser as well. Do you know if that’s possible?

Thanks a lot :wink:

Since React is not required to use Meteor, it seems reasonable to also install a separate linting presets when opting to use react

@rjdavid yeah, I see your point. And doing it like that seems to work fine for me. I was just thinking if there is a way to make things even simpler and more automatic, but if there isn’t, the few additional lines of code I have to write aren’t much of a problem haha.

Anyway, thanks a lot for your help!