Created
April 16, 2014 13:55
-
-
Save pamelafox/10879482 to your computer and use it in GitHub Desktop.
BabyHint.js - checkFunctionDecl
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
checkFunctionDecl: function(line, lineNumber) { | |
var errors = []; | |
var functions = line.match(/function\s+\w+/g); | |
_.each(functions, function(fun) { | |
var name = fun.split(/\s+/g)[1]; | |
// I18N: Don't translate the '\" var %(name)s = function() {}; \"' part | |
var error = { | |
row: lineNumber, | |
column: line.indexOf(fun), | |
text: $._("If you want to define a function, you should use \"var %(name)s = function() {}; \" instead!", {name: name}), | |
breaksCode: true, | |
source: "funcdeclaration" | |
}; | |
errors.push(error); | |
}); | |
return errors; | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment