-
-
Notifications
You must be signed in to change notification settings - Fork 106
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
support early returns and typeof checks for feature detection #596
Draft
bschlenk
wants to merge
20
commits into
amilajack:main
Choose a base branch
from
bschlenk:bschlenk/early-return
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bschlenk
force-pushed
the
bschlenk/early-return
branch
from
September 25, 2023 02:12
f608c8f
to
71a7c36
Compare
bschlenk
force-pushed
the
bschlenk/early-return
branch
from
October 13, 2023 18:42
71a7c36
to
ce1c17f
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hey Amila, thanks for building this plugin!
Sorry for the large PR, I'm hoping this will spark some discussion mainly, the code here is still WIP. But I wanted to get it in front of you before I get too far along.
As a lot of the issues point out,
if
statements prevent this plugin from detecting browser compat issues, and I wanted to take a shot at fixing it. But I wound up taking a few steps more and fixed a few other things.Fundamentally this sort of changes how this plugin is implemented. But I think it makes sense as far as what this plugin is meant to catch. When I think about these apis, I don't really care whether they're function calls,
new
statements, or member expressions. The error is simply that the object/method doesn't exist in certain browsers, and that's what we want to catch.With that in mind, this PR changes the approach to only lint on
Identifier
nodes. And it focuses on what types of operations would cause runtime errors. So any code that is testing if a feature exists is now okay:But if you do something that would result in a
ReferenceError
, we'll report it:I did a bit of other cleanup too, if that's desirable:
I'm happy to make whatever changes you'd like! I very much want to use this plugin, and these issues were the main blockers for me. I also plan on adding linting for unsupported regex features, and probably going through the list of other issues as well.
fixes:
typeof
in feature detection #520