Disallow new with empty parens
See original GitHub issueThe rule can be implemented as one of the following:
- an option in new-parens rule
- an option in no-extra-parens rule
- a separate rule
When does this rule warn? Please describe and show example code:
var p = new Person(); // error
var p = new Person; // correct
var name = new Person().getName(); // optionally correct
Is this rule preventing an error or is it stylistic?
Stylistic
Why is this rule a candidate for inclusion instead of creating a custom rule?
It is generic
Are you willing to create the rule yourself?
Yes
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:11 (7 by maintainers)
Top Results From Across the Web
Can we omit parentheses when creating an object using the ...
As a special case, for the new operator only, JavaScript simplifies the grammar by allowing the parenthesis to be omitted if there are...
Read more >space-in-parens - ESLint - Pluggable JavaScript Linter
A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease.
Read more >Remove parentheses for empty year field biblatex ieee style
By using biblatex ieee style, I found that the reference will display empty brackets even though the field "year" ...
Read more >What is the significance of empty parentheses? - Codecademy
VariableName+() is a function call and empty () mean that you don't use parameters ... Let's assume your function requires no parameter but...
Read more >Parentheses are redundant if attribute has no arguments
If an attribute's constructor has no parameters, C# allows you to specify it without parentheses when you call it. ReSharper suggests removing ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@platinumazure good catch, that’s quite the wrench. Let’s see… Based on the cases demonstrated below, it looks like we’ll need either a tri-state or an option on the “never”. I agree with @epoberezkin that immediate property access is pretty ugly, so maybe there’s a way to support that too.
So what if we started off with “always” (1-4 valid) and “never” (5-8 valid). Then, later, if someone requests an option that makes 3-6 valid, we could add a third state, making it “always”/“never”/“chained” or something like that.
What about adding an “always” (default) / “never” mode to
new-parens
?