# no-object-methods-with-collections

Rule `unicorn/no-object-methods-with-collections`. Disallow `Object` methods with `Map` or `Set`.

- Source: unicorn
- Technologies: JavaScript
- Kind: correctness
- Needs type information: no
- Autofix: yes, in at least one linter
- Reach: 9.9M weekly downloads of presets that enable it
- Trend: +28.3% last quarter
- Rank: #1045 by reach, #1300 by growth

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| ESLint | `unicorn/no-object-methods-with-collections` | no | suggestion | package `eslint-plugin-unicorn` | [docs](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v80.0.0/docs/rules/no-object-methods-with-collections.md) |

## Code examples

### Incorrect: the rule reports this

```js
Object.keys(map);
```

```js
Object.values(map);
```

```js
Object.entries(set);
```

### Correct: the rule accepts this

```js
Array.from(map.keys());
```

```js
Array.from(map.values());
```

```js
Array.from(set.entries());
```

Examples from the ESLint documentation.

## Enable it

### ESLint: `eslint.config.js`

```js
import unicorn from "eslint-plugin-unicorn";

export default [
  {
    plugins: { unicorn },
    rules: {
      "unicorn/no-object-methods-with-collections": "error",
    },
  },
];
```

## Presets that enable it

| Preset | Linter | Package | Rules | Weekly downloads | Trend |
| --- | --- | --- | --- | --- | --- |
| [Unicorn recommended](https://lintradar.dev/presets/unicorn-recommended.md) | ESLint | `eslint-plugin-unicorn` | 340 | 9.5M | +30.3% |
| [XO](https://lintradar.dev/presets/xo.md) | ESLint | `eslint-config-xo` | 618 | 413K | −5.0% |

## Related rules

- [unicorn/no-non-function-verb-prefix](https://lintradar.dev/rules/unicorn/no-non-function-verb-prefix.md): Disallow non-function values with function-style verb prefixes.
- [unicorn/no-optional-chaining-on-undeclared-variable](https://lintradar.dev/rules/unicorn/no-optional-chaining-on-undeclared-variable.md): Disallow optional chaining on undeclared variables.
- [unicorn/no-loop-iterable-mutation](https://lintradar.dev/rules/unicorn/no-loop-iterable-mutation.md): Disallow mutating a loop iterable during iteration.
- [unicorn/no-selector-as-dom-name](https://lintradar.dev/rules/unicorn/no-selector-as-dom-name.md): Disallow selector syntax in DOM names.
- [unicorn/no-leading-empty-lines](https://lintradar.dev/rules/unicorn/no-leading-empty-lines.md): Disallow empty lines at the beginning of a file.
- [unicorn/no-top-level-side-effects](https://lintradar.dev/rules/unicorn/no-top-level-side-effects.md): Disallow top-level side effects in exported modules.

---

Web page: https://lintradar.dev/rules/unicorn/no-object-methods-with-collections. Data from npm and the linters' documentation, collected Dec 4, 2026. Site guide for agents: https://lintradar.dev/llms.txt
