Skip to content

[Due for payment 2025-10-30] [$250] Create no-object-keys-includes lint rule #67427

@roryabraham

Description

@roryabraham

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:

  1. Copy the object keys into an array - O(n)
  2. 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 OwnerCurrent Issue Owner: @VictoriaExpensify

Metadata

Metadata

Labels

Awaiting PaymentAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributor

Type

No type
No fields configured for issues without a type.

Projects

Status
Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions