9

I want to use the now "Stage-3" proposal import(). If I lint my code with ESLint it's complaining about:

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

Which is correct for the static form of import but not for the new, dynamic one. I don't find the right option to make ESLint allow that. Can someone give me a hint?

4nduril
  • 279
  • 1
  • 10
  • 5
    ESLint natively supports stage 4 and above features. Anything below it, you have to use `babel-eslint` parser. – Gyandeep Feb 22 '17 at 17:53

1 Answers1

7

Of course is Gyandeep right. It's no question of rules but of the parser (That's what parsing error means after all…). So I use now 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.

Sean
  • 1,279
  • 9
  • 17
4nduril
  • 279
  • 1
  • 10
  • I do the above and still get error, described here: https://stackoverflow.com/questions/44145543/babel-eslint-does-not-allow-dynamic-import – croraf May 23 '17 at 22:34