# no-mismatched-map-key πŸ“ Disallow checking a Map key before accessing a different key. πŸ’ΌπŸš« This rule is enabled in the βœ… `recommended` [config](https://github.com/sindresorhus/eslint-plugin-unicorn#recommended-config). This rule is _disabled_ in the β˜‘οΈ `unopinionated` [config](https://github.com/sindresorhus/eslint-plugin-unicorn#recommended-config). When you check a key with `Map#has()`, accesses to the same map in the guarded branch should use the same key. A different key is usually a copy-paste mistake. This rule intentionally only reports simple, obvious cases. Branches that reassign the checked map receiver are ignored. ## Examples ```js // ❌ const value = map.has(key) ? map.get(anotherKey) : fallback; // βœ… const value = map.has(key) ? map.get(key) : fallback; ``` ```js // ❌ if (!map.has(key)) { map.set(anotherKey, value); } // βœ… if (!map.has(key)) { map.set(key, value); } ```