Skip to content

chore: fix JavaScript lint errors (issue #13273)#13278

Open
TrivCodez wants to merge 1 commit into
stdlib-js:developfrom
TrivCodez:fix/jsdoc-doctest-rename-example
Open

chore: fix JavaScript lint errors (issue #13273)#13278
TrivCodez wants to merge 1 commit into
stdlib-js:developfrom
TrivCodez:fix/jsdoc-doctest-rename-example

Conversation

@TrivCodez

@TrivCodez TrivCodez commented Jul 5, 2026

Copy link
Copy Markdown

Description

This PR fixes an ESLint crash caused by the stdlib/jsdoc-doctest rule when linting @stdlib/fs/rename/lib/index.js. The jsdoc-doctest rule runs JSDoc @example code in a VM context. The async rename() example used throw error in the callback, which, when the rename operation failed with ENOENT (file doesn't exist), threw an unhandled exception that crashed the ESLint process.

Changes

  • lib/node_modules/@stdlib/fs/rename/lib/index.js: Changed @example callbacks to use console.error(error.message) instead of throw 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

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
@TrivCodez TrivCodez requested a review from a team July 5, 2026 04:28
@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 Jul 5, 2026
@stdlib-bot

Copy link
Copy Markdown
Contributor

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:

  1. Please read our contributing guidelines.

  2. Update your pull request description to include this checked box:

    - [x] Read, understood, and followed the [contributing guidelines](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md)

This acknowledgment confirms that you've read the guidelines, which include:

  • The developer's certificate of origin
  • Your agreement to license your contributions under the project's terms

We can't review or accept contributions without this acknowledgment.

Thank you for your understanding and cooperation. We look forward to reviewing your contribution!

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