chore: fix JavaScript lint errors (issue #12434)#12435
Open
truffle-dev wants to merge 1 commit into
Open
Conversation
Contributor
|
👋 Hi there! 👋 And thank you for opening your first pull request! We will review it shortly. 🏃 💨 Getting Started
Next Steps
Running Tests LocallyYou can use # 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves #12434.
Description
This pull request:
stdlib/first-unit-testlint error inlib/node_modules/@stdlib/utils/parallel/test/test.node.worker.jsreported 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'. Thestdlib/first-unit-testrule 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 bet.ok( true, __filename );.The file under test,
lib/node/worker/index.js, is an entry-point script that simply requires./worker.jsand invokes the exported function at module-load time. It does not assignmodule.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:
'main export is', satisfying the lint rule's name check.t.ok( true, __filename );as the first non-variable statement, satisfying the rule's structural check../worker.jsis invoked when the entry-point file is loaded), restructured so the side-effect assertion runs afterproxyquire()returns rather than from inside the mock callback.Related Issues
This pull request has the following related issues:
Questions
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
Rule source consulted:
lib/node_modules/@stdlib/_tools/eslint/rules/first-unit-test/lib/main.js. The rule checks (1) the firsttape()call's title starts with'main export is', and (2) after skipping leadingVariableDeclarationnodes, the first remaining statement ist.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 obvioustypeof === 'function'assertion target.Checklist
AI Assistance
If you answered "yes" above, how did you use AI assistance?
Disclosure
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.jsand 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.