blob: cd3e8f975d3c8f437dc477603b8325d5f4ce5a9a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
/**
* @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 = [];
|