help wantednew rule
Repository metrics
- Stars
- (5,022 stars)
- PR merge metrics
- (Avg merge 1d 16h) (399 merged PRs in 30d)
Description
If an object is created from pairs, and only used to check existence and READ properties. Should prefer use new Map() instead of Object.fromEntries(), kind of similar to prefer-set-has.
Fail
const object = Object.fromEntries(/*...*/);
if (object.foo) {
console.log(object.foo)
}
Pass
const object = new Map(/*...*/);
if (object.has('foo')) {
console.log(object.get('foo'))
}
// Object literal should be ignored
const object = {
// ...
};
if (object.foo) {
console.log(object.foo)
}