sindresorhus/eslint-plugin-unicorn

More powerful `new-for-builtins`

Closed

#1,835 opened on May 27, 2022

 (5 comments) (2 reactions) (0 assignees)JavaScript (468 forks)user submission
enhancementhelp wanted

Repository metrics

Stars
 (5,022 stars)
PR merge metrics
 (Avg merge 1d 16h) (399 merged PRs in 30d)

Description

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)

Contributor guide