Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Implement lint rule to eliminate accidental nested updates #7040

Open
etrepum opened this issue Jan 11, 2025 · 0 comments
Open

Feature: Implement lint rule to eliminate accidental nested updates #7040

etrepum opened this issue Jan 11, 2025 · 0 comments
Labels
enhancement Improvement over existing feature lint @lexical/eslint-plugin or lint configuration

Comments

@etrepum
Copy link
Collaborator

etrepum commented Jan 11, 2025

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

@etrepum etrepum added enhancement Improvement over existing feature lint @lexical/eslint-plugin or lint configuration labels Jan 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improvement over existing feature lint @lexical/eslint-plugin or lint configuration
Projects
None yet
Development

No branches or pull requests

1 participant