JSHint & Use Strict - 'function' not defined? Follow
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?
Please sign in to leave a comment.
I guess I have to use the global option. That sucks, because I do this A LOT.
You can add /*global ... */ or fill "Predefined" field in JSHint integration UI (Settings | JavaScript | Code Quality Tools | JSHint).
Yea, I figure that out, but again, that sucks. We have a lot of "cross-file" calls.
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.)
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.
Sorry, that was incorrect. It was using var instead of declared Global that caused that issue. My mistake.
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!!!
To fix "PRIDE is read-only" error, you can specify
Alternatively it's possible to specify PRIDE:true in "Predefined (, separated)" JSHint field.