简体   繁体   中英

ESLint + Airbnb without eslint-plugin-react

I'm trying to use ESLint + Airbnb and I'm receiving the error message:

Failed to load plugin react: Cannot find module 'eslint-plugin-react'

But I'm not using eslint-plugin-react see above my .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 . Tell me why this plugin its required

According to their thread on git , add { "extends": "airbnb/base" } to your config.

edit: the above is deprecated. The same thread recommends to use this package: 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!

在此处输入图片说明

This is possibly because I had ESLint installed globally before and/or some generator tool created that global config. Although you're running ESLint locally now, it always looks for global configuration.
Of course, deleting the global config resolved the problem.
It's in your user directory (eg: C:\\Users\\<username> )
Be careful and check whether any other projects depend on the global config .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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