]>
git.proxmox.com Git - pve-eslint.git/blob - eslint/lib/rules/no-spaced-func.js
961bc681f7eac50bfe816d7d9295982f74a26555
2 * @fileoverview Rule to check that spaced function application
3 * @author Matt DuVall <http://www.mattduvall.com>
4 * @deprecated in ESLint v3.3.0
9 //------------------------------------------------------------------------------
11 //------------------------------------------------------------------------------
18 description
: "disallow spacing between function identifiers and their applications (deprecated)",
19 category
: "Stylistic Issues",
21 url
: "https://eslint.org/docs/rules/no-spaced-func"
26 replacedBy
: ["func-call-spacing"],
28 fixable
: "whitespace",
32 noSpacedFunction
: "Unexpected space between function name and paren."
38 const sourceCode
= context
.getSourceCode();
41 * Check if open space is present in a function name
42 * @param {ASTNode} node node to evaluate
46 function detectOpenSpaces(node
) {
47 const lastCalleeToken
= sourceCode
.getLastToken(node
.callee
);
48 let prevToken
= lastCalleeToken
,
49 parenToken
= sourceCode
.getTokenAfter(lastCalleeToken
);
51 // advances to an open parenthesis.
54 parenToken
.range
[1] < node
.range
[1] &&
55 parenToken
.value
!== "("
57 prevToken
= parenToken
;
58 parenToken
= sourceCode
.getTokenAfter(parenToken
);
61 // look for a space between the callee and the open paren
63 parenToken
.range
[1] < node
.range
[1] &&
64 sourceCode
.isSpaceBetweenTokens(prevToken
, parenToken
)
68 loc
: lastCalleeToken
.loc
.start
,
69 messageId
: "noSpacedFunction",
71 return fixer
.removeRange([prevToken
.range
[1], parenToken
.range
[0]]);
78 CallExpression
: detectOpenSpaces
,
79 NewExpression
: detectOpenSpaces