Unexpected token <> (React Fragment) error from ESLint

Viewed 828

I'm currently in the middle of upgrading dependencies from a project that's a couple of years old. I'm having a hard time with eslint (and maybe babel?) complaining about react fragments? <>

Parsing error: Unexpected token

  378 | 
  379 |         return (
> 380 |             <>
      |              ^

I've upgraded babel-eslint to 10.1.0 and added that to my .eslint config file. I was hoping that'd solve it but that's not helped. I'm not sure if I'm looking in the wrong area or not? As I say, the project is a couple of years old now and upgrading packages is new to me.

For example - I think babel-core is now @babel/core. I'm not sure outside of installing the newer package what else I need to do? And this may be my issue? But I'm not too sure

1 Answers

Follow the steps below and see if it resolves your issue:

install babel-eslint

npm install babel-eslint --save-dev

or

yarn add -D babel-eslint

Secondly, add this configuration in your .eslintrc file

{
   "parser":"babel-eslint"
}
Related