Skip to content

TypeScript · performance

no-offset-pagination

eslint:no-offset-pagination

Disallow OFFSET pagination in embedded SQL; it is O(N) per page and drops or repeats rows under concurrent writes. Use a keyset cursor.

Default
error
Fix
none
Languages
typescript

Why

Offset pagination scans skipped rows and shifts page boundaries under concurrent writes.

Fix

Page with a stable ordered key and a cursor predicate.

Before / after

Executed by this rule’s unit tests.

Before

Do not page by offset

src/runs.ts · focus
db.query(`SELECT id FROM runs ORDER BY id LIMIT ? OFFSET ?`);

After

Page from a stable cursor

src/runs.ts · focus
db.prepare(`SELECT id FROM runs WHERE id > ? ORDER BY id LIMIT ?`).all();

Limits

  • Only embedded SQL is inspected; test files and non-pagination OFFSET syntax are excluded.

Message IDs

noOffsetPagination