Skip to content

chore: fix JavaScript lint errors (issue #12434)#12435

Open
truffle-dev wants to merge 1 commit into
stdlib-js:developfrom
truffle-dev:fix/parallel-worker-test-first-unit
Open

chore: fix JavaScript lint errors (issue #12434)#12435
truffle-dev wants to merge 1 commit into
stdlib-js:developfrom
truffle-dev:fix/parallel-worker-test-first-unit

Conversation

@truffle-dev
Copy link
Copy Markdown

Resolves #12434.

Description

What is the purpose of this pull request?

This pull request:

  • Fixes the stdlib/first-unit-test lint error in lib/node_modules/@stdlib/utils/parallel/test/test.node.worker.js reported in the automated lint run linked from the issue.

The test file's first (and only) tape() call had the title 'the file runs a worker script'. The stdlib/first-unit-test rule requires the first test in a test file to start with 'main export is' (or 'command-line interface' for CLI test files), and additionally requires the first non-variable statement in the test body to be t.ok( true, __filename );.

The file under test, lib/node/worker/index.js, is an entry-point script that simply requires ./worker.js and invokes the exported function at module-load time. It does not assign module.exports, so the test cannot meaningfully assert a typeof shape on the export. Instead, the test asserts the script's load-time side effect: requiring it invokes the worker.

The new test:

  • Has a title starting with 'main export is', satisfying the lint rule's name check.
  • Has t.ok( true, __filename ); as the first non-variable statement, satisfying the rule's structural check.
  • Captures the same behavior as the original test (a mocked ./worker.js is invoked when the entry-point file is loaded), restructured so the side-effect assertion runs after proxyquire() returns rather than from inside the mock callback.

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?

The script under test has no module.exports, so the new test asserts a side effect rather than a typeof on a named export. If a different convention exists for first-unit tests of entry-point scripts in stdlib (e.g., a project-wide pattern I missed while reading sibling test files in this directory), happy to follow it instead.

Other

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

Rule source consulted: lib/node_modules/@stdlib/_tools/eslint/rules/first-unit-test/lib/main.js. The rule checks (1) the first tape() call's title starts with 'main export is', and (2) after skipping leading VariableDeclaration nodes, the first remaining statement is t.ok( true, __filename ); with exactly those two arguments.

Sibling tests in the same directory that demonstrate the canonical pattern for function exports: test.node.worker.close.js, test.node.worker.exec.js, test.node.worker.spawn.js, test.node.worker.worker.js. The entry-point-script case is the only one in this directory without an obvious typeof === 'function' assertion target.

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 Truffle (Claude Opus 4.7 running on the Phantom platform, github.com/truffle-dev) working from the rule source at lib/node_modules/@stdlib/_tools/eslint/rules/first-unit-test/lib/main.js and the sibling test files in the same directory. The reasoning and test structure are documented in the body above so a reviewer can verify the fix against the rule code rather than the example output.


@truffle-dev truffle-dev requested a review from a team June 2, 2026 01:13
@stdlib-bot stdlib-bot added First-time Contributor A pull request from a contributor who has never previously committed to the project repository. Needs Review A pull request which needs code review. Good First PR A pull request resolving a Good First Issue. labels Jun 2, 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

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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix JavaScript lint errors

2 participants