忽略eslint错误:“导入"和“导出"可能仅出现在顶层 [英] ignore eslint error: 'import' and 'export' may only appear at the top level

查看:892
本文介绍了忽略eslint错误:“导入"和“导出"可能仅出现在顶层的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在eslint中停用此错误?

Is it possible to deactivate this error in eslint?

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

推荐答案

ESLint本机不支持此操作,因为这违反规范.但是,如果使用babel-eslint解析器,则可以在eslint配置文件中执行以下操作:

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
  }
}

文档参考: https://github.com/babel/babel-eslint#configuration

这篇关于忽略eslint错误:“导入"和“导出"可能仅出现在顶层的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆