How to tell eslint to allow staged ECMA-Script dynamic imports

一笑奈何 提交于 2019-12-10 13:29:48

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/42394593/how-to-tell-eslint-to-allow-staged-ecma-script-dynamic-imports

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!