Skip to content

Commit 8efe2b2

Browse files
committed
style(@stdlib/plot/components/svg/canvas): fix no-new-array in onRender
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
1 parent 6e874c2 commit 8efe2b2

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

  • lib/node_modules/@stdlib/plot/components/svg/canvas/lib

lib/node_modules/@stdlib/plot/components/svg/canvas/lib/main.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,9 @@ function Canvas( options ) {
121121
var args;
122122
var i;
123123
debug( 'Received a render event. Re-emitting...' );
124-
args = new Array( arguments.length+1 );
125-
args[ 0 ] = 'render';
124+
args = [ 'render' ];
126125
for ( i = 0; i < arguments.length; i++ ) {
127-
args[ i+1 ] = arguments[ i ];
126+
args.push( arguments[ i ] );
128127
}
129128
self.emit.apply( self, args );
130129
}

0 commit comments

Comments
 (0)