Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Warn about uses of "self", to find mistakes in the "var self = this" …

…pattern
  • Loading branch information...
commit 0bff951101ff778a35a2508768012794f118812c 1 parent c576c27
@lennartcl lennartcl authored
Showing with 9 additions and 1 deletion.
  1. +9 −1 plugins-client/ext.jslanguage/scope_analyzer.js
View
10 plugins-client/ext.jslanguage/scope_analyzer.js
@@ -43,7 +43,6 @@ var GLOBALS = {
"undefined" : true,
"null" : true,
"arguments" : true,
- self : true,
"Infinity" : true,
onmessage : true,
postMessage : true,
@@ -481,6 +480,15 @@ handler.analyze = function(doc, ast, callback) {
scope.get(b.x.value).addUse(node);
} else if(handler.isFeatureEnabled("undeclaredVars") &&
!GLOBALS[b.x.value] && !jshintGlobals[b.x.value]) {
+ if (b.x.value === "self") {
+ markers.push({
+ pos: this.getPos(),
+ level: 'warning',
+ type: 'warning',
+ message: "Use 'window.self' to refer to the 'self' global."
+ });
+ return;
+ }
markers.push({
pos: this.getPos(),
level: 'warning',
Please sign in to comment.
Something went wrong with that request. Please try again.