You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
/**
|
|
|
|
* @fileoverview Rule to check that spaced function application
|
|
|
|
* @author Matt DuVall <http://www.mattduvall.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
// Rule Definition
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
module.exports = function(context) {
|
|
|
|
|
|
|
|
function detectOpenSpaces(node) {
|
|
|
|
var lastCalleeToken = context.getLastToken(node.callee);
|
|
|
|
var tokens = context.getTokens(node);
|
|
|
|
var i = tokens.indexOf(lastCalleeToken), l = tokens.length;
|
|
|
|
while (i < l && tokens[i].value !== "(") {
|
|
|
|
++i;
|
|
|
|
}
|
|
|
|
if (i >= l) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// look for a space between the callee and the open paren
|
|
|
|
if (tokens[i - 1].range[1] !== tokens[i].range[0]) {
|
|
|
|
context.report(node, "Unexpected space between function name and paren.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return {
|
|
|
|
"CallExpression": detectOpenSpaces,
|
|
|
|
"NewExpression": detectOpenSpaces
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
module.exports.schema = [];
|