sindresorhus/eslint-plugin-unicorn

Rule proposal: `prefer-map-has`

已關閉

#1,329 建立於 2021年6月3日

 (8 則留言) (5 個反應) (0 位負責人)JavaScript (468 個分叉)user submission
help wantednew ruletypes

倉庫指標

星標
 (5,022 顆星)
PR 合併指標
 (平均合併 4小時 30分鐘) (30 天內合併 26 個 PR)

描述

When checking existence, should prefer Map#has() over Map#get().

Fail

if (map.get(foo));

Pass

if (map.has(foo));

I think better ship this with prefer-map together, so user can notice this problem when we fix object.foo to map.get(foo) in prefer-map.

貢獻者指南