WebStorm: turn off auto deletion for unused imprts

Viewed 45

I like the optimized imports a lot except for one behavior that I want to get rid of.

So if I make a bracket mistake in my JSX and use an imported library below this mistake it automatically removes this import on save. Then I fix the issue and now my imports are gone and I have to get them manually back (or copy my changes and command + z until they are back again and paste my new changes).

This is really annoying so I'm searching for the option to turn off deletion for unused imports in WebStorm.

1 Answers

Just found out that suppressing JavaScript and TypeScript | Imports and dependencies | Unused ES6 / TypeScript imports inspection for particular import or for the whole file with // noinspection ES6UnusedImports helps:

// noinspection ES6UnusedImports
import {Bar} from "bar";
Related