Skip to content

feat: fix JavaScript lint errors issue #11193#11204

Open
shaniprajapatiii wants to merge 2 commits intostdlib-js:developfrom
shaniprajapatiii:shani
Open

feat: fix JavaScript lint errors issue #11193#11204
shaniprajapatiii wants to merge 2 commits intostdlib-js:developfrom
shaniprajapatiii:shani

Conversation

@shaniprajapatiii
Copy link
Copy Markdown

@shaniprajapatiii shaniprajapatiii commented Mar 29, 2026

Resolves #11193

Description

What is the purpose of this pull request?

This pull request:

  • fixes stdlib/no-new-array violations in lib/node_modules/@stdlib/stats/ztest2/benchmark/benchmark.js by replacing new Array(...) initialization with [] plus push(...)
  • fixes the ndarray package-sorting cycle by refactoring lib/node_modules/@stdlib/ndarray/base/assert/is-data-type-string/lib/main.js to use a precomputed dtype lookup table
  • removes the dependency path through @stdlib/array/base/assert/contains, which eliminates the reported cycle while preserving dtype-membership semantics

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?

  • Scope separation: This PR addresses two independent CI failures:

    • Lint violations (6 instances of new Array(...) in lib/node_modules/@stdlib/stats/ztest2/benchmark/benchmark.js, lines 42, 47, 77, 81, 115, 119 → replaced with [] + push(...))
    • Dependency cycle (removed @stdlib/array/base/assert/contains import from lib/node_modules/@stdlib/ndarray/base/assert/is-data-type-string/lib/main.js)
  • Lookup-table approach: The dtype validation now uses a precomputed table instead of a factory import:

    // Old (cycle-inducing):
    const contains = require('@stdlib/array/base/assert/contains');
    
    // New (cycle-breaking):
    const TABLE = {
      'float32': true,
      'float64': true,
      // ... all supported dtypes
    };
    function isDataTypeString(v) {
      return isString(v) && hasOwnProperty(TABLE, v);
    }

    Is this pattern acceptable, or do you recommend an alternative (e.g., lazy/deferred dependency loading)?

Other

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

Implementation notes, reasoning, and validation proof:

  • Root-cause discovery path:

    • The lint log reported exact file/line positions in the ztest2 benchmark where new Array(...) violated stdlib/no-new-array.
    • The dependency error reported a specific cycle chain including @stdlib/ndarray/base/assert/is-data-type-string and @stdlib/array/base/assert/contains.
    • Based on this, the fix focused on removing only the offending lint pattern and breaking only the dependency edge that introduced the cycle.
  • Why this approach is best for this PR:

    • It is the smallest safe change set for the reported failures.
    • It is behavior-preserving: benchmark logic and dtype-string validation semantics remain intact.
    • It directly targets CI blockers without introducing unrelated architectural changes.
  • Validation proof (local):

    • node lib/node_modules/@stdlib/stats/ztest2/test/test.js -> pass (121/121)
    • node lib/node_modules/@stdlib/ndarray/base/assert/is-data-type-string/test/test.js -> pass (32/32)
    • node -p "(()=>{const out=require('./lib/node_modules/@stdlib/_tools/pkgs/toposort/lib/index.js').sync(); if(out instanceof Error){throw out;} return 'Toposort(all) OK. Package count: '+out.length;})()" -> pass (Toposort(all) OK)
    • Select-String -Path "lib/node_modules/@stdlib/stats/ztest2/benchmark/benchmark.js" -Pattern "new Array\(" -> no matches
  • Scope of changed files:

    • lib/node_modules/@stdlib/stats/ztest2/benchmark/benchmark.js
    • lib/node_modules/@stdlib/ndarray/base/assert/is-data-type-string/lib/main.js

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 use GitHub Copilot assisted for:

  • Analyzing CI logs to identify lint violations and dependency cycles
  • Understanding the codebase structure and affected modules
  • Researching documentation and patterns for both fixes

All proposed code changes were manually written after AI-assisted analysis.
I validated every change with targeted testing (121 + 32 unit tests + toposort validation).


@stdlib-js/reviewers

Copilot AI review requested due to automatic review settings March 29, 2026 19:27
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot wasn't able to review any files in this pull request.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@stdlib-bot stdlib-bot added Needs Review A pull request which needs code review. First-time Contributor A pull request from a contributor who has never previously committed to the project repository. Good First PR A pull request resolving a Good First Issue. labels Mar 29, 2026
@stdlib-bot
Copy link
Copy Markdown
Contributor

👋 Hi there! 👋

And thank you for opening your first pull request! We will review it shortly. 🏃 💨

Getting Started

Next Steps

  1. A project maintainer will approve GitHub Actions workflows for your PR.
  2. All CI checks must pass before your submission can be fully reviewed.
  3. You'll need to address any failures in linting or unit tests.

Running Tests Locally

You can use make to run any of the CI commands locally from the root directory of the stdlib repository:

# Run tests for all packages in the math namespace:
make test TESTS_FILTER=".*/@stdlib/math/.*"

# Run benchmarks for a specific package:
make benchmark BENCHMARKS_FILTER=".*/@stdlib/math/base/special/sin/.*"

If you haven't heard back from us within two weeks, please ping us by tagging the "reviewers" team in a comment on this PR.

If you have any further questions while waiting for a response, please join our Zulip community to chat with project maintainers and other community members.

We appreciate your contribution!

Documentation Links

@shaniprajapatiii shaniprajapatiii changed the title fix JavaScript lint errors (issue #11193) fix JavaScript lint errors issue #11193 and #11204 Mar 29, 2026
@shaniprajapatiii shaniprajapatiii changed the title fix JavaScript lint errors issue #11193 and #11204 fix JavaScript lint errors issue #11193 Mar 29, 2026
@shaniprajapatiii shaniprajapatiii changed the title fix JavaScript lint errors issue #11193 fix JavaScript lint errors issue #11204 Mar 29, 2026
@shaniprajapatiii shaniprajapatiii changed the title fix JavaScript lint errors issue #11204 fix JavaScript lint errors issue #11193 Mar 29, 2026
shaniprajapatiii

This comment was marked as duplicate.

shaniprajapatiii

This comment was marked as duplicate.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot wasn't able to review any files in this pull request.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@shaniprajapatiii shaniprajapatiii changed the title fix JavaScript lint errors issue #11193 fix: JavaScript lint errors issue #11193 Mar 29, 2026
@shaniprajapatiii shaniprajapatiii changed the title fix: JavaScript lint errors issue #11193 feat: fix JavaScript lint errors issue #11193 Mar 29, 2026
@github-actions github-actions bot mentioned this pull request Mar 30, 2026
@stdlib-bot stdlib-bot added the Potential Duplicate There might be another pull request resolving the same issue. label Mar 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

First-time Contributor A pull request from a contributor who has never previously committed to the project repository. Good First PR A pull request resolving a Good First Issue. Needs Review A pull request which needs code review. Potential Duplicate There might be another pull request resolving the same issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix JavaScript lint errors

3 participants