2 * @fileoverview Rule to enforce consistent spacing after function names
3 * @author Roberto Vidal
4 * @copyright 2014 Roberto Vidal. All rights reserved.
8 //------------------------------------------------------------------------------
10 //------------------------------------------------------------------------------
12 module.exports = function(context) {
14 var requiresSpace = context.options[0] === "always";
17 * Reports if the give named function node has the correct spacing after its name
19 * @param {ASTNode} node The node to which the potential problem belongs.
22 function check(node) {
23 var tokens = context.getFirstTokens(node, 3),
24 hasSpace = tokens[1].range[1] < tokens[2].range[0];
26 if (hasSpace !== requiresSpace) {
27 context.report(node, "Function name \"{{name}}\" must {{not}}be followed by whitespace.", {
29 not: requiresSpace ? "" : "not "
35 "FunctionDeclaration": check,
36 "FunctionExpression": function (node) {