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

MEN-8001 #172

Merged
merged 4 commits into from
Feb 13, 2025
Merged

MEN-8001 #172

merged 4 commits into from
Feb 13, 2025

Conversation

mzedel
Copy link
Contributor

@mzedel mzedel commented Feb 13, 2025

No description provided.

@mzedel mzedel requested a review from mineralsfree February 13, 2025 08:01
Copy link
Contributor

@mineralsfree mineralsfree left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just some small suggestions, thank you 👍

if (typeof a[field] === 'string') {
const result = a[field].localeCompare(b[field], { sensitivity: 'case' });
const result = a[field].localeCompare(b[field], navigator.language, { sensitivity: 'case' });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's not the best idea to sort it based on browser settings. Maybe en-US?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's what the localeCompare did until now if I read https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/localeCompare#locales correctly - just that the absence of the parameter made the sensitivity option not apply... maybe it would be clearer with undefined?

Copy link
Contributor

@mineralsfree mineralsfree Feb 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, undefined is effectively equivalent to navigator.language in this case. en-US will sort things consistently across browsers, but maybe wrong in different alphabet. I am not sure what is more important here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

en-US won't sort it consistent with the user expectation either if the expectation is based on how it works now 🤷 - IMO the important part is getting the case insensitivity enabled, as that was intentional in here

import dayjs from 'dayjs';
import utc from 'dayjs/plugin/utc.js';
import pluralize from 'pluralize';
import Cookies from 'universal-cookie';

dayjs.extend(utc);

const isEncoded = uri => {
const isEncoded = (uri: string) => {
uri = uri || '';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not related to your changes, but this could be achieved through default params. I think it's better to avoid reassigning the arguments

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can't default to this everywhere though, as we might get a falsy value that's not undefined passed (thinking primarily about the inputs where we fallback to empty strings)

hasMonitor: boolean;
ipAddress?: string;
isDemoMode: boolean;
isHosted: boolean;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you think it would make sense to add member ordering rules to eslint?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, I was tempted to do that, but we rely on the order of some objects in the UI code, where we then iterate over the object entries... but since the iteration order afaik isn't guaranteed, we could add the rule and either ignore the places with expected order or make the iteration rely on a stable index 👌 => will do this in a follow up PR though

Copy link
Contributor

@mineralsfree mineralsfree Feb 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's possible to apply rules to typescript types and interfaces definitions exclusively, so it won't affect js objects, but both things are nice to have 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#174 turns out the ts rule only is for ts things 😆 - so the regular object sorting order can be taken on a later date 👍

@mzedel mzedel merged commit 04d3c87 into NorthernTechHQ:main Feb 13, 2025
2 checks passed
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

Successfully merging this pull request may close these issues.

2 participants