sindresorhus/eslint-plugin-unicorn

Rule proposal: `prefer-map-has`

Chiusa

#1329 aperta il 3 giu 2021

 (8 commenti) (5 reazioni) (0 assegnatari)JavaScript (468 fork)user submission
help wantednew ruletypes

Metriche repository

Star
 (5022 stelle)
Metriche merge PR
 (Merge medio 4h 30m) (26 PR mergiate in 30 g)

Descrizione

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.

Guida contributor