Skip to content

Commit

Permalink
Fix: Don't warn for member expression functions (fixes #2402)
Browse files Browse the repository at this point in the history
  • Loading branch information
nzakas committed May 8, 2015
1 parent 5beee9d commit c11c408
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/rules/no-wrap-func.js
Expand Up @@ -27,7 +27,7 @@ module.exports = function(context) {
return;
}

if (!/CallExpression|NewExpression/.test(node.parent.type)) {
if (!/CallExpression|NewExpression|MemberExpression/.test(node.parent.type)) {
previousToken = context.getTokenBefore(node);
nextToken = context.getTokenAfter(node);
if (previousToken.value === "(" && nextToken.value === ")") {
Expand Down
1 change: 1 addition & 0 deletions tests/lib/rules/no-wrap-func.js
Expand Up @@ -23,6 +23,7 @@ eslintTester.addRuleTest("lib/rules/no-wrap-func", {
"(function() {})()",
"var a = function() {}",
"new Object(function() {})",
"(function () {thing()}).bar()",
{
code: "opts.ease = opts.ease || (a => a * a * a)",
ecmaFeatures: { arrowFunctions: true }
Expand Down

4 comments on commit c11c408

@michaelficarra
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a[(function(){})] and f((function(){})) are mistakenly allowed here.

@nzakas
Copy link
Member Author

@nzakas nzakas commented on c11c408 May 9, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you file an issue for that?

@michaelficarra
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, but they won't be very detailed, as I've not run into the issue myself. I can just clearly see from the implementation that these would cause false negatives.

@nzakas
Copy link
Member Author

@nzakas nzakas commented on c11c408 May 9, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand, I just can't keep track of side conversations.

Please sign in to comment.