chore(lint): resolve oxlint warnings#19893
Conversation
- Turn off `no-base-to-string`, as we rely on casting things to strings in many places after verifying that they are simple not-falsey. It could be worthwhile to impose better type safety on all these things at some point, but that is unlikely to be worth doing in the near term. - Remove several unused variables. We could consider disabling this rule in tests specifically, since that is where it's most common to leave scaffolding and debugging values behind. - Cast as types in a few cases to make our intention clear, where the values were actually being used safely, but not explicitly. - Disable `require-array-sort-compare` in one case where we benefit with a smaller code footprint by using the implicit numeric comparison on `Array.sort()`.
Semver Impact of This PR🟢 Patch (bug fixes) 📋 Changelog PreviewThis is how your changes will appear in the changelog. New Features ✨Deps
Bug Fixes 🐛
Internal Changes 🔧
🤖 This preview updates automatically when you update the PR. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix prepared a fix for the issue found in the latest run.
- ✅ Fixed: Lint suppression based on incorrect
Array.sort()assumption- Replaced bare
sort()withsort((a, b) => a - b)ingetEarliestTimestampand removed the lint suppression so ordering is explicitly numeric.
- Replaced bare
Or push these changes by commenting:
@cursor push 85fb3438e1
Preview (85fb3438e1)
diff --git a/packages/replay-internal/src/eventBuffer/EventBufferArray.ts b/packages/replay-internal/src/eventBuffer/EventBufferArray.ts
--- a/packages/replay-internal/src/eventBuffer/EventBufferArray.ts
+++ b/packages/replay-internal/src/eventBuffer/EventBufferArray.ts
@@ -73,8 +73,7 @@
/** @inheritdoc */
public getEarliestTimestamp(): number | null {
- //oxlint-disable-next-line require-array-sort-compare
- const timestamp = this.events.map(event => event.timestamp).sort()[0];
+ const timestamp = this.events.map(event => event.timestamp).sort((a, b) => a - b)[0];
if (!timestamp) {
return null;This Bugbot Autofix run was free. To enable autofix for future PRs, go to the Cursor dashboard.
size-limit report 📦
|
node-overhead report 🧳Note: This is a synthetic benchmark with a minimal express app and does not necessarily reflect the real-world performance impact in an application.
|
This changes getEarliestTimestamp() to walk the list a single time, instead of performing a full sort, as a sorted list is not needed, just the smallest value.
04129d0 to
7a3168e
Compare


no-base-to-string, as we rely on casting things to strings in many places after verifying that they are simple not-falsey. It could be worthwhile to impose better type safety on all these things at some point, but that is unlikely to be worth doing in the near term.require-array-sort-comparein one case where we benefit with a smaller code footprint by using the implicit numeric comparison onArray.sort().Closes #19894 (added automatically)