Skip to content

fix(prefer-timer-args): check UpdateExpressions & TemplateLiterals - #158

Merged
43081j merged 1 commit into
mainfrom
jg/safer-timers
Sep 17, 2026
Merged

43081j merged 1 commit into
mainfrom
jg/safer-timers

Conversation

@43081j

@43081j 43081j commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

An UpdateExpression is a mutation so we can't safely inline it. For
example:

setTimeout(() => fn(i++), 10);
// not the same as
setTimeout(fn, 10, i++);

A TemplateLiteral may contain expressions which mutate, so we also now
check those:

setTimeout(() => `foo ${fn()} bar`, 10);

Fixes #157

An `UpdateExpression` is a mutation so we can't safely inline it. For
example:

```ts
setTimeout(() => fn(i++), 10);
// not the same as
setTimeout(fn, 10, i++);
```

A `TemplateLiteral` may contain expressions which mutate, so we also now
check those:

```ts
setTimeout(() => `foo ${fn()} bar`, 10);
```
@43081j
43081j merged commit 0613c3d into main Sep 17, 2026
3 checks passed
@43081j
43081j deleted the jg/safer-timers branch September 17, 2026 12: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.

[bug] "prefer-timer-args" conflicts with i++

1 participant