Configuring inspection "Unresolved JavaScript variable" to recognize global variables from external files

I have a PHP/HTML page which has something like this:
<!DOCTYPE html>
<script src="/jquery.js" type="text/javascript"></script>
<script type="text/javascript">
var foobar = 10;
<script src="/test.js" type="text/javascript"></script>
<button>Click me!</button>

and in test.js:

$('button').click(funtion() {

"Unresolved JavaScript variable" inspection reports "foobar" variable in test.js as unresolved. Is it possible to configure this inspection (at least indirectly) to lookup global scope variables in all files (.js or .php/.html/etc with JavaScript)?
This would be really helpful and could be configured to be an error to quickly see where global JavaScript variables are not declared with the "var" keyword.

Comment actions Permalink

Add following code to comment, there is no option to lookup all html files
/*global foobar */

Comment actions Permalink
/*global foobar */  worked, and there should not be a space between "/*" and "global".
Is this construct documented somewhere?
Comment actions Permalink

Are there any support for unrecognized properties? For example in

/*global myGlobalVarDefinedElseWhere */

myProperty is treated as unrecognized.

Comment actions Permalink

For all who land here via search engines. "use strict" from ECMAScript 5 may also be helpfull.


Please sign in to leave a comment.