Generating require()/import statements from fuzzy-finder


#1

When I write JavaScript code, one of the thing I do very, very often is writing require()/import statement.

It takes quite some mental workload to write it, because

  • I need to recall in which directory is the file I am writing.
  • I also need to recall where the file I want to require() is.
  • Then I need to think how many times I should type ../../...

So I wrote a bit of init script to automate this. It hijacks the fuzzy-finder, and when you press Cmd+I instead of Enter, it will generate an import statement and insert it into the editor.

You can find the code in my article, JavaScript require/import helper.

By the way, I just started a publication on Medium called Hacking Atom where I post small Atom hacks that I didn’t make into a package. I hope you’ll find them interesting, and please let me know if you’d like to write!