Skip to content

style(@stdlib/plot/components/svg/canvas): fix no-new-array in onRender#12244

Draft
Planeshifter wants to merge 1 commit into
developfrom
philipp/ci-fix-plot-canvas-no-new-array-2026-05-22
Draft

style(@stdlib/plot/components/svg/canvas): fix no-new-array in onRender#12244
Planeshifter wants to merge 1 commit into
developfrom
philipp/ci-fix-plot-canvas-no-new-array-2026-05-22

Conversation

@Planeshifter
Copy link
Copy Markdown
Member

Resolves #12236.

Description

What is the purpose of this pull request?

This pull request:

  • Replaces new Array( arguments.length+1 ) + index assignment in onRender() with an array literal [ 'render' ] and push() to satisfy the stdlib/no-new-array lint rule.

Related Issues

Does this pull request have any related issues?

Questions

Any questions for reviewers of this pull request?

No.

Other

Any other information relevant to this pull request?

Failing run: https://github.com/stdlib-js/stdlib/actions/runs/26260926243 (2026-05-22T00:33:27Z, develop)

Symptom: stdlib/no-new-array violation at lib/node_modules/@stdlib/plot/components/svg/canvas/lib/main.js:124Using the 'new Array()' constructor is not allowed; use an array literal with push instead.

Root cause: onRender() pre-allocated args = new Array( arguments.length+1 ) and filled it by index before passing to self.emit.apply(). The pattern is semantically correct but violates the project's no-new-array rule.

Change: args is now initialized as [ 'render' ] before the loop; each arguments[i] is appended via push(). Behavior is identical for the .apply() call site.

Validation: Three independent reviewer agents (two opus, one sonnet) reviewed the diff; all returned approve or non-blocking findings only.

Note: Five sibling SVG subcomponents (defs, marks, clip-path, background, path) contain the identical pattern and were not changed in this PR. They should be addressed in a follow-up.

Checklist

Please ensure the following tasks are completed before submitting this pull request.

AI Assistance

When authoring the changes proposed in this PR, did you use any kind of AI assistance?

  • Yes
  • No

If you answered "yes" above, how did you use AI assistance?

  • Code generation (e.g., when writing an implementation or fixing a bug)
  • Test/benchmark generation
  • Documentation (including examples)
  • Research and understanding

Disclosure

If you answered "yes" to using AI assistance, please provide a short disclosure indicating how you used AI assistance.

This PR was authored by Claude Code as part of an automated CI-fix routine. The fix was validated by three independent review agents (two opus, one sonnet) before committing.


@stdlib-js/reviewers


Generated by Claude Code

The lint workflow (run 26260926243, 2026-05-22) failed on develop with a
`stdlib/no-new-array` violation at line 124 of `canvas/lib/main.js`.
The `onRender` helper pre-allocated an array via `new Array(n)` followed
by index-based assignment before passing it to `self.emit.apply()`. This
constructor form is disallowed by the `stdlib/no-new-array` rule.

Replace the three-step `new Array(n)` + `args[0]='render'` + index loop
with `args = [ 'render' ]` followed by `push()` in the existing loop.
The resulting array is a dense `Array` instance; `Function.prototype.apply`
accepts it identically, so runtime behavior is unchanged.

Ref: https://github.com/stdlib-js/stdlib/actions/runs/26260926243
@stdlib-bot stdlib-bot added the Good First PR A pull request resolving a Good First Issue. label May 22, 2026
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