Webstorm: Automatic imports?

does anybody know if Webstorm can do “automatic” imports? So for example if I’m using Meteor.startup(), it should automatically do an import Meteor from {meteor/meteor}?

1 Like

I don’t think there’s really any way it can actually know. Like what if you have two files that export something with the same name?

Yeah you’re right, but is there any “auto completion” for Webstorm? In my case I have to type in everything manually without any recommendation popup.

You can make a live template under settings / editor / live templates. So that when you type for example: imp:meteor it will be expanded to 'import { Meteor } from 'meteor/meteor';.

With ASP.NET and Visual Studio, unresolved references can be easily fixed by Visual Studio itself. It’s just a matter of right-clicking on the unresolved reference and selecting from the menu. Then the appropriate import statement appears at the top. A similar feature could be developed in WebStorm.

Eclipse for Android also had similar feature - it inserted import statements automatically when building the project.

Mhhh…in Webstorm the variables are declared as defined even without any import. So for example I’m having a component called App, I can do var test = App; in any file, WebStorm shows it as valid, while Meteor stops running, because App isn’t defined.

If you use ESLint and forbidd global variables, an error will be reporterd by Webstorm.

1 Like