简体   繁体   English

Eslint 不会因为 eslint 插件错误而工作?

[英]Eslint wont work because of eslint plugin error?

I can't seem to get my eslint to work.我似乎无法让我的 eslint 工作。

I have the eslint extenstion on vscode.我在 vscode 上有 eslint 扩展。 I created a new node project and npm installed eslint as a dev dependency.我创建了一个新的节点项目,并 npm 安装了 eslint 作为开发依赖项。 I chose the Air-BNB style and then went to check if it worked.我选择了Air-BNB风格,然后去检查它是否有效。 Whenever I open a file I get a notification saying there is an error with eslint.每当我打开一个文件时,我都会收到一条通知,说 eslint 有错误。

Vscode notification error message vscode通知错误信息

ESlint stack trace error output ESlint 堆栈跟踪错误 output

Some things I did:我做过的一些事情:

  • I installed eslint locally.我在本地安装了eslint。

  • At one point I found out that I had eslint installed globally so I removed it and stuck with the local install per project basis.有一次我发现我已经全局安装了 eslint,所以我删除了它并坚持每个项目的本地安装。

  • Ive disabled and enabled vscode eslint (Extension ESlint 2.1.8).我已经禁用并启用了 vscode eslint(扩展 ESlint 2.1.8)。

My Config File:我的配置文件:

 module.exports = { env: { browser: true, commonjs: true, es2020: true, }, extends: [ 'airbnb-base', ], parserOptions: { ecmaVersion: 11, }, rules: { }, };

Here are my dev dependencies:这是我的开发依赖项:

 "devDependencies": { "eslint": "^7.7.0", "eslint-config-airbnb-base": "^14.2.0", "eslint-plugin-import": "^2.22.0", "eslint-plugin-require": "0.0.1" }

The problem is right their in the error message, you have two different versions of eslint-plugin-import in your node-modules tree.问题出在错误消息中,您的节点模块树中有两个不同版本的eslint-plugin-import You just need to make sure you only have one version.你只需要确保你只有一个版本。

I expect you tried to add a newer version than the one used by CRA.我希望您尝试添加比 CRA 使用的版本更新的版本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM