0

Let's take this file :

const foo = require('./bar')

foo is not used anymore.

How to automatically remove this line from the file ? Is there any command for that job ?

tfontain
  • 66
  • 12
  • I will not answer your question, but, with VS Code (and maybe an extension), you can see unused variables and functions in your file. – Jérémie RPK Aug 15 '21 at 16:14

1 Answers1

0

If you're using VS code then go to one unused declaration then press Ctrl+.. Or hover over it and It will a show quick fix option. Click on it then select the Delete all unused declaration.

Or if you're using vim/nvim with coc.vim use the <leader>qf shortcut to do a quick fix.

Edit

I found that this question has already been answered here Is there a way to remove unused imports and declarations

h-sifat
  • 1,455
  • 3
  • 19