ESLint Parsing error: Unexpected token

后端 未结 8 1994
野趣味
野趣味 2020-11-28 02:12

With this code:

import React from \'react\';
import { Link } from \'react-router\';
import { View, NavBar } from \'amazeui-touch\';

import * as Pages from \         


        
相关标签:
8条回答
  • 2020-11-28 03:10

    Originally, the solution was to provide the following config as object destructuring used to be an experimental feature and not supported by default:

    {
      "parserOptions": {
        "ecmaFeatures": {
          "experimentalObjectRestSpread": true
        }
      }
    }
    

    Since version 5, this option has been deprecated.

    Now it is enough just to declare a version of ES, which is new enough:

    {
      "parserOptions": {
        "ecmaVersion": 2018
      }
    }
    
    0 讨论(0)
  • 2020-11-28 03:17

    I solved this issue by First, installing babel-eslint using npm

    npm install babel-eslint --save-dev
    

    Secondly, add this configuration in .eslintrc file

    {
       "parser":"babel-eslint"
    }
    
    0 讨论(0)
提交回复
热议问题