Skip to content
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

False positives reported violation when mdn-browser-compat-data uses ranged version #446

Open
tbroyer opened this issue Jan 7, 2021 · 2 comments

Comments

@tbroyer
Copy link
Contributor

tbroyer commented Jan 7, 2021

I recently updated all my dependencies after a few months, and now have a report:

  62:34  error  location.hostname() is not supported in Opera 71  compat/compat

Looking around in related projects, I found that mdn-browser-compat-data have recently updated their data for location.hostname from true to a ranged version, specifically "version_added": "≤12.1", and it looks like eslint-plugin-compat doesn't support that format (parsing strings as a semver, which itself doesn't deal with the character).

@tbroyer
Copy link
Contributor Author

tbroyer commented Jan 7, 2021

Oh, it looks like the issue rather is that ast-metadata-inferer's compat.json actually contains "opera":{"version_added":false}, and this is because version 0.4.0 is built from mdn-browser-compat-data 1.0.20 which contained broken/erroneous data (fixed by mdn/browser-compat-data#6286, released in 1.0.26).

Ideally, both projects (ast-metadata-inferer and eslint-plugin-compat) should upgrade to @mdb/browser-compat-data which is now at version 3.0.1.

Fwiw, adding

  it("should support ranged versions", () => {
    const node = { protoChainId: "Accelerometer" };
    const config = determineTargetsFromConfig(".", "edge 18, edge 87");
    const targets = parseBrowsersListVersion(config);
    const result = getUnsupportedTargets(node, targets);
    expect(result).toEqual(["Edge 18"]);
  });

to test/mdn-provider.spec.ts passes, so it looks like ranged versions are actually correctly supported.

On the other hand, as reported initially:

  it("should support ranged versions", () => {
    const node = { protoChainId: "location.hostname" };
    const config = determineTargetsFromConfig(".", "opera 71");
    const targets = parseBrowsersListVersion(config);
    const result = getUnsupportedTargets(node, targets);
    expect(result).toEqual([]);
  });

fails:

$ yarn spec
yarn run v1.22.10
$ jest --testPathIgnorePatterns test/e2e-repo.spec.ts /benchmarks-tmp
 PASS  test/helpers.spec.ts
 PASS  test/caniuse-provider.spec.ts
 FAIL  test/mdn-provider.spec.ts
  ● MdnProvider › should support ranged versions

    expect(received).toEqual(expected) // deep equality

    - Expected  - 1
    + Received  + 3

    - Array []
    + Array [
    +   "Opera 71",
    + ]

      18 |     const targets = parseBrowsersListVersion(config);
      19 |     const result = getUnsupportedTargets(node, targets);
    > 20 |     expect(result).toEqual([]);
         |                    ^
      21 |   });
      22 | });
      23 | 

      at Object.<anonymous> (test/mdn-provider.spec.ts:20:20)
      at processTicksAndRejections (node:internal/process/task_queues:93:5)

 PASS  test/e2e.spec.ts

Test Suites: 1 failed, 3 passed, 4 total
Tests:       1 failed, 78 passed, 79 total
Snapshots:   8 passed, 8 total
Time:        4.231 s
Ran all test suites.

@wasd171
Copy link

wasd171 commented Dec 29, 2022

Having a similar issue with 142:24 error document.body() is not supported in Firefox 55 compat/compat
"eslint-plugin-compat": "~4.0.2"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants