Eslint报错--sourceType 'module' is not supported when ecmaVersion <2015.

1,508 阅读1分钟

最近在做企业微信开发,在网上找了个小demo跑一跑之后就开始出现各种问题

Parsing error: sourceType 'module' is not supported when ecmaVersion < 2015. Consider adding `{ ecmaVersion: 2015 }` to the parser options

就比如这个代码里面import就直接飘红,在网上看了很多配置改了之后都没什么效果,最后在stackoverflow看到了同样的问题下边给的一个解答最终帮我解决了这个问题
I cannot make a config to override the main configuration of the eslint.js

.eslintrc

module.exports = {
  "root": true,
  "env": {
    "node": true,
    "browser": true,
  },
  "globals": {},
  "parserOptions": {
    "ecmaVersion": 5,
    "sourceType": "module",
    "ecmaFeatures": {
      "jsx": true,
    },
  },
 
  "extends": ["myplugin"],
  "rules": {
    "prettier/prettier": ["error"],
  },
}

eslint-config-myplugin

module.exports = {

      "parserOptions": {
        "ecmaVersion": 6,
      }
   

}

i get this error:

0:0 error Parsing error: sourceType 'module' is not supported when ecmaVersion < 2015. Consider adding { ecmaVersion: 2015 } to the parser options

✖ 1 problem (1 error, 0 warnings)