help wantednew rule
Metriche repository
- Star
- (5022 stelle)
- Metriche merge PR
- (Merge medio 4h 30m) (26 PR mergiate in 30 g)
Descrizione
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)
}