Skip to content

fix: ignore various unsafe args in prefer-timer-args - #174

Merged
43081j merged 1 commit into
mainfrom
jg/drop-writes
Oct 17, 2026
Merged

43081j merged 1 commit into
mainfrom
jg/drop-writes

Conversation

@43081j

@43081j 43081j commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

The following are unsafe as args to the arrow function form we detect:

// Reassigned vars
let a = 1; setTimeout(() => fn(a), 100); a = 2;

// Spread
setTimeout(() => fn(...args), 100);

// Variable functions
setTimeout(() => getFn()(), 100);
setTimeout(() => (a || b)(), 100);

In all these cases, the inner referenced identifiers may change before
the timer fires, so they are unsafe to extract.

Fixes #169

The following are unsafe as args to the arrow function form we detect:

```ts
// Reassigned vars
let a = 1; setTimeout(() => fn(a), 100); a = 2;

// Spread
setTimeout(() => fn(...args), 100);

// Variable functions
setTimeout(() => getFn()(), 100);
setTimeout(() => (a || b)(), 100);
```

In all these cases, the inner referenced identifiers may change before
the timer fires, so they are unsafe to extract.
@43081j
43081j merged commit bda103b into main Oct 17, 2026
3 checks passed
@43081j
43081j deleted the jg/drop-writes branch October 17, 2026 13:57
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.

prefer-timer-args: arguments are evaluated when the timer is set, not when it fires

1 participant