style(@stdlib/plot/components/svg/canvas): fix no-new-array in onRender#12244
Draft
Planeshifter wants to merge 1 commit into
Draft
style(@stdlib/plot/components/svg/canvas): fix no-new-array in onRender#12244Planeshifter wants to merge 1 commit into
Planeshifter wants to merge 1 commit into
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves #12236.
Description
This pull request:
new Array( arguments.length+1 )+ index assignment inonRender()with an array literal[ 'render' ]andpush()to satisfy thestdlib/no-new-arraylint rule.Related Issues
Questions
No.
Other
Failing run: https://github.com/stdlib-js/stdlib/actions/runs/26260926243 (2026-05-22T00:33:27Z,
develop)Symptom:
stdlib/no-new-arrayviolation atlib/node_modules/@stdlib/plot/components/svg/canvas/lib/main.js:124—Using the 'new Array()' constructor is not allowed; use an array literal with push instead.Root cause:
onRender()pre-allocatedargs = new Array( arguments.length+1 )and filled it by index before passing toself.emit.apply(). The pattern is semantically correct but violates the project'sno-new-arrayrule.Change:
argsis now initialized as[ 'render' ]before the loop; eacharguments[i]is appended viapush(). 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
AI Assistance
If you answered "yes" above, how did you use AI assistance?
Disclosure
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