Skip to content

fix(@toss/hangul): replace non-null assertion(!) with nullish coalescing operator (??) #487

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

Merged
merged 4 commits into from
Jun 2, 2024

Conversation

saul-atomrigs
Copy link
Contributor

Overview

first: HANGUL_CHARACTERS_BY_FIRST_INDEX[firstIndex]!,
middle: HANGUL_CHARACTERS_BY_MIDDLE_INDEX[middleIndex]!,
last: HANGUL_CHARACTERS_BY_LAST_INDEX[lastIndex]!,

This PR addresses the typescript-eslint warning (forbidden non-null assertion) by replacing it with the nullish coalescing operator (??) and giving an empty string as the default value.

AS-IS

Captura de pantalla 2024-05-31 a las 10 14 07 a  m

TO-BE

Captura de pantalla 2024-05-31 a las 10 24 32 a  m

source: https://typescript-eslint.io/rules/no-non-null-assertion/

PR Checklist

  • [✅] I read and included theses actions below
  1. I have read the Contributing Guide
  2. I have written documents and tests, if needed.

@saul-atomrigs saul-atomrigs requested a review from okinawaa as a code owner May 31, 2024 01:30
Copy link

vercel bot commented May 31, 2024

@saul-atomrigs is attempting to deploy a commit to the Toss Team on Vercel.

A member of the Team first needs to authorize it.

@raon0211
Copy link
Collaborator

Thanks for your contribution!

Actually this was intended on purpose; there is no chance that the array access results in returning undefined. Adding nullish coalescing will add extra runtime overhead and increase in bundle size.

If possible, I think adding some comments like // eslint-disable-next-line is a better design choice.

@saul-atomrigs
Copy link
Contributor Author

Oh, I see your point makes sense. Thanks!

Would you like me to add either // eslint-disable-next-line above each line or maybe /* eslint-disable @typescript-eslint/no-non-null-assertion */ for the entire page? Happy to contribute :)

@raon0211
Copy link
Collaborator

raon0211 commented Jun 1, 2024

I think adding separate // eslint-disable-next-line @typescript-eslint/no-non-null-assertion for each line would be helpful for us :)

@saul-atomrigs
Copy link
Contributor Author

Changes applied. Many thanks!

Copy link
Collaborator

@raon0211 raon0211 left a comment

Choose a reason for hiding this comment

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

Thanks!

@raon0211 raon0211 merged commit 12a5872 into toss:main Jun 2, 2024
5 of 6 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