Reputation: 109
Here is the JSON:
{
"env": {
"node": true
},
"root": true,
"parser": "@typescript-eslint/parser",
"extends": [
"standard",
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"plugin:import/errors",
"plugin:import/warnings",
"plugin:promise/recommended",
"prettier"
],
"parserOptions": {
"ecmaVersion": 2021,
"sourceType": "module"
},
"plugins": [
"prettier", "@typescript-eslint"
],
"rules": {
"semi": [2, "always"]
}
}
And here goes the js file:
module.exports = {
root: true,
parser: '@typescript-eslint/parser',
extends: [
'standard',
'eslint:recommended',
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
'plugin:import/errors',
'plugin:import/warnings',
'plugin:promise/recommended',
'prettier',
],
parserOptions: {
ecmaVersion: 2021,
sourceType: 'module',
},
plugins: ['prettier', '@typescript-eslint'],
rules: {
'semi': [2, 'always']
},
env: {
node: true,
},
};
Can't figure out what is causing this issue.
If I comment the contents of the js file and leave the json config and then run npx eslint src/test.ts
, I get this:
Oops! Something went wrong! :(
ESLint: 7.32.0
ESLint couldn't find the plugin "@typescript-eslint/eslint-plugin".
(The package "@typescript-eslint/eslint-plugin" was not found when loaded as a Node module from the directory "/Users/Albert/Documents/Projects".)
It's likely that the plugin isn't installed correctly. Try reinstalling by running the following:
npm install @typescript-eslint/eslint-plugin@latest --save-dev
The plugin "@typescript-eslint/eslint-plugin" was referenced from the config file in "../.eslintrc.js".
If you still can't figure out the problem, please stop by https://eslint.org/chat/help to chat with the team.
Why is it looking for the plugin inside the 'Projects' dir?
I tried the proposed solution, didn't work.
Upvotes: 5
Views: 15346
Reputation: 1077
It looks like you have an ESLint configuration file in the Project folder, which is up the directory structure of your actual project folder.
When you run ESLint in a folder, ESLint first looks for configuration files in that folder. Then, it looks in the parent folder - if there is a configuration file there, it merges it with the initial configuration file. ESLint keeps going up the directory structure and merges each configuration file it finds, until it reaches your root directory.
If you want to limit ESLint to the configuration file in your project, add this in the eslintrc.js
or eslintrc.json
file:
{
"root": true
}
This will make ESLint stop looking for configuration files beyond this one.
Whichever file you add the root
key to, delete the other file. If there is more than one configuration file in a folder, ESLint will use only one (between eslintrc.js
and eslintrc.json
, it will use the former, because each format has a priority order).
You can find more information about the priority order here and how ESLint looks for configuration files here.
Upvotes: 8