Skip to content

Instantly share code, notes, and snippets.

@pamelafox
Created April 16, 2014 13:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pamelafox/10879482 to your computer and use it in GitHub Desktop.
Save pamelafox/10879482 to your computer and use it in GitHub Desktop.
BabyHint.js - checkFunctionDecl
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