new-parens

在调用不带参数的构造函数时强制或禁止使用括号

一些该规则报告的问题可以通过 --fix 命令行选项 自动修复

JavaScript 允许在通过 new 关键字调用函数并且构造函数没有参数时省略括号。但是,一些编码人员认为省略括号与语言的其余部分不一致,从而使代码不太清晰。

var person = new Person;

规则详情

当使用 new 关键字调用不带参数的构造函数时,此规则可以强制或禁止使用括号。

选项

该规则采用一种选择。

    kEtQi+Z0dlnoc54hfXSBKjf/sKVVfoKbc+laoBAbwSiS9yIELPmjhqixH2S74SXIRrgVuPEXwQnFBnXTAMoyWkBTZyQRzKUPZ20PgYh4R5ZeeeXIvRqa7npyvqPvPm0Woi1eppQx6vjGmG6RlsAXMsbstJPnemkukUb5375NdBbTn7EpDLJ2rGLXirkY9PPOY3vYM3QE0Df1AeulGQt7lN16UnawswG1n1CoPgLJcsamp3ug4zUdNJu5OhBx1ulQYKq88auvM2A7DLa6FzUH2g==

always

zsV3VIEaArmSNnLhUR0dD6x/Kk6nBF44iom5U8wqwP07MGjlxRA+pniOGuvOEP3uWpUfhdeXuf7N+hlxO0jFR0Fy3Q4EZSz7pK5bVeg6Ofo=

/*eslint new-parens: "error"*/

var person = new Person;
var person = new (Person);

zsV3VIEaArmSNnLhUR0dD6x/Kk6nBF44iom5U8wqwP2dMdcKVz+0cEUOpaA9ItokHjXLPlpJRd9v8k7SMUK/VQi9KQK/jOiVf7cprC9gTac=

/*eslint new-parens: "error"*/

var person = new Person();
var person = new (Person)();

never

zsV3VIEaArmSNnLhUR0dDyWiLa4+lnJ9BybfNjsTc4Euj665hDadg+6/lGoim8myIdJaUFNpRbOsgjlMQNwfVpf7x83RfpCElAJMLpnI6eU=

/*eslint new-parens: ["error", "never"]*/

var person = new Person();
var person = new (Person)();

zsV3VIEaArmSNnLhUR0dDyWiLa4+lnJ9BybfNjsTc4Fwn5DCusqYjvpthp5XrkLDUZKvdJdPzio6g2WfLCWUiVsEyiK3fCjAPb+OyNIauzU=

/*eslint new-parens: ["error", "never"]*/

var person = new Person;
var person = (new Person);
var person = new Person("Name");