Skip to content

Add a rule to prevent simultaneously calling lodash mapKeys() and mapValues() #183

@frantic1048

Description

@frantic1048

Example:

import { chain, mapKeys, mapValues } from 'lodash';

chain(input).mapKeys(...).mapValues(...).value();

mapValues(mapKeys(input, ...), ...);

The usage is not intuitive, and it is preferable to use Object.fromEntries() in this scenario. The similar case is .keyBy(...).mapValues(...)

const input = [
  { k: 'key1', v: 'value1' },
  { k: 'key2', v: 'value2' },
];

// this `mapKeys().mapValues()` call
chain(input).mapKeys('k').mapValues('v').value();

// equals
Object.fromEntries(input.map((item) => [item.k, item.v]));

// equals
{
  key1: 'value1',
  key2: 'value2',
}

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions