Skip to content

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
developfrom
philipp/ci-fix-plot-svg-siblings-no-new-array-2026-05-23
Draft

fix(@stdlib/plot/components/svg): replace new Array() with array literal in defs, background, and path#12252
Planeshifter wants to merge 1 commit into
developfrom
philipp/ci-fix-plot-svg-siblings-no-new-array-2026-05-23

Conversation

@Planeshifter
Copy link
Copy Markdown
Member

Resolves .

Description

What is the purpose of this pull request?

This pull request:

  • fixes stdlib/no-new-array lint violations in three SVG plot component files by replacing new Array( arguments.length+1 ) constructor calls with array literal plus push() in the onRender callback of each constructor

Related Issues

Does this pull request have any related issues?

This pull request has the following related issues:

Questions

Any questions for reviewers of this pull request?

No.

Other

Any other information relevant to this pull request? This may include screenshots, references, and/or implementation notes.

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

Symptom: stdlib/no-new-array reported 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 onRender closure pre-allocated args = new Array( arguments.length+1 ), assigned args[0] = 'render', and filled subsequent indices by position before calling self.emit.apply( self, args ). The pattern is semantically correct but violates the project rule prohibiting the Array constructor.

Fix: Replace new Array( arguments.length+1 ) and positional index assignment with an array literal [ 'render' ] and a push() call inside the loop body. The resulting array is equivalent for all values of arguments.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 to error, causing CI failure); the pattern matches the fix applied to clip-path and mirrors PR #12244.

Reviewer notes: Additional sibling components (annotations, axis, graph, rug, symbols, title) contain the same new Array pattern and require follow-up PRs. The clip-path and marks siblings do not require changes — clip-path already uses the corrected pattern and marks does not have the violation.

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 helps reviewers determine how much scrutiny to apply when reviewing your contribution. Example disclosures: "This PR was written primarily by Claude Code." or "I consulted ChatGPT to understand the codebase, but the proposed changes were fully authored manually by myself.".

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

…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
@stdlib-bot
Copy link
Copy Markdown
Contributor

Coverage Report

No coverage information available.

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.

3 participants