eslint-plugin-import
eslint-plugin-import copied to clipboard
'import/parsers' setting breaks my editor linter (VS Code)
Hi Friends,
I am trying to use the rule 'import/no-unused-modules': [2, { unusedExports: true }] which, from research, requires the following eslintrc config:
settings: {
'import/parsers': {
'@typescript-eslint/parser': ['.ts', '.tsx'],
},
'import/resolver': {
node: true,
typescript: true,
},
},
However, when I add the 'import/parsers' setting, the editor lint plugin seems to stops reporting anything. Does anyone know what the cause for this is, and how to resolve it?
This is the lint plugin log:
[Info - 15:46:02] ESLint server is starting.
[Info - 15:46:02] ESLint server running in node v16.14.2
[Info - 15:46:02] ESLint server is running.
[Info - 15:46:03] ESLint library loaded from: [...]/src/ui/node_modules/.pnpm/[email protected]/node_modules/eslint/lib/api.js
[Warn - 15:46:04]
No ESLint configuration (e.g .eslintrc) found for file: [...]/src/ui/apps/webtrader/.eslintrc.js
File will not be validated. Consider running 'eslint --init' in the workspace folder ui
Alternatively you can disable ESLint by executing the 'Disable ESLint' command.
@JounQin is this the breaking change you were referencing?
I don't think so, that commit has not been released yet.
Yep. Getting exactly the same thing here.
No ESLint configuration (e.g .eslintrc) found for file: .../src/file.ts
File will not be validated. Consider running 'eslint --init' in the workspace folder backend
Alternatively you can disable ESLint by executing the 'Disable ESLint' command.
To add to that a little:
- Node 20.12.0 & 18.13.0
- VS Code, Webstorm & Cursor all have the same issue: IDE doesn't work, but running lint commands in CLI does work
I had the following rules activated from eslint-plugin-import
"import/no-empty-named-blocks": "error",
"import/no-named-as-default": "error",
"import/no-unused-modules": [1, {"unusedExports": true}],
"import/no-unassigned-import": "error",
I went through one-by-one and identified this as causing this issue
"import/no-unused-modules": [1, {"unusedExports": true}],
plugins:
...,
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 12,
"sourceType": "module",
"project": "./tsconfig.json",
"tsconfigRootDir": appRoot.path,
},
"plugins": [
"simple-import-sort",
"no-unawaited-dot-catch-throw",
"import",
"promise",
],
...
dependencies:
"@typescript-eslint/eslint-plugin": "5.62.0",
"@typescript-eslint/parser": "5.62.0",
"eslint": "7.32.0",
"eslint-plugin-import": "2.29.1",
"eslint-plugin-no-unawaited-dot-catch-throw": "0.1.0",
"eslint-plugin-only-warn": "1.0.3",
"eslint-plugin-promise": "6.4.0",
"eslint-plugin-simple-import-sort": "7.0.0"