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

refactor(helper/html): Prefer Array.isArray over instanceof Array #3601

Merged
merged 1 commit into from
Nov 1, 2024

Conversation

exoego
Copy link
Contributor

@exoego exoego commented Oct 31, 2024

Array.isArray is more widely used in Hono codebase, specially in jsx and css.

Theoretical reason: https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-instanceof-array.md

And it's a bit shorter 😝

a instanceof Array // 18 chars
Array.isArray(a)  // 16 chars

The author should do the following, if applicable

  • Add tests
  • Run tests
  • bun run format:fix && bun run lint:fix to format the code
  • Add TSDoc/JSDoc to document the code

Copy link

codecov bot commented Oct 31, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 94.71%. Comparing base (4dd8b2b) to head (c2d55c3).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3601   +/-   ##
=======================================
  Coverage   94.71%   94.71%           
=======================================
  Files         158      158           
  Lines        9555     9556    +1     
  Branches     2813     2810    -3     
=======================================
+ Hits         9050     9051    +1     
  Misses        505      505           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@yusukebe yusukebe changed the title refactor: Prefer Array.isArray over instanceof Array refactor(helper/html): Prefer Array.isArray over instanceof Array Nov 1, 2024
Copy link
Member

@yusukebe yusukebe left a comment

Choose a reason for hiding this comment

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

LGTM!

@yusukebe
Copy link
Member

yusukebe commented Nov 1, 2024

@exoego

Yeah, we should use Array.isArray. Thank you!

@yusukebe yusukebe merged commit c88ead6 into honojs:main Nov 1, 2024
16 checks passed
@exoego exoego deleted the isarray branch November 1, 2024 01:14
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