fix(@stdlib/plot/components/svg): replace new Array() with array literal in defs, background, and path#12252
Draft
Planeshifter wants to merge 1 commit into
Draft
Conversation
…teral in `defs`, `background`, and `path` The `lint_random_files` workflow on `develop` fails with `stdlib/no-new-array` violations in these three SVG component files. The `onRender()` callback in each pre-allocates `args = new Array( arguments.length+1 )`, sets `args[0] = 'render'`, and fills indices 1..N by position before passing to `self.emit.apply( self, args )`. The pattern is semantically correct but violates the project `no-new-array` rule, which is set to `error`. Replace with an array literal `[ 'render' ]` pre-seeded with the event name, then append forwarded arguments via `push()`. Both approaches produce the same dense array `['render', ...forwardedArgs]` for all values of `arguments.length`, including zero. The `emit.apply` call contract is unchanged. This follows the identical fix applied to the sibling `canvas` component in PR #12244, which explicitly left these three files as a follow-up. The `clip-path` and `marks` siblings do not require changes (they already use the corrected pattern or do not have the violation). Ref: https://github.com/stdlib-js/stdlib/actions/runs/26260926243
Contributor
Coverage ReportNo coverage information available. |
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 .
Description
This pull request:
stdlib/no-new-arraylint violations in three SVG plot component files by replacingnew Array( arguments.length+1 )constructor calls with array literal pluspush()in theonRendercallback of each constructorRelated Issues
This pull request has the following related issues:
@stdlib/plot/components/svg/canvas)Questions
No.
Other
Failing run: https://github.com/stdlib-js/stdlib/actions/runs/26260926243 (
lint_random_files, branchdevelop, 2026-05-22T00:33:27Z)Symptom:
stdlib/no-new-arrayreported at error severity in three files:lib/node_modules/@stdlib/plot/components/svg/defs/lib/main.js(line 79)lib/node_modules/@stdlib/plot/components/svg/background/lib/main.js(line 124)lib/node_modules/@stdlib/plot/components/svg/path/lib/main.js(line 179)Root cause: Each
onRenderclosure pre-allocatedargs = new Array( arguments.length+1 ), assignedargs[0] = 'render', and filled subsequent indices by position before callingself.emit.apply( self, args ). The pattern is semantically correct but violates the project rule prohibiting theArrayconstructor.Fix: Replace
new Array( arguments.length+1 )and positional index assignment with an array literal[ 'render' ]and apush()call inside the loop body. The resulting array is equivalent for all values ofarguments.length, including zero. Total diff: 3 files, +6/-9 lines.Validation: Three independent review passes confirmed correctness and no regression; the
fix:commit type is correct (rule is set toerror, causing CI failure); the pattern matches the fix applied toclip-pathand mirrors PR #12244.Reviewer notes: Additional sibling components (
annotations,axis,graph,rug,symbols,title) contain the samenew Arraypattern and require follow-up PRs. Theclip-pathandmarkssiblings do not require changes —clip-pathalready uses the corrected pattern andmarksdoes not have the violation.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