Coming from https://expensify.slack.com/archives/C05LX9D6E07/p1753812175447629?thread_ts=1753810372.474349&cid=C05LX9D6E07
Problem
When we write code like this to check if a key exists in an object:
Object.keys(policyRates).includes(customUnitRateID)
We incur performance overhead in that we are doing an O(n) operation:
- Copy the object keys into an array - O(n)
- Iterate the array searching for a matching key - also O(n)
Solution
Write a lint rule to disallow that pattern, enforcing that instead we do an O(1) lookup in the object:
customUnitRateID in policyRates
or
!!policyRates[customUnitRateID]
Upwork Automation - Do Not Edit
- Upwork Job URL: https://www.upwork.com/jobs/~021968163942954970101
- Upwork Job ID: 1968163942954970101
- Last Price Increase: 2025-09-24
Issue Owner
Current Issue Owner: @VictoriaExpensify
Coming from https://expensify.slack.com/archives/C05LX9D6E07/p1753812175447629?thread_ts=1753810372.474349&cid=C05LX9D6E07
Problem
When we write code like this to check if a key exists in an object:
We incur performance overhead in that we are doing an O(n) operation:
Solution
Write a lint rule to disallow that pattern, enforcing that instead we do an O(1) lookup in the object:
or
Upwork Automation - Do Not Edit
Issue Owner
Current Issue Owner: @VictoriaExpensify