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>
<html>
<head>
<script src="/jquery.js" type="text/javascript"></script>
<script type="text/javascript">
var foobar = 10;
</script>
<script src="/test.js" type="text/javascript"></script>
</head>
<body>
<button>Click me!</button>
</body>
and in test.js:
$('button').click(funtion() {
alert(foobar);
});
"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.
Please sign in to leave a comment.
Add following code to comment, there is no option to lookup all html files
/*global foobar */
http://www.jslint.com/lint.html
Are there any support for unrecognized properties? For example in
/*global myGlobalVarDefinedElseWhere */
alert(myGlobalVarDefinedElseWhere.myProperty);
myProperty is treated as unrecognized.
For all who land here via search engines. "use strict" from ECMAScript 5 may also be helpfull.