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

Linter for mdn_url #5201

Closed
bershanskiy opened this issue Nov 24, 2019 · 6 comments
Closed

Linter for mdn_url #5201

bershanskiy opened this issue Nov 24, 2019 · 6 comments
Labels
idle Issues and pull requests with no recent activity linter Issues or pull requests regarding the tests / linter of the JSON files.

Comments

@bershanskiy
Copy link
Contributor

Sometimes the __compat.mdn_url property is incorrect, e.g. as shown in #5195. After seeing that issue, I looked for more similar bugs and found a couple, so I propose we make an explicit linter check for mdn_url. Below is a draft checklist, please tell me if it sounds reasonable.

Checks

  1. Any top-level feature has a proper link, e.g. api.feature has a link https://developer.mozilla.org/docs/Web/API/feature
  2. Any sub-feature has a link that extends from the parent
    E.g. api.feature.attribute has a link https://developer.mozilla.org/docs/Web/API/feature/attribute and api.feature.feature_event has link https://developer.mozilla.org/docs/Web/API/feature/feature_event
@queengooborg queengooborg added the linter Issues or pull requests regarding the tests / linter of the JSON files. label Nov 25, 2019
@bershanskiy
Copy link
Contributor Author

bershanskiy commented Nov 30, 2019

As per @vinyldarkscratch's request, I started writing a linter for all MDN URLs in all folders and here are odd URLs I don't know what to do about:

  • javascript.builtins.Intl has reasonable URL:

     https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl
    

    but its children have URLs without Intl, e.g. javascript.builtins.Intl.Collator has

    https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Collator
    

    These URLs might be inconsistent with MDN practices.

  • CSS data

    • The data does not seem to know the difference between CSS selectors with : and :: (aka pseudo-classes and pseudo-elements) so linter can not enforce these constraints. I think it's OK.
  • API

    • javascript.builtins.Object has a bunch of non-standard lookupSetter and lookupGetter, etc. which document attributes which have underscores in them (the descriptions and URLs all have underscores). May be, it's better to add underscores to the names and remove descriptions?

@bershanskiy
Copy link
Contributor Author

bershanskiy commented Dec 4, 2019

@sideshowbarker I noticed you filed #5256 and #5257, which actually help with linter (since they fix some values that linter would fail on). If you are interested, here are some more similar issues (some of these might be false positives):

× api\MediaKeyStatusMap.json -- #5269
mdn_urls – 1 error:

Actual: "https://developer.mozilla.org/docs/Web/API/MediaKeyStatusMap/[@@iterator]"
Expected pattern: "^https://developer.mozilla.org/docs/Web/API/MediaKeyStatusMap/iterator$"

× api\PaintWorkletGlobalScope.json
mdn_urls – 3 errors:

Actual: "https://developer.mozilla.org/docs/Web/API/PaintWorklet"
Expected pattern: "^https://developer.mozilla.org/docs/Web/API/PaintWorkletGlobalScope$"

Actual: "https://developer.mozilla.org/docs/Web/API/PaintWorklet/devicePixelRatio"
Expected pattern: "^https://developer.mozilla.org/docs/Web/API/PaintWorkletGlobalScope/devicePixelRatio$"

Actual: "https://developer.mozilla.org/docs/Web/API/PaintWorklet/registerPaint"
Expected pattern: "^https://developer.mozilla.org/docs/Web/API/PaintWorkletGlobalScope/registerPaint$"

× api\Selection.json -- false positive, may be?
mdn_urls – 2 errors:

Actual: "https://developer.mozilla.org/docs/Web/API/Selection/removeAllRanges"
Expected pattern: "^https://developer.mozilla.org/docs/Web/API/Selection/empty$"

Actual: "https://developer.mozilla.org/docs/Web/API/Selection/collapse"
Expected pattern: "^https://developer.mozilla.org/docs/Web/API/Selection/setPosition$"

× api\ServiceWorkerRegistration.json
mdn_urls – 7 errors:

Actual: "https://developer.mozilla.org/docs/Web/API/ServiceWorkerRegistration/showNotification"
Expected pattern: "^https://developer.mozilla.org/docs/Web/API/ServiceWorkerRegistration/showNotification/actions$"

Actual: "https://developer.mozilla.org/docs/Web/API/ServiceWorkerRegistration/showNotification"
Expected pattern: "^https://developer.mozilla.org/docs/Web/API/ServiceWorkerRegistration/showNotification/badge$"

Actual: "https://developer.mozilla.org/docs/Web/API/ServiceWorkerRegistration/showNotification"
Expected pattern: "^https://developer.mozilla.org/docs/Web/API/ServiceWorkerRegistration/showNotification/data$"

Actual: "https://developer.mozilla.org/docs/Web/API/ServiceWorkerRegistration/showNotification"
Expected pattern: "^https://developer.mozilla.org/docs/Web/API/ServiceWorkerRegistration/showNotification/image$"

Actual: "https://developer.mozilla.org/docs/Web/API/ServiceWorkerRegistration/showNotification"
Expected pattern: "^https://developer.mozilla.org/docs/Web/API/ServiceWorkerRegistration/showNotification/renotify$"

Actual: "https://developer.mozilla.org/docs/Web/API/ServiceWorkerRegistration/showNotification"
Expected pattern: "^https://developer.mozilla.org/docs/Web/API/ServiceWorkerRegistration/showNotification/requireInteraction$"

Actual: "https://developer.mozilla.org/docs/Web/API/ServiceWorkerRegistration/showNotification"
Expected pattern: "^https://developer.mozilla.org/docs/Web/API/ServiceWorkerRegistration/showNotification/vibrate$"

× html\elements\html.json
mdn_urls – 1 error:

Actual: "https://developer.mozilla.org/docs/Web/HTML/Using_the_application_cache"
Expected pattern: "^https://developer.mozilla.org/docs/Web/HTML/Element/html/manifest$"

× html\elements\iframe.json
mdn_urls – 1 error:

Actual: "https://developer.mozilla.org/docs/Mozilla/Gecko/Chrome/API/Browser_API"
Expected pattern: "^https://developer.mozilla.org/docs/Web/HTML/Element/iframe/mozbrowser$"

× http\data-url.json
mdn_urls – 1 error:

Actual: "https://developer.mozilla.org/docs/Web/HTTP/Basics_of_HTTP/Data_URIs"
Expected pattern: "^https://developer.mozilla.org/docs/Web/HTTP/data-url$"

× javascript\builtins\Object.json
mdn_urls – 4 errors:

Actual: "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/__defineGetter__"
Expected pattern: "^https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/defineGetter$"

Actual: "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/__defineSetter__"
Expected pattern: "^https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/defineSetter$"

Actual: "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/__lookupGetter__"
Expected pattern: "^https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/lookupGetter$"

Actual: "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/__lookupSetter__"
Expected pattern: "^https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/lookupSetter$"

× javascript\builtins\Promise.json
mdn_urls – 1 error:

Actual: "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise"
Expected pattern: "^https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise/Promise$"

× webextensions\api\cookies.json
mdn_urls – 2 errors:

Actual: "https://developer.mozilla.org/docs/Mozilla/Add-ons/WebExtensions/API/cookies/set"
Expected pattern: "^https://developer.mozilla.org/docs/Mozilla/Add-ons/WebExtensions/API/cookies/Cookie/sameSite$"

Actual: "https://developer.mozilla.org/docs/Mozilla/Add-ons/WebExtensions/API/cookies/set"
Expected pattern: "^https://developer.mozilla.org/docs/Mozilla/Add-ons/WebExtensions/API/cookies/sameSiteStatus$"

@sideshowbarker
Copy link
Member

@sideshowbarker I noticed you filed #5256 and #5257, which actually help with linter (since they fix some values that linter would fail on). If you are interested, here are some more similar issues (some of these might be false positives)

Thanks — I’ll be happy to raise PRs for those

@queengooborg
Copy link
Contributor

Speaking of which, @bershanskiy, would you be willing to re-share your linter code (particularly in the form of a PR), since we repurposed the original PR for just the API folder updates?

@bershanskiy
Copy link
Contributor Author

@vinyldarkscratch

would you be willing to re-share your linter code

Done! #5273

@Elchi3
Copy link
Member

Elchi3 commented Aug 10, 2023

I'm going to close this in favor of #5201 which suggests to test for broken links.

@Elchi3 Elchi3 closed this as not planned Won't fix, can't repro, duplicate, stale Aug 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
idle Issues and pull requests with no recent activity linter Issues or pull requests regarding the tests / linter of the JSON files.
Projects
None yet
Development

No branches or pull requests

4 participants