Skip to content
This repository was archived by the owner on Mar 23, 2024. It is now read-only.

Commit dbd2879

Browse files
hzoomikesherov
authored andcommitted
requireSpacesInCallExpression: use tokenAssert
Closes gh-983
1 parent 565dc5b commit dbd2879

File tree

1 file changed

+8
-18
lines changed

1 file changed

+8
-18
lines changed

lib/rules/require-spaces-in-call-expression.js

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -44,24 +44,14 @@ module.exports.prototype = {
4444
var tokens = file.getTokens();
4545

4646
file.iterateNodesByType('CallExpression', function(node) {
47-
var nodeBeforeRoundBrace = node;
48-
if (node.callee) {
49-
nodeBeforeRoundBrace = node.callee;
50-
}
51-
52-
var roundBraceToken = file.getTokenByRangeStart(nodeBeforeRoundBrace.range[0]);
53-
do {
54-
roundBraceToken = file.findNextToken(roundBraceToken, 'Punctuator', '(');
55-
} while (roundBraceToken.range[0] < nodeBeforeRoundBrace.range[1]);
56-
57-
var functionEndToken = file.getPrevToken(roundBraceToken);
58-
59-
if (roundBraceToken.value === '(' && functionEndToken.range[1] === roundBraceToken.range[0]) {
60-
errors.add(
61-
'Missing space before opening round brace',
62-
roundBraceToken.loc.start
63-
);
64-
}
47+
var lastCalleeToken = file.getLastNodeToken(node.callee);
48+
var roundBraceToken = file.findNextToken(lastCalleeToken, 'Punctuator', '(');
49+
50+
errors.assert.whitespaceBetween({
51+
token: file.getPrevToken(roundBraceToken),
52+
nextToken: roundBraceToken,
53+
message: 'Missing space before opening round brace'
54+
});
6555
});
6656
}
6757
};

0 commit comments

Comments
 (0)