vscode-eslint: ESLint giving false positives for unused vars in typescript code

I am using Visual Studio Code with the ESLint extension and am getting false positives on imports being reported as violating the @typescript-eslint/no-unused-vars rule.

Visual Studio Code version info:

Version: 1.52.1 (user setup) Commit: ea3859d4ba2f3e577a159bc91e3074c5d85c0523 Date: 2020-12-16T16:34:46.910Z Electron: 9.3.5 Chrome: 83.0.4103.122 Node.js: 12.14.1 V8: 8.3.110.13-electron.0 OS: Windows_NT x64 10.0.19042

ESLint v2.1.14

settings.json and eslintrc files are attached. The same code and eslintrc show no warnings when using IntelliJ Ultimate.

image

eslintrc:

{
    "extends": [
        "eslint:recommended",
        "plugin:@typescript-eslint/eslint-recommended",
        "plugin:@typescript-eslint/recommended",
        "prettier/@typescript-eslint",
        "plugin:prettier/recommended",
        "plugin:react/recommended"
    ],
    "env": {
        "browser": true,
        "node": true,
        "es6": true
    },
    "parser": "@typescript-eslint/parser",
    "plugins": ["@typescript-eslint", "react"],
    "parserOptions": {
        "ecmaVersion": 2018, // Allows for the parsing of modern ECMAScript features
        "sourceType": "module", // Allows for the use of imports
        "ecmaFeatures": {
            "jsx": true // Allows for the parsing of JSX
        }
    },
    "settings": {
        "react": {
            "version": "detect" // Tells eslint-plugin-react to automatically detect the version of React to use
        }
    }
}

settings.json

{
    "editor.minimap.enabled": false,
    "editor.fontSize": 11,
    "[javascript]": {
        "editor.defaultFormatter": "esbenp.prettier-vscode"
    },
    "git.enableSmartCommit": true,
    "files.autoSave": "off",
    "vim.useSystemClipboard": true,
    "eslint.alwaysShowStatus": true,
    "eslint.codeAction.showDocumentation": {
        "enable": true
    },
    "[typescriptreact]": {
        "editor.defaultFormatter": "esbenp.prettier-vscode"
    },
    "editor.formatOnSave": true
}

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 3
  • Comments: 19 (7 by maintainers)

Most upvoted comments

Hey I noticed this issue over the past few months.

It happens in terminal and in vscodeā€¦ its happening on all my react (native) projects, for e.g look at this screenshot

import '../styles/globals.css';
import { ChakraProvider } from '@chakra-ui/react';

import { useAuth, AuthProvider } from '../contexts/auth';

const MyApp = ({ Component, pageProps }) => {
	return (
		<AuthProvider>
			<ChakraProvider>
				<Component {...pageProps} />
			</ChakraProvider>
		</AuthProvider>
	);
};

export default MyApp;

** image **

It seems to happen to object destructuring only.

I resolved this issue by adding to my .eslintrc.json this : "@typescript-eslint/no-unused-vars": "off",

I am also facing the same issue.