简体   繁体   English

没有eslint插件反应的ESLint + Airbnb

[英]ESLint + Airbnb without eslint-plugin-react

I'm trying to use ESLint + Airbnb and I'm receiving the error message: 我正在尝试使用ESLint + Airbnb,并且收到错误消息:

Failed to load plugin react: Cannot find module 'eslint-plugin-react' 无法加载插件反应:找不到模块“ eslint-plugin-react”

But I'm not using eslint-plugin-react see above my .eslintrc.js 但是我没有使用eslint-plugin-react参见我的.eslintrc.js

module.exports = {
  extends: 'airbnb-base',
  rules: {
    'no-console': 0,
    'linebreak-style': [2, 'windows'],
    'no-new': 0,
    'eslint eol-last': ['error', 'never'],
  },
};

But unfortunately I'm receiving the error message before mentioned. 但不幸的是,我收到前面提到的错误消息。 I have no idea about the error. 我不知道这个错误。 I'm not using eslint-plugin-react . 我没有使用eslint-plugin-react Tell me why this plugin its required 告诉我为什么需要此插件

According to their thread on git , add { "extends": "airbnb/base" } to your config. 根据他们在git的线程,在您的配置中添加{ "extends": "airbnb/base" }

edit: the above is deprecated. 编辑:不建议使用以上内容。 The same thread recommends to use this package: https://www.npmjs.com/package/eslint-config-airbnb-base 相同的线程建议使用此软件包: https : //www.npmjs.com/package/eslint-config-airbnb-base

The same thing happened to me, and I found out that there was a global .eslintrc which included react! 同样的事情发生在我身上,我发现有一个全局.eslintrc包含了react!

在此处输入图片说明

This is possibly because I had ESLint installed globally before and/or some generator tool created that global config. 这可能是因为我在全局之前安装了ESLint和/或某些生成器工具创建了该全局配置。 Although you're running ESLint locally now, it always looks for global configuration. 尽管您现在在本地运行ESLint,但它始终会寻找全局配置。
Of course, deleting the global config resolved the problem. 当然,删除全局配置可以解决该问题。
It's in your user directory (eg: C:\\Users\\<username> ) 它在您的用户目录中(例如: C:\\Users\\<username>
Be careful and check whether any other projects depend on the global config . 注意并检查是否还有其他项目依赖于全局配置

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

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