jsx file eslint error Parsing error: Unexpected token < eslint

question

Recently, I found a problem when using react native to develop an app:
insert image description here
Error details:
insert image description here
As you can see, this is the correct way of writing jsx, and there is no grammatical error, but eslint still reports an error, which roughly means unexpected symbols <. It can be inferred that eslint is not correct It is caused by parsing the jsx syntax. Although the program can run normally, it is really unbearable for obsessive-compulsive disorder.

analyze

Reason: The development environment is not compatible with ESLint's current parsing capabilities

Solution: parse with babel-eslint

solve

Installbabel-eslint

npm install babel-eslint --save-dev

Add in .eslintrc.js

parse: 'babel-eslint'

insert image description here
Problem solved, error cleared.

Guess you like

Origin blog.csdn.net/ZHANGYANG_1109/article/details/128568641