chore: fix JavaScript lint errors (issue #12434)#12435
Conversation
|
👋 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 |
|
Thank you for working on this pull request. However, we cannot accept your contribution as this pull request does not follow project conventions. We place a high value on consistency throughout the stdlib codebase, and this pull request was found to significantly deviate from stdlib conventions. We encourage you to closely examine other packages in stdlib and attempt to emulate the practices and conventions found therein.
In short, the more effort you put in to ensure that your contribution looks and feels like stdlib—including variables names, bracket spacing, line breaks, etc—the more likely that your contribution will be reviewed and ultimately accepted. We encourage you to closely study the codebase before continuing to work on this pull request. Thank you again for your interest in stdlib, and we look forward to reviewing your future contributions. |
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.