Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Removing unused imports in AngularJS project in bulk using Visual Studio Code

I'm tasked with cleaning our AngularJS project to remove unused imports and variables. I use VS Code and through TypeScript Hero extension I can do what I want to do one file at a time. However, is there a way to fix all typescript files in project?

like image 890
Devin Avatar asked Nov 27 '17 16:11

Devin


1 Answers

For visual studio code, you can simply open your preference settings and add the following to your settings.json:

"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
  "source.organizeImports": true
}

You can also enable/disable on save per language using following setting.json:

"editor.formatOnSave": true,
"[typescript]": {
    "editor.codeActionsOnSave": {
        "source.organizeImports": true
    }
},

This new feature has been released since April last year in 2018. Hopefully this can be helpful!

like image 52
JayKan Avatar answered Oct 02 '22 13:10

JayKan