Skip to content

chore: fix JavaScript lint errors#13278

Merged
kgryte merged 1 commit into
stdlib-js:developfrom
TrivCodez:fix/jsdoc-doctest-rename-example
Jul 6, 2026
Merged

chore: fix JavaScript lint errors#13278
kgryte merged 1 commit into
stdlib-js:developfrom
TrivCodez:fix/jsdoc-doctest-rename-example

Conversation

@TrivCodez

@TrivCodez TrivCodez commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

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!

@kgryte kgryte added difficulty: 1 Low degree of difficulty. Should be straightforward to implement and/or resolve. review: 5 and removed Needs Review A pull request which needs code review. labels Jul 6, 2026
@stdlib-bot

Copy link
Copy Markdown
Contributor

Coverage Report

No coverage information available.

@kgryte kgryte changed the title chore: fix JavaScript lint errors (issue #13273) chore: fix JavaScript lint errors Jul 6, 2026
@kgryte kgryte merged commit 2eab69a into stdlib-js:develop Jul 6, 2026
105 of 106 checks passed
@kgryte

kgryte commented Jul 6, 2026

Copy link
Copy Markdown
Member

Thank you for your contribution and congratulations on your first PR!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

difficulty: 1 Low degree of difficulty. Should be straightforward to implement and/or resolve. 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. review: 5

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix JavaScript lint errors

3 participants