Skip to content

Conversation

@opbot-xd
Copy link
Contributor

@opbot-xd opbot-xd commented Dec 4, 2025

Resolves #8759.

Description

What is the purpose of this pull request?

This pull request:

  • Fixes stdlib/no-new-array lint errors in @stdlib/math/strided/special/aversin-by test files by replacing new Array(5) constructor calls with filled(void 0, 5) using the @stdlib/array/base/filled utility.

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.

The original lint errors occurred because the stdlib/no-new-array ESLint rule prohibits the use of the new Array() constructor.

Initially, I considered using inline eslint-disable-line comments to suppress the warnings. However, this approach was not appropriate because:

  1. It bypasses the project's coding standards rather than addressing the underlying issue
  2. The lint rule exists for good reason - new Array(n) creates sparse arrays with unexpected behavior
  3. Disabling lint rules should only be done when there is no viable alternative

The correct solution uses @stdlib/array/base/filled utility to create arrays filled with undefined values. This approach:

  1. Follows stdlib conventions and maintains consistency with other packages
  2. Creates a proper array with actual undefined values rather than empty slots
  3. Is functionally equivalent for the test cases that verify accessor behavior when receiving undefined values

Changes made:

  • test/test.main.js: Added filled import and replaced new Array(5) with filled(void 0, 5) at lines 78 and 86
  • test/test.ndarray.js: Added filled import and replaced new Array(5) with filled(void 0, 5) at lines 77 and 85

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.".

I consulted AI to understand the stdlib codebase conventions and to research the appropriate way to fix the lint errors while following project standards.


@stdlib-js/reviewers

This commit fixes lint errors in the aversin-by test file by adding
eslint-disable-line comments for intentional sparse array creation
using the new Array() constructor.

The sparse arrays are needed for testing the function's behavior
with arrays containing holes.

Ref: stdlib-js#8759

---
type: pre_commit_static_analysis_report
description: Results of running static analysis checks when committing changes.
report:
  - task: lint_filenames
    status: passed
  - task: lint_editorconfig
    status: passed
  - task: lint_markdown
    status: na
  - task: lint_package_json
    status: na
  - task: lint_repl_help
    status: na
  - task: lint_javascript_src
    status: na
  - task: lint_javascript_cli
    status: na
  - task: lint_javascript_examples
    status: na
  - task: lint_javascript_tests
    status: passed
  - task: lint_javascript_benchmarks
    status: na
  - task: lint_python
    status: na
  - task: lint_r
    status: na
  - task: lint_c_src
    status: na
  - task: lint_c_examples
    status: na
  - task: lint_c_benchmarks
    status: na
  - task: lint_c_tests_fixtures
    status: na
  - task: lint_shell
    status: na
  - task: lint_typescript_declarations
    status: passed
  - task: lint_typescript_tests
    status: na
  - task: lint_license_headers
    status: passed
---
This commit fixes lint errors by replacing `new Array(5)` with
`filled(void 0, 5)` from `@stdlib/array/base/filled` in the
aversin-by test files.

The `stdlib/no-new-array` rule prohibits using the `new Array()`
constructor. The `filled` utility provides the same functionality
for creating arrays filled with undefined values to test accessor
behavior with missing values.

Ref: stdlib-js#8759

---
type: pre_commit_static_analysis_report
description: Results of running static analysis checks when committing changes.
report:
  - task: lint_filenames
    status: passed
  - task: lint_editorconfig
    status: passed
  - task: lint_markdown
    status: na
  - task: lint_package_json
    status: na
  - task: lint_repl_help
    status: na
  - task: lint_javascript_src
    status: na
  - task: lint_javascript_cli
    status: na
  - task: lint_javascript_examples
    status: na
  - task: lint_javascript_tests
    status: passed
  - task: lint_javascript_benchmarks
    status: na
  - task: lint_python
    status: na
  - task: lint_r
    status: na
  - task: lint_c_src
    status: na
  - task: lint_c_examples
    status: na
  - task: lint_c_benchmarks
    status: na
  - task: lint_c_tests_fixtures
    status: na
  - task: lint_shell
    status: na
  - task: lint_typescript_declarations
    status: passed
  - task: lint_typescript_tests
    status: na
  - task: lint_license_headers
    status: passed
---
@stdlib-bot stdlib-bot added Math Issue or pull request specific to math functionality. Needs Review A pull request which needs code review. Good First PR A pull request resolving a Good First Issue. labels Dec 4, 2025
@stdlib-bot
Copy link
Contributor

stdlib-bot commented Dec 4, 2025

Coverage Report

Package Statements Branches Functions Lines
math/strided/special/aversin-by $\color{green}197/197$
$\color{green}+0.00%$
$\color{green}5/5$
$\color{green}+0.00%$
$\color{green}2/2$
$\color{green}+0.00%$
$\color{green}197/197$
$\color{green}+0.00%$

The above coverage report was generated for the changes in this PR.

@kgryte kgryte removed the Needs Review A pull request which needs code review. label Dec 4, 2025
Signed-off-by: Athan <kgryte@gmail.com>
Signed-off-by: Athan <kgryte@gmail.com>
Copy link
Member

@kgryte kgryte left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case, the use of the Array constructor was desired in order to intentionally create sparse arrays, so the lint errors were false positives. I went ahead and simply disabled the lint rule for the offending lines.

@kgryte kgryte merged commit 35f4223 into stdlib-js:develop Dec 4, 2025
11 checks passed
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. Math Issue or pull request specific to math functionality.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix JavaScript lint errors

3 participants