How to tell eslint to allow dynamic ECMA-Script imports

I want to use the "Stage-3" sentence now import()

. If I tie my code with ESLint it complains:

Parsing error: 'import' and 'export' may only appear at the top level

      

This is true for a static form import

, but not for a new, dynamic one. I cannot find the correct one for ESLint. Can anyone give me a hint?

+4


source to share


1 answer


Of course, this is Gyandeep. It's not about rules, but about a parser (which is every parsing error ...). So now I use babel-eslint

with the following .eslintrc

(excerpt):

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

      



Also, I made sure I installed and used babel-plugin-syntax-dynamic-import

.

+4


source







All Articles