eslint-plugin-unicorn
eslint-plugin-unicorn copied to clipboard
More powerful `new-for-builtins`
Currently, new-for-builtins
enforce builtins used either call
or new
.
My idea is to extend this rule to check all builtins.
- Objects like
JSON
/Math
/Reflect
/Temporal
should be neithercall
nornew
- Objects from global objects like
Intl.DateTimeFormat
/Temporal.Now
... should also be checked - ~Only fix cases
new
andcall
result the sameFunction('')
/new Function('')
,Error('')
/new Error('')
, use suggestion for other cases likenew Symbol()
(runtime error)~
What’s the reason to disallow new Promise
?
Mistake, updated.
use suggestion for other cases like new Symbol()(runtime error)
Why cannot new Symbol()
be auto-fixed?
Why cannot new Symbol() be auto-fixed?
I guess I was overthinking.
Accepted