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

fix: move sdk code to limit number of new deps #3259

Closed

Conversation

szymonmaslowski
Copy link
Contributor

@szymonmaslowski szymonmaslowski commented Dec 10, 2024

LW-11966

Move sdk code to limit number of new deps

Copy link
Member

@DominikGuzei DominikGuzei left a comment

Choose a reason for hiding this comment

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

code changes approved, not tested 👍

@szymonmaslowski szymonmaslowski force-pushed the fix/lw-11966-limit-number-of-new-deps branch from d1c8b50 to 9df2664 Compare December 10, 2024 17:09
Comment on lines +138 to +142
assertLength(expectedLength, target);
// eslint-disable-next-line wrap-regex
if (target.length > 0 && !/^[\da-f]+$/i.test(target)) {
throw new Error('expected hex string');
}
Copy link

Choose a reason for hiding this comment

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

code more readable and removes need for eslint comment

Suggested change
assertLength(expectedLength, target);
// eslint-disable-next-line wrap-regex
if (target.length > 0 && !/^[\da-f]+$/i.test(target)) {
throw new Error('expected hex string');
}
assertLength(expectedLength, target);
const isHexString = /^[\da-f]+$/i;
if (target.length > 0 && !isHexString.test(target)) {
throw new Error('expected hex string');
}

Comment on lines +145 to +149
export const typedHex = <T,>(value: string, length?: number): T => {
assertIsHexString(value, length);
// eslint-disable-next-line @typescript-eslint/no-explicit-any
return (value as any) as T;
};
Copy link

Choose a reason for hiding this comment

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

better to use unknown for this case imo, also complies with eslint requirements

Suggested change
export const typedHex = <T,>(value: string, length?: number): T => {
assertIsHexString(value, length);
// eslint-disable-next-line @typescript-eslint/no-explicit-any
return (value as any) as T;
};
export const typedHex = <T>(value: string, length?: number): T => {
assertIsHexString(value, length);
return value as unknown as T;
};

@szymonmaslowski
Copy link
Contributor Author

Most probably, we are not going to include these changes.

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.

4 participants