Search code examples
javascriptreactjseslinteslint-config-airbnb

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


Solution

  • The same thing happened to me, and I found out that there was a global .eslintrc which included react!

    enter image description here

    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 (e.g.: C:\Users\<username>)
    Be careful and check whether any other projects depend on the global config.