typescript-eslint icon indicating copy to clipboard operation
typescript-eslint copied to clipboard

feat(eslint-plugin): add `no-object-methods-on-collections` rule

Open stepankuzmin opened this issue 1 month ago • 4 comments

Adds a new ESLint rule no-object-methods-on-collections that prevents using Object methods on Map, Set, WeakMap, and WeakSet instances.

Based on https://github.com/typescript-eslint/typescript-eslint/pull/10104 and https://github.com/typescript-eslint/typescript-eslint/pull/9369

Examples

❌ Incorrect

const map = new Map();
Object.keys(map); // Returns empty array

✅ Correct

const map = new Map();
Array.from(map.keys()); // Correct way to get keys

stepankuzmin avatar Oct 24 '25 14:10 stepankuzmin

Thanks for the PR, @stepankuzmin!

typescript-eslint is a 100% community driven project, and we are incredibly grateful that you are contributing to that community.

The core maintainers work on this in their personal time, so please understand that it may not be possible for them to review your work immediately.

Thanks again!


🙏 Please, if you or your company is finding typescript-eslint valuable, help us sustain the project by sponsoring it transparently on https://opencollective.com/typescript-eslint.

typescript-eslint[bot] avatar Oct 24 '25 14:10 typescript-eslint[bot]

Deploy Preview for typescript-eslint ready!

Name Link
Latest commit bedf3dcb9920f3030556b2a0aa1f32855ac93d61
Latest deploy log https://app.netlify.com/projects/typescript-eslint/deploys/68fb9554fdc4a200084164a6
Deploy Preview https://deploy-preview-11718--typescript-eslint.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

Lighthouse
1 paths audited
Performance: 96
Accessibility: 97
Best Practices: 100
SEO: 92
PWA: 80
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify project configuration.

netlify[bot] avatar Oct 24 '25 14:10 netlify[bot]

🤖 Nx Cloud AI Fix Eligible

An automatically generated fix could have helped fix failing tasks for this run, but Self-healing CI is disabled for this workspace. Visit workspace settings to enable it and get automatic fixes in future runs.

To disable these notifications, a workspace admin can disable them in workspace settings.


View your CI Pipeline Execution ↗ for commit bedf3dcb9920f3030556b2a0aa1f32855ac93d61

Command Status Duration Result
nx test eslint-plugin --coverage=false ❌ Failed 5m 18s View ↗
nx run-many -t lint ❌ Failed 3m 14s View ↗
nx run integration-tests:test ❌ Failed 56s View ↗
nx test eslint-plugin ❌ Failed 5m 11s View ↗
nx run-many -t typecheck ✅ Succeeded 2m 3s View ↗
nx run types:build ✅ Succeeded 5s View ↗
nx test eslint-plugin-internal --coverage=false ✅ Succeeded 4s View ↗
nx test typescript-estree --coverage=false ✅ Succeeded 2s View ↗
Additional runs (28) ✅ Succeeded ... View ↗

☁️ Nx Cloud last updated this comment at 2025-10-24 15:12:30 UTC

nx-cloud[bot] avatar Oct 24 '25 14:10 nx-cloud[bot]

👋 @stepankuzmin are you waiting on us for anything with this PR? Is it ready for review?

JoshuaKGoldberg avatar Nov 24 '25 13:11 JoshuaKGoldberg