Skip to content

Commit

Permalink
Merge pull request #83 from mamacdon/new-parens-func-fix
Browse files Browse the repository at this point in the history
Adds test and fixes #82
  • Loading branch information
nzakas committed Jul 20, 2013
2 parents 8d4bce1 + d816b8f commit 934d766
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/rules/new-parens.js
Expand Up @@ -16,7 +16,7 @@ module.exports = function(context) {
var prenticesTokens = tokens.filter(function(token) {
return token.value === "(" || token.value === ")";
});
if (prenticesTokens.length !== 2) {
if (prenticesTokens.length < 2) {
context.report(node, "Missing '()' invoking a constructor");
}
}
Expand Down
15 changes: 15 additions & 0 deletions tests/lib/rules/new-parens.js
Expand Up @@ -46,6 +46,21 @@ vows.describe(RULE_ID).addBatch({

topic: "var a = new Date();",

"should not report a violation": function(topic) {

var config = { rules: {} };
config.rules[RULE_ID] = 1;

var messages = eslint.verify(topic, config);

assert.equal(messages.length, 0);
}
},

"when evaluating 'var a = new Date(function() {})'": {

topic: "var a = new Date(function() {});",

"should not report a violation": function(topic) {

var config = { rules: {} };
Expand Down

0 comments on commit 934d766

Please sign in to comment.