-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
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
no-new-object
to allow argument
#11810
Comments
This should definitely be optional. 😄 |
Out of curiosity, why do you want to use the wrapper objects? |
I've changed it to be optional and off-by-default (and switching the commit message from "Breaking" to "New"). My own need is merely for typeson-registry's ability to serialize/deserialize But I think some may wish to use this for polyfilling or extending the prototype. Interestingly, BigInt.prototype.plusOne = function () {
return this + 1n;
};
Object(1n).plusOne(); |
Because JS runtime does boxing automatically, so you don't need to wrap it by |
Btw, the reason I originally suggested the behavior as the default is because the only rationale given in the docs for avoiding However, I understand people don't always want to allow such more obscure uses. |
Ah, ok, I see, thanks, @mysticatea . I've amended the docs to avoid mentioning that. But it is still possible to do such conversions. I've also seen |
Unfortunately, it looks like there wasn't enough interest from the team Thanks for contributing to ESLint and we appreciate your understanding. |
What 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:
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 requiringnew
in such cases, as perunicorn/new-for-builtins
).If it is thought that people will like to make this optional, I can modify to something like
allowWithArguments
.The text was updated successfully, but these errors were encountered: