Skip to content

why inside If statement is exempt #545

Closed

Description

@JiaYifan

image
The question is, the code in If statement is exempt from browser compatibility check. It seems unreasonable.

Activity

  1. bschlenk commented on Sep 22, 2023

    @bschlenk

    I think it's meant to allow checking for the existence of a thing before using it, like

    if (window.fetch) {
      fetch()
    }

    But it's too broad because it also means it doesn't catch

    if (true) {
      fetch()
    }
  2. tujoworker commented on Jan 13, 2026

    @tujoworker
    Contributor

    I think this should be configurable / possible to disable.

    In my case, Object.hasOwn is flagged because it’s unsupported in Safari < 15.4. However, it only actually fails in one out of ~20 usages. All the other usages are guarded by conditional logic (e.g. runtime checks), so they are never reported.

    This makes the rule feel a bit too opinionated for some real-world cases, where developers should get a feedback by eslint-plugin-compat.

  3. tujoworker commented on Jan 13, 2026

    @tujoworker
    Contributor

    Here is a PR to allow detection inside if statements. Hope it will be reviews by the maintainers.

  4. github-actions commented on Jan 23, 2026

    @github-actions

    🎉 This issue has been resolved in version 6.1.0 🎉

    The release is available on:

    Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions