-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Enforce feature order #3427
Enforce feature order #3427
Conversation
Again, the devil is in the details :) I think we need to talk a bit how we want to sort special characters. The characters allowed for the identifiers that we want to sort here are You can observe this for example on this table https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp#Browser_compatibility. There you have Another case is https://developer.mozilla.org/en-US/docs/Web/CSS/@media#Browser_compatibility where all the -moz- prefixed items etc would now be at the top when we right now have placed them at the end. So, I've tried to change the sorting and here's what I came up with to put special chars last (change in fix-feature-order.js). value = Object.keys(value).sort((a, b) => {
if(a === '__compat') return -1;
return (b.toLowerCase().localeCompare("a") >= 0) - (a.toLowerCase().localeCompare("a") >= 0)
|| a.toLowerCase().localeCompare(b.toLowerCase());
}) I didn't change it in the linter to see the difference to the current sorting, so here's the output of that and where this differs exactly from your original sorting.
Long story short: I don't know how you or everyone else feels about this, but I think we should have special char things like the |
I'm in favor of putting them towards the bottom, especially if that's how we've got it currently sorted. I went ahead and committed those changes to |
I think the main reason for sorting features is to help people find things, and give them the simplest, most consistent and most predictable rule for finding things. So for me the answer to "how should we sort special characters?" is "how would most people expect special characters to be sorted?". Personally, I'd expect non-alpha characters to come first, just because that's the default in But I don't feel strongly about this. The main things are to have the check in the linter and the fix command. I saw this is using |
Ah, unfortunately it looks like it may be giving different results. I just gave it a quick test run by merging all of the sorting PRs into a new branch, along with the latest master, and it looks like there's over a thousand files that are being changed from the new code. We should probably look further into what exactly |
Thanks, Will!
Yes, this question was driving my thinking as well. I believe for the two examples I've given, my view would be that people would expect special things like Given this seems to only affect sorting in 24 files, I think we could go with the "special characters last" approach for now, but change to standard "special characters first" sort, if it causes problems (I don't think it will).
Good question. I think nodejs now supports internationalization, so this might matter. |
And done, all sorting PRs have been updated to reflect this as well! (I realized I made a slight mistake the first time -- I set it up so that anything with numbers in it is sorted last. Heh, whoops...) |
@vinyldarkscratch A heads up here, I'm not certain I'll have enough time to review this this week (I saw you tagged me in a review, I'm not ignoring it). If I can't get to this week, I'll give you some sort of update on Monday. Thank you! |
Not a problem, thanks for taking the time to review it! There’s definitely no rush. 😉 |
Hey @vinyldarkscratch, thanks for your patience on this. Would you be open to sort of rebooting this process, to try out some of the things we've discussed on #4469? I can draw up some next steps for that, if you're interested. Or if you'd rather press on with how things have started here, we can leave the #4469 to another issue. Let me know what you'd prefer. |
We've been referring to this PR in the discussion in #4469. Yeah, let's give this one a reboot with the new plans! What would you like me to do to get this prepared for the new process? |
OK, supposing we were starting from square one, here's how I'd imagine migrations would look:
As it pertains to this PR specifically, I'd expect:
As you can tell, I'm making this up as I go, so I'm open to ideas or improvements on this. |
Sounds like a plan to me! Regarding the location of the script, personally, I feel that the fix-up script should remain where it is for two reasons:
I'm not stubborn on this. We can easily set up a fix script that uses the scripts within that folder! Which do you think is more appropriate? |
This is a great point and I didn't think of it. Yeah, leave the script where it is. |
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.
Thanks for all your work on this one! Looks good to me! Let's merge this now so we don't regress sorting in new PRs anymore.
This closes #264 and introduces the sorting of all the features by alphabetical order (case insensitive). This also provides a script that automatically sorts said features (as well as the browser order in
__compat
), which can be called usingnpm run fix
.