Ent*_*ame 7 eslint atom-editor babeljs
我更新了所有软件包,现在我使用 eslint 2.4.0 和 babel-eslint 5.0.0。
但现在,我在 eslint 检查时遇到错误:
AssertionError: 当模式为 ES6 且在模块上下文中时,应该出现 ImportDeclaration。
我的.eslintrc是:
{
"ecmaFeatures": {
"jsx": true,
"modules": true
},
"env": {
"browser": true,
"node": true
},
"parser": "babel-eslint",
"rules": {
"quotes": [2, "single"],
"strict": [2, "never"],
"react/jsx-uses-react": 2,
"react/jsx-uses-vars": 2,
"react/react-in-jsx-scope": 2
},
"plugins": [
"react"
]
}
Run Code Online (Sandbox Code Playgroud)
有不兼容的情况吗?突破性改变?
谢谢
小智 8
昨天(2022 年 7 月 29 日)我得到了“当模式为 ES6 且在模块上下文中时应该出现 ImportDeclaration”,但今天终于解决了。
如果您在 nextJS 项目中新安装了 eslint,请编辑 eslintrc.json 文件的这一部分,如下所示。
"parserOptions": {
"ecmaFeatures": {
"jsx": true
},
"ecmaVersion": 13,
"sourceType": "module"
}
Run Code Online (Sandbox Code Playgroud)
对我来说,解决方法是将“ecmaVersion”从“最新”更改为 13。
执行此操作后,运行 eslint 命令可能会引发新错误,只需更新 eslint 规则即可阻止这些错误。
对我来说,我必须将 "react/prop-type": "off" 更改为 "react/prop-types": "off" - 我只是在“react/prop-type”部分添加了一个“s”。
我希望这有帮助
| 归档时间: |
|
| 查看次数: |
10311 次 |
| 最近记录: |