sindresorhus/eslint-plugin-unicorn

More powerful `new-for-builtins`

Chiusa

#1835 aperta il 27 mag 2022

 (5 commenti) (2 reazioni) (0 assegnatari)JavaScript (468 fork)user submission
enhancementhelp wanted

Metriche repository

Star
 (5022 stelle)
Metriche merge PR
 (Merge medio 1g 16h) (399 PR mergiate in 30 g)

Descrizione

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)

Guida contributor