`no-new-object` to allow argument
See original GitHub issueWhat rule do you want to change?
no-new-object
Does this change cause the rule to produce more or fewer warnings?
Fewer warnings.
How will the change be implemented? (New option, new default behavior, etc.)?
New default behavior.
Please provide some example code that this change will affect:
new Object(BigInt('1n'))
What does the rule currently do for this code?
Reports an error.
What will the rule do after it’s changed?
Not report anything.
Are you willing to submit a pull request to implement this change?
Yes.
As per the above example, there are uses for wrapping some items within a new Object()
(or within the equivalent, Object()
, but some prefer the style of requiring new
in such cases, as per unicorn/new-for-builtins
).
If it is thought that people will like to make this optional, I can modify to something like allowWithArguments
.
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (6 by maintainers)
Top GitHub Comments
Btw, the reason I originally suggested the behavior as the default is because the only rationale given in the docs for avoiding
new Object
is that it is equivalent to the object literal, but in this case it isn’t.However, I understand people don’t always want to allow such more obscure uses.
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.