Skip to content

Conversation

rajanarahul93
Copy link
Contributor

@rajanarahul93 rajanarahul93 commented Sep 13, 2025

Summary

This pull request resolves a stdlib/no-new-array ESLint error in the format_data.js utility within the @stdlib/plot/unicode/stemleaf package. The change updates the array initialization and population method to comply with project coding standards.

Root Cause

The code used new Array(number) to pre-allocate an array, which is disallowed by the stdlib/no-new-array lint rule. This rule is in place to prevent common bugs associated with the Array constructor and to promote a consistent coding style using array literals ([]).

Changes

  • Replaced out = new Array(data.length) with an empty array literal initialization out = [].
  • Changed the method for adding elements to the array from index assignment (out[i] = ...) to out.push(...).

Risk & Rollback

  • Risk: Low. This is a non-functional change that only addresses code style. The modified behavior (producing a dense array instead of a sparse one) is more correct for the intended use case.
  • Rollback: The commit can be safely reverted using git revert <commit_hash> if any issues are discovered.
  • Read, understood, and followed the contributing guidelines

Related

@stdlib-bot stdlib-bot added the Needs Review A pull request which needs code review. label Sep 13, 2025
@stdlib-bot
Copy link
Contributor

Hello! Thank you for your contribution to stdlib.

We noticed that the contributing guidelines acknowledgment is missing from your pull request. Here's what you need to do:

  1. Please read our contributing guidelines.

  2. Update your pull request description to include this checked box:

    - [x] Read, understood, and followed the [contributing guidelines](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md)

This acknowledgment confirms that you've read the guidelines, which include:

  • The developer's certificate of origin
  • Your agreement to license your contributions under the project's terms

We can't review or accept contributions without this acknowledgment.

Thank you for your understanding and cooperation. We look forward to reviewing your contribution!

@stdlib-bot stdlib-bot added the Good First PR A pull request resolving a Good First Issue. label Sep 13, 2025
@kgryte kgryte changed the title chore:fix no-new-array lint error in stemleaf chore: address lint errors in plot/unicode/stemleaf Sep 13, 2025
@kgryte kgryte removed the Needs Review A pull request which needs code review. label Sep 13, 2025
Copy link
Member

@kgryte kgryte left a comment

Choose a reason for hiding this comment

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

LGTM

@kgryte
Copy link
Member

kgryte commented Sep 13, 2025

As the CI failure does not stem from changes introduced in this PR, I'll go ahead and merge.

@kgryte kgryte merged commit f5d1741 into stdlib-js:develop Sep 13, 2025
52 of 57 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Good First PR A pull request resolving a Good First Issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix JavaScript lint errors
3 participants