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

Rewrite emoji_utils to TS #30147

Open
wants to merge 18 commits into
base: main
Choose a base branch
from

Conversation

taichi221228
Copy link
Contributor

This PR rewrites emoji_utils as TS.

The buildSearch function has been refactored for better coding practices. More explicit typings and declaration were used, and the logic related to array search has been simplified for better readability. The 'eslint-disable' comment line was moved to a more appropriate location after these changes.
Removed the unnecessary stringFromCodePoint function polyfill from the emoji_utils.ts file. Instead, we use the built-in JavaScript function String.fromCodePoint to simplify the code.
The unifiedToNative function in emoji_utils.ts has been refactored for cleaner coding practices. Lint disabling has been moved to a different part of the code, and type checking has been revised to specify that the input unified is of type Emoji['unified']. The function's variables have been updated to const for better securities against undesired changes.
The emoji sanitization function has been refactored for better handling of emoji variations. New types have been imported from 'emoji-mart', allowing for a more precise type assignment for the emoji input and output. Bound checking operations have been adjusted to better accommodate and handle custom emojis and skin variations.
This commit adds detailed comments explaining the usage of `skin_tone` in emoji_utils.ts, noting its absence in the type definition link and the need for a separate type with DefinitelyTyped. It also highlights potential mismatch issues between versions of `@types/emoji-mart` and `emoji-mart`, given they have different maintainers and packages.
The refactoring of emoji utilities in the mastodon feature has been done to enhance readability and maintenance of the code. The types and functions involved in sanitizing and getting data have been clarified, including the introduction of an interface for skin tones. Additionally, erroneous typescript comments have been removed and the emojis type has been exported for further use.
The unused constant `_JSON` was removed from the `emoji_utils.ts` file. This decluttering enhances the manageability and readability of the code.
This commit introduces type aliases to the emoji utilities in JavaScript code, specifically `RawEmoji` and `GetDataArgs`. These changes help to simplify function signatures. By extracting complex types into separate type aliases, the code readability has been improved significantly.
A comment has been added to the 'getData' function in emoji_utils.ts to clarify that the source code version does not match that of DefinitelyTyped. The note also highlights the challenges in maintaining type consistency due to outdated and non-existing properties.
This commit refactors the `uniq` function found in the emoji utilities to accept an explicitly defined array as an argument, improving overall TypeScript compliance. It also replaces the `.indexOf` method with the more efficient `.includes` method for better performance.
This commit refactors the intersect function in the emoji_utils.ts file. The `a` and `b` parameters are more explicitly defined as empty arrays, and the indexOf method is replaced with the includes method for better readability and performance. Additionally, the placement of the eslint-disable directive has been adjusted to improve linting results.
The deepMerge function was removed from the emoji_utils file. This function was not used in the code and was deemed unnecessary, hence it was removed. Also, with its removal, the corresponding import was deleted.
New comments were added in the 'emoji_utils.ts' file to suggest separating the general array operations from the emoji-related functions into different files. This aims to increase the readability and maintainability of the code.
The measureScrollbar function has been deleted from the emoji_utils.ts file. This simplifies the module export list by removing a function that was unnecessary or out of context.
Removed the no-unsafe-return rule from the eslint-disable and eslint-enable comments in the emoji_utils.ts file, as it is no longer required. This helps to improve code readability and reduces unnecessary complexity.
@ClearlyClaire ClearlyClaire requested a review from a team May 6, 2024 10:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants