SyntaxError: 'import' and 'export' may appear only with 'sourceType: module' - Gulp

后端 未结 10 825
天命终不由人
天命终不由人 2020-11-27 20:10

Consider the following two files:

app.js

import Game       from \'./game/game\';
import React      from \'react\';
import ReactDOM   fro         


        
10条回答
  •  长情又很酷
    2020-11-27 20:34

    ESLint natively doesnt support this because this is against the spec. But if you use babel-eslint parser then inside your eslint config file you can do this:

    {
      "parser": "babel-eslint",
      "parserOptions": {
        "sourceType": "module",
        "allowImportExportEverywhere": true
      }
    }

    Doc ref: https://github.com/babel/babel-eslint#configuration

    Answer referred from here : ignore eslint error: 'import' and 'export' may only appear at the top level

提交回复
热议问题