1 # require parentheses when invoking a constructor with no arguments (new-parens)
3 JavaScript allows the omission of parentheses when invoking a function via the `new` keyword and the constructor has no arguments. However, some coders believe that omitting the parentheses is inconsistent with the rest of the language and thus makes code less clear.
6 var person = new Person;
11 This rule can enforce or disallow parentheses when invoking a constructor with no arguments using the `new` keyword.
15 This rule takes one option.
17 - `"always"` enforces parenthesis after a new constructor with no arguments (default)
18 - `"never"` enforces no parenthesis after a new constructor with no arguments
22 Examples of **incorrect** code for this rule with the `"always"` option:
25 /*eslint new-parens: "error"*/
27 var person = new Person;
28 var person = new (Person);
31 Examples of **correct** code for this rule with the `"always"` option:
34 /*eslint new-parens: "error"*/
36 var person = new Person();
37 var person = new (Person)();
42 Examples of **incorrect** code for this rule with the `"never"` option:
45 /*eslint new-parens: ["error", "never"]*/
47 var person = new Person();
48 var person = new (Person)();
51 Examples of **correct** code for this rule with the `"never"` option:
54 /*eslint new-parens: ["error", "never"]*/
56 var person = new Person;
57 var person = (new Person);
58 var person = new Person("Name");