chore: fix JavaScript lint errors#13278
Conversation
The `stdlib/jsdoc-doctest` ESLint rule executes @example code in a VM. The async rename example calls `rename('./beep/boop.txt', './beep/foo.txt', done)` with a callback that throws the error. Since fs.rename is async, the callback fires after the VM context is gone, causing an unhandled Node.js exception that kills the ESLint process. Fix: change the error handling in examples from `throw` to `console.error(message)`, matching the pattern used by @stdlib/fs/unlink. resolves stdlib-js#13273
|
Hello! Thank you for your contribution to stdlib. We noticed that the contributing guidelines acknowledgment is missing from your pull request. Here's what you need to do:
This acknowledgment confirms that you've read the guidelines, which include:
We can't review or accept contributions without this acknowledgment. Thank you for your understanding and cooperation. We look forward to reviewing your contribution! |
Coverage ReportNo coverage information available. |
|
Thank you for your contribution and congratulations on your first PR! |
Description
This PR fixes an ESLint crash caused by the
stdlib/jsdoc-doctestrule when linting@stdlib/fs/rename/lib/index.js. Thejsdoc-doctestrule runs JSDoc@examplecode in a VM context. The asyncrename()example usedthrow errorin the callback, which, when the rename operation failed withENOENT(file doesn't exist), threw an unhandled exception that crashed the ESLint process.Changes
lib/node_modules/@stdlib/fs/rename/lib/index.js: Changed@examplecallbacks to useconsole.error(error.message)instead ofthrow error/throw err, matching the convention used by similar packages (e.g.,@stdlib/fs/unlink,@stdlib/fs/exists).This crash blocked ESLint from checking approximately 8 additional JavaScript files in the lint run.
resolves #13273