Skip to content

Conversation

@addaleax
Copy link
Collaborator

@addaleax addaleax commented Dec 15, 2025

Record types in TS are typically used to indicate that an object may have arbitrary keys. This means that using {} or similar object literals to initialize them is a poor choice -- if user code can cause keys like hasOwnProperty or __proto__ to be used as keys on those objects, they will not behave as intended.

This has been the cause of many security issues in the JS ecosystem, so let's add a lint rule to limit impact of these issues and force ourselves to stick to best practices.

Example autofixer output: mongodb-js/compass#7652

Description

Open Questions

Checklist

… for `Record`s

`Record` types in TS are typically used to indicate that an object
may have arbitrary keys. This means that using `{}` or similar object
literals to initialize them is a poor choice -- if user code can
cause keys like `hasOwnProperty` or `__proto__` to be used as
keys on those objects, they will not behave as intended.

This has been the cause of many security issues in the JS
ecosystem, so let's add a lint rule to limit impact
of these issues and force ourselves to stick to best practices.
@addaleax addaleax merged commit e6f66d9 into main Dec 16, 2025
33 checks passed
@addaleax addaleax deleted the eslint-no-plain-object-records branch December 16, 2025 11:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants