-
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
Avoid usage of unguarded getRangeAt and add eslint rule #16212
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.
Thanks for this proposal!
Each custom ESLint rule should have its own documentation:
https://github.com/WordPress/gutenberg/tree/master/packages/eslint-plugin/docs/rules
It should also be included in the "Rules" tab of the README.md
file:
https://github.com/WordPress/gutenberg/tree/master/packages/eslint-plugin#rules
It's a fairly targeted rule, which makes me wonder if it's the sort of thing where we could generalize the guarding. That said, it's a pretty specific issue with this one function affecting some browsers and not others. I guess we'd really only care to revise it if there were other range functions which are similarly problematic when unguarded.
Thanks @aduth, I updated the PR. |
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 great, thanks! 👍
Some last-minute thoughts / feedback:
I was also wondering about the developer experience for someone who encounters this warning. Will it be obvious what they need to do to resolve the issue, when the message is simply "Avoid unguarded getRangeAt" ? I wonder if we could expand the message and/or implement a fixer (depending on difficulty). It still looks good in its current form, and we could merge it as-is if you're okay with the proposed changes. |
Can we unblock this. It it seems readyish. Just need a refresh/rebase. |
Conflicts resolved, thanks! |
* Avoid usage of unguarded getRangeAt and add eslint rule * Address PR comments * ESLint Plugin: Add CHANGELOG entry for avoid-unguarded-get-range-at * ESLint Plugin: Rename avoid-unguarded-get-range-at to no-unguarded-get-range-at
* Avoid usage of unguarded getRangeAt and add eslint rule * Address PR comments * ESLint Plugin: Add CHANGELOG entry for avoid-unguarded-get-range-at * ESLint Plugin: Rename avoid-unguarded-get-range-at to no-unguarded-get-range-at
Description
Closes #15606.
This PR addresses #15606. I ran a grep through all
getRangeAt
calls and fixed all occurrences. It also adds a new eslint rule.Types of changes
The PR introduces a Bug fix (non-breaking change which fixes an issue), and also adds a rule
enforcement to avoid similar problems in the future