I'm trying to setup linting for a node project. I wish to use the airbnb style guide.
These are my dev dependencies in package.json:
"devDependencies": {
"eslint": "^8.2.0",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-plugin-import": "^2.25.2"
}
This is my .eslintrc.json file:
{
"env": {
"es2021": true,
"node": true
},
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "module"
},
"extends": "airbnb",
"rules": { /* ... */ }
}
I keep getting this error (in the VSCode Output terminal):
[Info - 9:24:00] Failed to load config "airbnb" to extend from. Referenced from: C:\GitWorkspace\lorand.eu\backend\.eslintrc.json
Note that eslint works just fine whenever using .yml or .js files as configuration.
How could I solve this error in the json config file?
P.S While this is a minimal reproducible error, the setup process that yielded the error came by following the instructions in this video: https://www.youtube.com/watch?v=SydnKbGc7W8&t=1111s
CodePudding user response:
When you use the eslint-config-airbnb-base
package via the command below...
$ npm install --save-dev eslint-config-airbnb-base
...you have to add "airbnb-base" the following to your .eslintrc.json
file's extends
field, as seen below:
"extends": "airbnb-base"
The package eslint-config-airbnb
that is installed via the command...
npm install --save-dev eslint-config-airbnb
...is the package that you use "extends": "airbnb"
to your .eslintrc
file
The difference is that the latter, the airbnb
supports react, where the airbnb-base
does not.
Obviously, you don't want to add the unnecessary rules for a framework you're not using.