JSHint & Use Strict - 'function' not defined?

When I enable Use Strict for JSHint and add "use strict"; to the top my scripts, now I get errors from JSHint if the function is not defined in the same file that it is called. How do I get rid of this error?

8 comments
Comment actions Permalink

I guess I have to use the global option. That sucks, because I do this A LOT.

0
Comment actions Permalink

You can add /*global ... */ or fill "Predefined" field in JSHint integration UI (Settings | JavaScript | Code Quality Tools | JSHint).

0
Comment actions Permalink

Yea, I figure that out, but again, that sucks. We have a lot of "cross-file" calls.

0
Comment actions Permalink

What sucks the most about this, is that if you set it to Global, then PHPStorm doesn't autocomplete on parameters
or know that this is a function in another file (Navigate->Declaration.)

0
Comment actions Permalink

Ok, so if I put in in Predefined, but not when I used Globlal, though in effect they are the same thing. I'm filing this as a bug.

0
Comment actions Permalink

Sorry, that was incorrect. It was using var instead of declared Global that caused that issue. My mistake.

0
Comment actions Permalink

I can't Global or Predefined for something like this:

(!PRIDE) PRIDE = {};

Because I get an error that PRIDE is undefined. If I put do this /*global PRIDE */, then I get an error that PRIDE is read-only!!!

0
Comment actions Permalink

To fix "PRIDE is read-only" error, you can specify

/*global PRIDE:true*/

Alternatively it's possible to specify PRIDE:true in "Predefined (, separated)" JSHint field.
0

Please sign in to leave a comment.