nipunadrox
nipunadrox

Reputation: 21

ESLint extend error : Failing to load config

My project structure :

helloworld
  src
    UI
      debug.js
    public
      node_modules
        eslint
        eslint-config-airbnb-base
        eslint-plugin-import
  .eslintrc.json
  package.json
  debug.js
  .yarnrc

.yarnrc :

--*.modules-folder "./src/public/node_modules"

.eslintrc.json :

{
    "root": true,
    "env": {
        "browser": true,
        "es2021": true
    },
    "extends": [
        "airbnb-base"
    ],
    "parserOptions": {
        "ecmaVersion": "latest"
    },
    "rules": {
    }
}

When I run the linter in terminal using src/public/node_modules/.bin/eslint debug.js OR src/public/node_modules/.bin/eslint src/ui/debug.js it's throwing the below error.

Oops! Something went wrong! :(

ESLint: 8.8.0

ESLint couldn't find the config "airbnb-base" to extend from. Please check that the name of the config is correct.

The config "airbnb-base" was referenced from the config file in "/projects/linter/helloworld/.eslintrc.json".

BUT - if I move the .eslintrc.json & debug.js to /src/public and run src/public/node_modules/.bin/eslint src/public/debug.js, the file will be linted successfully.

How could I point the eslint to refer the config in src/public/node_modules/ so it would lint the debug.js in root as well as in /src/ui/ ?

Thanks in advance.

Upvotes: 2

Views: 11012

Answers (1)

Akasha
Akasha

Reputation: 1077

Having eslintrc.json in the project root shouldn't be a problem.

Could you please post the content of package.json?

Meanwhile, here are some suggestions for what could be conflicting:

  • If eslint-config-airbnb-base isn't in package.json, try to install it:
yarn add --dev eslint-config-airbnb-base
  • If ESLint was installed globally, try to remove it and install it locally instead:
yarn global remove eslint
yarn add --dev eslint

Upvotes: 1

Related Questions