2

I'm writing a single-page JavaScript application and I'm using Atom as my text-editor. (It's an Electron application, but that's besides the point.)

I'm also using the linter-jshint plugin for Atom. This is great, as it shows immediately in the text-editor when I make a typo in a variable, among other useful things.

Lately, my app has been getting very long. Naturally, I want to try and split it up across multiple files. After doing some research on StackOverflow, I've determined that I can use Grunt to automatically concatenate JavaScript files together. This is great because I don't have to refactor my code - I can just copy paste my existing functions into separate files. Easy!

However, once I do this, Atom fills up with warnings and errors from JSHint, because it can't find variables and functions that are located in the other files!

Now, I could just abandon the JHint plugin in Atom altogether and use the JSHint plugin for Grunt after the concatenation has already occured. But that sucks! I want the code that I'm going to be writing to be checked on the fly like a real IDE.

Is there a way to tell Atom/JSHint to assume that a bunch of JavaScript files will all be concatenated together? Or am I just approaching this problem completely wrong?

Community
  • 1
  • 1
James
  • 1,394
  • 2
  • 21
  • 31

1 Answers1

1

You can split your electron application with Node Common Modules, and use require('./state.js'); within your application.

Although I don't use Atom, that should allow for it to understand how you're using your variables and functions in other files.

Also this should eliminate your need for concatenation as the single-page app will have all it's dependencies accounted for.

atschaal
  • 355
  • 1
  • 14