项目装上 eslint 后出现报错 Parsing error: ‘import’ and ‘export’ may only appear at the top level.*
因为 eslint 可能不支持动态导入
解决办法:
$ npm install eslint babel-eslint --save-dev
or
$ yarn add eslint babel-eslint -D
在.eslintrc.js文件中添加上
module.exports = {
parser: “babel-eslint”,
parserOptions: {
sourceType: “module”,
allowImportExportEverywhere: false,
ecmaFeatures: {
globalReturn: false,
},
babelOptions: {
configFile: “path/to/config.js”,
},
},
};