eslint-plugin-unicorn icon indicating copy to clipboard operation
eslint-plugin-unicorn copied to clipboard

More powerful `new-for-builtins`

Open fisker opened this issue 2 years ago • 5 comments

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 neither call nor new
  • Objects from global objects like Intl.DateTimeFormat/Temporal.Now... should also be checked
  • ~Only fix cases new and call result the same Function('')/new Function(''), Error('')/new Error(''), use suggestion for other cases like new Symbol()(runtime error)~

fisker avatar May 27 '22 07:05 fisker

What’s the reason to disallow new Promise?

dimaMachina avatar May 27 '22 08:05 dimaMachina

Mistake, updated.

fisker avatar May 27 '22 09:05 fisker

use suggestion for other cases like new Symbol()(runtime error)

Why cannot new Symbol() be auto-fixed?

sindresorhus avatar May 27 '22 09:05 sindresorhus

Why cannot new Symbol() be auto-fixed?

I guess I was overthinking.

fisker avatar May 27 '22 09:05 fisker

Accepted

sindresorhus avatar Jun 05 '22 09:06 sindresorhus