-
Notifications
You must be signed in to change notification settings - Fork 2k
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 structure #5273
Conversation
@vinyldarkscratch @sideshowbarker I don't think we should merge any linter until all URL issues are fixed, and I think #2537 won't be fixed this year. |
Thanks for creating this PR, and for taking initiative on this! This has already revealed so many issues along the way, primarily due to copy-pastes of existing data that weren't fully updated. To answer your question regarding capitalization enforcement, since MDN is case-insensitive I don't think it really matters much, but I'd say that there's no reason not to enforce it. I'm wondering if this new test file should also go into Since we're still working on fixing up the URLs, and this linter is still experimental, I'm gonna go ahead and add the "not ready" label to let the other maintainers know. 😉 |
That's my thought process exactly.
I created a separate file because it does not share any logic with that file. FYI, I do care about performance too and try to avoid unnecessary costly (complex) regular expressions. I'll share final benchmark data later when patch is more complete. Edit: typo. |
I wonder if this linter should have support for checking if each If such 404-checking were added, I think it would be need to be as a non-default option, due to the fact it’s going to be making a network request for every single |
Yes, I think it would be best if it did
So yeah then what the linter would be helping to enforce in this case is consistency in styling of the URLs (beyond just strictly checking for complete mismatches). But I think doing that level of style checking would be consistent with the purpose of the linter (and with linting in general). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I reviewed this (initial code) and tested it and found it works as expected (great!). I have no changes to suggest at this point, but I will also happily further updates/refinements
I agree that URL checker would be nice (not only 404 but any non-200 code, especially 301 and 302). However, I don't think we should add it in this PR because it'll already be pretty large (300+ lines of code).
As far as I know, #5228 introduces broken URL check for shortened URLs (aka URLs to bug reports most of which are in the notes to the compat data). I don't really know how it'll work out, so for now I just plan to wait it out.
It definitely won't make a lot of requests by default. However, I do want to lint all new URLs, so I want to add "incremental" linting -- lint only files that were changed in the PR and check only URLs that were changed in the PR. Specifically:
This approach reduces lint time from ~8 seconds to less than a second for most commits I work on. (I like this because I'm really impatient). Of course, once in a while (e.g., before each release or once a day) someone/something should do a complete (non-incremental) lint to sanity-check. Edit: tyop. |
I'm pushing all the most recent stuff to https://github.com/bershanskiy/browser-compat-data/tree/linter-mdn_url2 because I need to pull/merge/rebase from mdn/master all the time to incorporate the latest fixes. I'll push all the good stuff to this branch once it's in a presentable state. |
Don't worry, #5228 covers all of that. It checks every URL within BCD (
This certainly brings up an interesting way to optimize linter time! I'd say that this is something we should probably implement for not just this linter, but all of them. Let's get a discussion going for this -- can you open up an issue so we can get that going? |
/** @type {Identifier} */ | ||
// TODO(bershanskiy): remove require, if applicable | ||
// See https://github.com/mdn/browser-compat-data/pull/5795 | ||
const data = require(filename); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wait for #5795.
I have updated the linter and rebased the PR to pull in changes from master. This PR is still work-in-progress and should wait for:
|
Thanks for this summary @bershanskiy. That makes it a lot easier for me to prioritize reviews. |
Tracking list of URLs that might need to be updated:
|
This PR is stale, I'll open a new one once I update the patch. |
Summary
This is linter from #5201. Currently, it is very experimental because I would like to fix as many actual bugs before committing to a particular linter implementation.
Questions for bike-shedding:
MDN uses case-insensitive URLs (serves the same content regardless of capitalization), but that would weaken the linter.
TODO list:
CC @vinyldarkscratch @sideshowbarker
A checklist to help your pull request get merged faster: