How to prevent WebStorm from removing imports? - webstorm

WebStorm is removing unused imports by default. How can I turn this off?
e.g. if I comment out an imported element, the import statement is auto-deleted. When I comment that element back in, I need to manually insert the necessary import statement again.
Often auto-insert of import statements does not help since WebStorm does not recognize that the element has to be imported...

Unused imports are always removed when optimizing imports, so, if you like to keep them, don't run Code | Optimize imports, and make sure that Optimize Imports is not enabled in Reformat Code dialog: Code | Show Reformat File dialog, clear the Optimize Imports checkbox

Related

WebStorm: turn off auto deletion for unused imprts

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.
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";

Can "Remove Unnecessary Usings" in VS2017 be customized?

VS2017 includes a feature to remove all unnecessary using statements from the top of a .cs file. While useful, I'd like to configure it to not remove System.Linq even if it is unused. Otherwise I have to add it back in as soon as I need to use an extension method.
Is there any way to change the default behavior?

Auto curly braces in WebStorm, check for modification

I am using WebStorm to make React application.
Firstly, when I use JSX tag attribute, it automatically creates curly brace. How can I disable this option?
Secondly, when our source code was modified, many IDE shows us that this file is changed. In VSCode it's done like this:
but WebStorm is not. So I can't know whether this file has changed or not. How can I set this?
Firstly, when I use JSX tag attribute, it automatically creates curly brace. How can I disable this option?
See https://stackoverflow.com/a/46949738/783119 -- should explain the situation (so I do not repeat the same here)
Secondly, when our source code was modified, many IDE shows us that this file is changed.
Settings/Preferences
Editor | General | Editor Tabs
Enable Mark modified tabs with asterisk option.

Autocomplete for import keyword is ommiting file extension

I am having a problem with WebStorm auto complete when using import keyword in JavaScript.
You can see an example here: https://i.gyazo.com/95adbf84c964663f715fc069ba1e1e8a.mp4
Basically when I auto complete following code:
import {loadLevel, loadSprite} from './loaders';
It doesn't add a file extension to loaders, which should look like this:
import {loadLevel, loadSprite} from './loaders.js';
I am using latest WebStorm version, I also tried to Invalidate cache and restarted IDE.
I am using JavaScript ES6 version in settings.
There are no other files called loaders with different extension anywhere else in my project.
If you need any more info, let me know.
Thanks
WebStorm supports completing file name with extension (when using completion in the from part). To enable completing file name with extension, set registry key commonjs.complete.required.filename.with.extension to true :
Open Help | Find Action... dialog
Type Registry, find Registry item in dropdown list and press Enter
Find commonjs.complete.required.filename.with.extension there, tick the checkbox
But this hidden option doesn't affect auto-imports, so, when auto-creating import statement from reference, extension won't be added - WEB-28741

PyCharm not doing full syntax coloring for a specific file name

In my Django projet, I have one models.py file that PyCharm is only partially syntax coloring: it's coloring the Python keywords and comments but not other things it normally does like coloring method names, keyword parameters. This is the only file in my project like this -- all other .py files are fully syntax colored.
It's the file name not contents that is the issue. I know this because when I rename the file, PyCharm immediately fully syntax colors it. When I rename it back to models.py, it goes back to partial coloring.
Note it's not just the syntax coloring that's off -- it's also other code analysis-related tools for this file.
What could be causing PyCharm to be treating this one file differently?
In the PyCharm status bar, there is a "Highlighting level" indicator. Clicking on it allows you to choose the highlighting level between "None", "Syntax" and "Inspections", and the selected value is persisted per file. Please try clicking on it and making sure that the level is set to "Inspections".