-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Edit Post: Select blocks only once multiple verified #12477
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good in my tests, as expected no behavior changes were noticed 👍
As referred, this would for sure be an excellent lint rule. Maybe it was already implemented by someone and is available.
The end 2 end tests fail seems totally unrelated and an intermittent problem, I restarted them.
I looked around a bit, and unfortunately couldn't find much. I started working on a rule, and found a few edge cases, mostly stylistic:
Here's my work-in-progress: It finds a lot of very interesting faults! Full report
|
Nice exploration 👍
For the destructuring case, I guess an error should be thrown if none of the variables destructured is used before the return if at least one is used I think it is fine.
Yes, I think only limiting to function calls makes sense. |
Related: #5031
This pull request seeks to optimize the multiple-use validation to avoid calling the
getBlocks
selector until after verifying that a non-multiple-supporting block is present in the post. This should help alleviate some performance bottleneck for a currently-underperforming selector (getBlocks
), particularly when the the condition will not apply for the vast majority of blocks.This is effectively a refactoring to reorganize code to only assign a variable value at a point where it is certain to be relevant for use by the remainder of the function. As an aside, it would be very interesting to try to develop a lint rule to verify that a variable is used before the next
return
statement.Testing instructions:
Repeat testing instructions from #5031
Add a
console.count
at the point thegetBlocks
function is called, and verify that it is not called while authoring paragraph content (unlike before).