Feature: Implement lint rule to eliminate accidental nested updates
- Dominant language
- TypeScript
- Stars
- 23.9k
- Forks
- 2.2k
- Avg merge
- 1d 14h
- Merged PRs (30d)
- 55
Description
## Description
Nested updates are never a good idea, so if we find a `$function` (or a `registerCommand`) that has an embedded `editor.update` we should rewrite it to remove the `editor.update`. As a companion to this we could add a `$defer` or something like that which could be used to provide explicit nested update semantics but I doubt we'll actually find any use case for it.
## Impact
Bugs will be avoided, code will be easier to test when the effects of updates happen in a sensible order. Nobody really wants to reason about code that looks like this:
```
editor.dispatchCommand(COMMAND_A, undefined);
editor.update(() => $b());
editor.dispatchCommand(COMMAND_C, undefined);
```
that will either execute in A, B, C or A, C, B 🙃 order depending on the context of whether this is called inside of an `editor.update` (or command listener) or not.
RE #7039 #7037 for recent examples
Contributor guide
Assessment
This issue has not been assessed yet.