Skip to content

Case-insensitive globals changed from eslint-plugin-compat 6.2.0 to 7.0.0 #684

@joshkel

Description

@joshkel

Case sensitivity has changed between eslint-plugin-compat 6.2.0 and 7.0.0 in ways that can result in false positives.

6.2.0 reported no issues for the following:

import * as serviceWorker from './serviceWorker.ts';
serviceWorker.register(false);

7.0.0 gives the following error:

ServiceWorker is not supported in op_mini all, KaiOS 2.5, android 145

This isn't a reference to the ServiceWorker global - it's my own serviceWorker variable. Case sensitivity matters; eslint-plugin-compat shouldn't confuse the two. I believe that the fix in #681 is far too aggressive: the browser crypto global variable is an instance of the Crypto class, but there are plenty of other DOM API classes that do not follow this pattern (like ServiceWorker).

As another example:

   if (!navigator.permissions) {
      return;
    }
    // eslint-disable-next-line compat/compat
    navigator.permissions
      .query({ name: 'local-network-access' })
      .then((permissionStatus) => {
        permissionStatus.addEventListener('change', handleChange);
      })

I expect that I may have to suppress eslint-plugin-compat's warning when accessing navigator.permissions. However, starting with eslint-plugin-compat 7.0.0, I also have to suppress warnings about using my local permissionStatus variable, just because it happens to have the same name as a PermissionStatus interface that isn't globally recognized.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions