Comparing version 0.3.5 to 0.3.6
{ | ||
"name": "aether", | ||
"version": "0.3.5", | ||
"version": "0.3.6", | ||
"homepage": "https://github.com/codecombat/aether", | ||
@@ -5,0 +5,0 @@ "authors": [ |
@@ -127,3 +127,3 @@ (function() { | ||
JavaScript.prototype.lint = function(rawCode, aether) { | ||
var e, error, g, jshintGlobals, jshintOptions, jshintSuccess, lintProblems, wrappedCode, _i, _len, _ref3; | ||
var c, e, error, firstParen, firstSemiColon, g, i, jshintGlobals, jshintOptions, jshintSuccess, line, lines, lintProblems, offset, parenCount, row, wrappedCode, _i, _j, _k, _len, _len1, _len2, _ref3, _ref4; | ||
lintProblems = []; | ||
@@ -177,2 +177,50 @@ if (!jshintHolder.jshint) { | ||
} | ||
if (_.isEmpty(lintProblems)) { | ||
lines = rawCode.split(/\r\n|[\n\r\u2028\u2029]/g); | ||
offset = 0; | ||
for (row = _j = 0, _len1 = lines.length; _j < _len1; row = ++_j) { | ||
line = lines[row]; | ||
if (/^\s*if /.test(line)) { | ||
if ((firstParen = line.indexOf('(')) >= 0) { | ||
parenCount = 1; | ||
_ref4 = line.slice(firstParen + 1, +line.length + 1 || 9e9); | ||
for (i = _k = 0, _len2 = _ref4.length; _k < _len2; i = ++_k) { | ||
c = _ref4[i]; | ||
if (c === '(') { | ||
parenCount++; | ||
} | ||
if (c === ')') { | ||
parenCount--; | ||
} | ||
if (parenCount === 0) { | ||
break; | ||
} | ||
} | ||
i += firstParen + 1 + 1; | ||
if (parenCount === 0 && /^[ \t]*;/.test(line.slice(i, +line.length + 1 || 9e9))) { | ||
firstSemiColon = line.indexOf(';'); | ||
lintProblems.push({ | ||
type: 'transpile', | ||
reporter: 'aether', | ||
level: 'warning', | ||
message: "Don't put a ';' after an if statement.", | ||
range: [ | ||
{ | ||
ofs: offset + firstSemiColon, | ||
row: row, | ||
col: firstSemiColon | ||
}, { | ||
ofs: offset + firstSemiColon + 1, | ||
row: row, | ||
col: firstSemiColon + 1 | ||
} | ||
] | ||
}); | ||
break; | ||
} | ||
} | ||
} | ||
offset += line.length + 1; | ||
} | ||
} | ||
return lintProblems; | ||
@@ -179,0 +227,0 @@ }; |
@@ -136,3 +136,3 @@ (function() { | ||
getTranspileHint = function(msg, context, languageID, code, range, simpleLoops) { | ||
var c, codeSnippet, hint, hintCreator, lineStart, lineStartLow, nonAlphNumMatch, parens, prevIndex, quoteCharacter, _i, _len, _ref; | ||
var c, codeSnippet, hint, hintCreator, index, lineStart, lineStartLow, nonAlphNumMatch, parens, prevIndex, quoteCharacter, _i, _len, _ref; | ||
if (simpleLoops == null) { | ||
@@ -152,3 +152,14 @@ simpleLoops = false; | ||
} else if (msg === "Unexpected indent") { | ||
hint = "Code needs to line up."; | ||
if (range != null) { | ||
index = range[0].ofs; | ||
while (index > 0 && /\s/.test(code[index])) { | ||
index--; | ||
} | ||
if (index >= 3 && /else/.test(code.substring(index - 3, index + 1))) { | ||
hint = "You are missing a ':' after 'else'. Try `else:`"; | ||
} | ||
} | ||
if (hint == null) { | ||
hint = "Code needs to line up."; | ||
} | ||
} else if (msg.indexOf("Unexpected token") >= 0 && (context != null)) { | ||
@@ -192,3 +203,3 @@ codeSnippet = code.substring(range[0].ofs, range[1].ofs); | ||
} | ||
if ((hint == null) && lineStart.indexOf('if ') === 0) { | ||
if ((hint == null) && /^\s*if /.test(lineStart)) { | ||
if (codeSnippet === ':') { | ||
@@ -353,3 +364,3 @@ hint = "Your if statement is missing a test clause. Try `if True:`"; | ||
hint = this.getExactMatch(target, this.context.commonThisMethods, function(match) { | ||
return "You do not have the " + match + " skill."; | ||
return "You do not have an item equipped with the " + match + " skill."; | ||
}); | ||
@@ -359,3 +370,3 @@ } | ||
hint = this.getNoCaseMatch(target, this.context.commonThisMethods, function(match) { | ||
return "Did you mean " + match + "? You do not have that skill."; | ||
return "Did you mean " + match + "? You do not have an item equipped with that skill."; | ||
}); | ||
@@ -368,3 +379,3 @@ } | ||
msgFormatFn: function(match) { | ||
return "Did you mean " + match + "? You do not have that skill."; | ||
return "Did you mean " + match + "? You do not have an item equipped with that skill."; | ||
} | ||
@@ -440,3 +451,3 @@ } | ||
hint = this.getExactMatch(target, this.context.commonThisMethods, function(match) { | ||
return "You do not have the " + match + " skill."; | ||
return "You do not have an item equipped with the " + match + " skill."; | ||
}); | ||
@@ -446,3 +457,3 @@ } | ||
hint = this.getNoCaseMatch(target, this.context.commonThisMethods, function(match) { | ||
return "Did you mean " + match + "? You do not have that skill."; | ||
return "Did you mean " + match + "? You do not have an item equipped with that skill."; | ||
}); | ||
@@ -455,3 +466,3 @@ } | ||
msgFormatFn: function(match) { | ||
return "Did you mean " + match + "? You do not have that skill."; | ||
return "Did you mean " + match + "? You do not have an item equipped with that skill."; | ||
} | ||
@@ -458,0 +469,0 @@ } |
@@ -211,3 +211,3 @@ (function() { | ||
buildScope = function(scope, fn) { | ||
var child, childScope, key, _ref3, _ref4, _ref5, _ref6, _results; | ||
var child, childScope, key, _ref3, _ref4, _ref5, _ref6, _ref7, _results; | ||
buildVarMap(scope.varMap, fn); | ||
@@ -220,7 +220,10 @@ buildCallMap(scope.calls, fn); | ||
child = _ref4[key]; | ||
if (((_ref5 = child.body) != null ? _ref5.body : void 0) != null) { | ||
buildScope(scope, child); | ||
} | ||
if (key === 'parent' || key === 'leadingComments' || key === 'originalNode') { | ||
continue; | ||
} | ||
if ((child != null ? child.type : void 0) === S.ExpressionStatement && ((_ref5 = child.expression) != null ? _ref5.type : void 0) === S.AssignmentExpression) { | ||
if (((_ref6 = child.expression.right) != null ? _ref6.type : void 0) === S.FunctionExpression) { | ||
if ((child != null ? child.type : void 0) === S.ExpressionStatement && ((_ref6 = child.expression) != null ? _ref6.type : void 0) === S.AssignmentExpression) { | ||
if (((_ref7 = child.expression.right) != null ? _ref7.type : void 0) === S.FunctionExpression) { | ||
childScope = { | ||
@@ -227,0 +230,0 @@ children: [], |
{ | ||
"name": "aether", | ||
"version": "0.3.5", | ||
"version": "0.3.6", | ||
"description": "Analyzes, instruments, and transpiles JS to help beginners.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
208267
3871