Skip to content

Commit

Permalink
Adds test and fix for issue #82
Browse files Browse the repository at this point in the history
  • Loading branch information
mamacdon committed Jul 18, 2013
1 parent 9637601 commit d816b8f
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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 d816b8f

Please sign in to comment.