Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an option for "new-parens" to require having no parenthesis on new #10034

Closed
pfgithub opened this issue Feb 28, 2018 · 3 comments
Closed
Labels
archived due to age This issue has been archived; please open a new issue for any further discussion auto closed The bot closed this issue enhancement This change enhances an existing feature of ESLint evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion rule Relates to ESLint's core rules

Comments

@pfgithub
Copy link
Contributor

pfgithub commented Feb 28, 2018

#10074 <!--
ESLint adheres to the JS Foundation Code of Conduct.

This template is for requesting a rule change. If you are here for another reason, please see below:

1. To report a bug: https://eslint.org/docs/developer-guide/contributing/reporting-bugs
2. To propose a new rule: https://eslint.org/docs/developer-guide/contributing/new-rules
3. To request a change that is not a bug fix, rule change, or new rule: https://eslint.org/docs/developer-guide/contributing/changes
4. If you have any questions, please stop by our chatroom: https://gitter.im/eslint/eslint

Note that leaving sections blank will make it difficult for us to troubleshoot and we may have to close the issue.

-->

What rule do you want to change?

new-parens

Does this change cause the rule to produce more or fewer warnings?

No

How will the change be implemented? (New option, new default behavior, etc.)?

Adds an option for always requiring or always not allowing new parens

Please provide some example code that this change will affect:

"new-parens": ["error", "never"]
Examples of incorrect code for this rule:

var person = new Person();
var person = new (Person)();
var thing = new Person().Thing

Examples of correct code for this rule:

var person = new Person;
var person = new (Person);
var person = new Person("Name");
var thing = (new Person).Thing

"new-parens": ["error", "always"]
Examples of incorrect code for this rule:

var person = new Person;
var person = new (Person);
var thing = (new Person).Thing;

Examples of correct code for this rule:

var person = new Person();
var person = new (Person)();
var person = new Person("Name");
var thing = new Person().Thing;

What does the rule currently do for this code?

Has no option of setting to require no parenthesis on new with no arguments

What will the rule do after it's changed?

Same thing as it currently does, but also includes an option to require no parenthesis on new constructors with no arguments

@eslint-deprecated eslint-deprecated bot added the triage An ESLint team member will look at this issue soon label Feb 28, 2018
@not-an-aardvark
Copy link
Member

Thanks for the proposal. How would the rule handle cases like this when using the never option?

new Foo().Bar

@not-an-aardvark not-an-aardvark added enhancement This change enhances an existing feature of ESLint rule Relates to ESLint's core rules evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion and removed triage An ESLint team member will look at this issue soon labels Feb 28, 2018
@pfgithub
Copy link
Contributor Author

pfgithub commented Mar 3, 2018

Thanks for the proposal. How would the rule handle cases like this when using the never option?

new Foo().Bar

This would be a warning/error. If --fix is applied it would surround it in parenthesis like (new Foo).Bar

@eslint-deprecated eslint-deprecated bot added the auto closed The bot closed this issue label Dec 11, 2018
@eslint-deprecated
Copy link

Unfortunately, it looks like there wasn't enough interest from the team
or community to implement this change. While we wish we'd be able to
accommodate everyone's requests, we do need to prioritize. We've found
that issues failing to reach accepted status after 21 days tend to
never be accepted, and as such, we close those issues.
This doesn't mean the idea isn't interesting or useful, just that it's
not something the team can commit to.

Thanks for contributing to ESLint and we appreciate your understanding.

pfgithub added a commit to pfgithub/eslint that referenced this issue Feb 12, 2019
kaicataldo pushed a commit that referenced this issue May 25, 2019
* Update: Add never option for new-parens (fixes #10034)

* Docs: Fix eslint comment in new-parens never example

* Chore: Add tests for new-parens explicit always and never with arguments

* Chore: Adjust wording and naming of new-parens unnecessary message
@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Jun 10, 2019
@eslint-deprecated eslint-deprecated bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Jun 10, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
archived due to age This issue has been archived; please open a new issue for any further discussion auto closed The bot closed this issue enhancement This change enhances an existing feature of ESLint evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion rule Relates to ESLint's core rules
Projects
None yet
Development

No branches or pull requests

2 participants