import-js
import-js copied to clipboard
Add WebStorm plugin
Now that import-js has extracted the core into a standalone gem, it can be integrated more easily with additional editors. We already have emacs and Sublime Text support and we should add WebStorm support. https://plugins.jetbrains.com/webStorm
In a recent JS survey, WebStorm was one of the most popular editors for JS developers: https://ponyfoo.com/articles/javascript-developer-survey-results#what-are-your-preferred-text-editors
To create a plugin, there are a few options. The best thing is if the editor already supports plugins written in Ruby. Then you can directly instantiate a ImportJS::Importer with a custom editor class (e.g. ImportJS::WebStormEditor). Look at ImportJS::VIMEditor for inspiration.
If the plugin framework doesn't allow Ruby plugins, then you can do what the Sublime plugin does: use the external import-js command-line tool (available after installing the import_js gem, notice differences in dash and underscore between gem and CLI tool - that's unfortunate but intentional). The CLI tool accepts file contents via stdin, and outputs the whole file again (after doing imports) in stdout. In case there are messages to display, or ambiguities to resolve, stderr contains a JSON blob with useful information. See https://github.com/trotzig/import-js/blob/master/import-js.py for how the Sublime plugin is implemented.
The Emacs plugin uses a slightly different approach. It keeps a running Ruby process and passes messages back and forth. See https://github.com/trotzig/import-js/blob/master/plugin/import-js.el .
I'll be happy to provide continued support for whoever makes an attempt at creating a plugin.
Is this still relevant? @trotzig @lencioni
I think we can close this out.