Search code examples
javascriptvisual-studio-codesettings

VScode is not graying out unused variables


I've found many answers on here, however none of them work.

VS code how to show unused variables as red

VS code doesn't gray out unused variables

VSCode - gray out unused imports

As we can see here, Component is not grayed out. Screenshot for color example

enter image description here ^ screenshot to show the highlighting issue

Code block: (this line import { Component } from 'react', should be grayed out, also const happy should be grayed out.

import { Component } from 'react'
import './search-box.styles.css'

const happy = ''

const SearchBox = ({ className, placeholder, onChangeHandler }) => {
  return (
    <input
      className={`search-box ${className}`}
      type='search'
      placeholder={placeholder}
      onChange={onChangeHandler}
    />
  )
}

export default SearchBox

All the settings I've tried:

"javascript.validate.enable": true,
"javascript.showUnused.enabled": true,
"typescript.showUnused.enabled": true,
"editor.showUnused": true,

I observe the same behavior when I delete all my user settings (which resets them to the default).

When I run VS Code with extensions disabled, I observe the same behavior.

VS Code version

Version: 1.82.2 (Universal)
Commit: abd2f3db4bdb28f9e95536dfa84d8479f1eb312d
Date: 2023-09-14T05:59:47.790Z
Electron: 25.8.1
ElectronBuildId: 23779380
Chromium: 114.0.5735.289
Node.js: 18.15.0
V8: 11.4.183.29-electron.0
OS: Darwin arm64 22.6.0

VS Code Extensions

Babel ES6/ES7
Better Comments
colorize
crates
Docker
DotENV
Emmet commands and keybindings
ES7+ React/Redux/React-Native snippets
Even Better TOML
GitHub Theme
GitLens
GraphQL
IntelliCode
IntelliCode API Usage Examples
Live Server
Markdown All in One
Material Icon Theme
Mithril Emmet
One Dark Pro
Path Autocomplete
Prettier - Code formatter
rust-analyzer
Snazzy Operator
Spirted Away Color Theme
Stylelint
Tailwind CSS intelliSense
vsode-icons
vscode-styled-components

Solution

  • Found the answer here:

    VisualStudioCode editor.showUnused true not working

    Had to completely uninstall VScode and run some extra rm -rf commands https://jimkang.medium.com/complete-uninstall-remove-vscode-mac-5e48bef3bdec

    Step 1

    rm -rf $HOME/Library/Application\ Support/Code
    // add sudo if you needed to
    // if you're using insider*
    sudo rm -rf $HOME/Library/Application\ Support/Code\ -\ Insiders/
    

    Step 2

    rm -rf $HOME/.vscode
    // add sudo if you needed to
    // if you're using insider*
    sudo rm -rf $HOME/.vscode-insiders/