Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: fix JavaScript lint errors #6029

Merged
merged 4 commits into from
Mar 17, 2025
Merged

Conversation

JaySoni1
Copy link
Contributor

@JaySoni1 JaySoni1 commented Mar 13, 2025

Summary

This pull request fixes JavaScript lint errors identified in the automated JavaScript lint workflow.

Files Modified

  1. lib/node_modules/@stdlib/utils/get-prototype-of/lib/polyfill.js
  2. lib/node_modules/@stdlib/_tools/pkgs/deps/lib/sync.js

Details of Changes

1. polyfill.js

  • Problem: Object was used without being loaded via require().

  • Lint Error:
    /home/runner/work/stdlib/stdlib/lib/node_modules/@stdlib/utils/get-prototype-of/lib/polyfill.js
    45:22 error Object is used without loading it beforehand via require() stdlib/require-globals

  • Fix: Added the required require statement for Object.

Changes Made:

// Add this at the top with other requires
var Object = require( '@stdlib/utils/global-object' );

// Lines 45-46 updated as:
if ( obj instanceof Object ) {
    return Object.prototype;
}

2. sync.js

  • Problem: JSDoc example incorrectly showed a return example for a scenario that throws an error.

  • Lint Error:
    /home/runner/work/stdlib/stdlib/lib/node_modules/@stdlib/_tools/pkgs/deps/lib/sync.js
    43:1 error Encountered an error while running code: Cannot find module '/foo/bar/baz'. Did you mean to include a // throws <Error> annotation instead of // returns [{...}]? stdlib/jsdoc-doctest

  • Fix: Updated the JSDoc example annotation to correctly indicate an error is thrown.

Changes Made:

/**
* @example
* var pkgs = [ '/foo/bar/baz' ];
* // throws <Error>
* var deps = pkgDeps( pkgs );
*/

Checklist ✅

  • Read, understood, and followed the contributing guidelines
  • Fixed all linting errors mentioned in Fix JavaScript lint errors #6004
  • Ran npm test locally and all tests passed successfully
  • Ensured there are no breaking changes
  • PR addresses both identified lint errors in polyfill.js and sync.js

Related Issues


Additional Notes

  • If there’s any feedback, happy to address it.
  • Thank you for reviewing my contribution!

 Object is available globally in JS, this rule enforces explicit require() to ensure compatibility and clarity.

Signed-off-by: JaySoni1 <jaygsoni14@gmail.com>
The linter suggests you should add a // throws <Error> comment to indicate the example throws an error, instead of pretending it returns an object.

Signed-off-by: JaySoni1 <jaygsoni14@gmail.com>
@stdlib-bot stdlib-bot added First-time Contributor A pull request from a contributor who has never previously committed to the project repository. Needs Review A pull request which needs code review. labels Mar 13, 2025
@stdlib-bot
Copy link
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!

@stdlib-bot stdlib-bot added the Good First PR A pull request resolving a Good First Issue. label Mar 13, 2025
@stdlib-bot
Copy link
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!

Signed-off-by: Athan <kgryte@gmail.com>
Signed-off-by: Athan <kgryte@gmail.com>
@kgryte kgryte changed the title fix: resolve JavaScript lint errors in polyfill.js and sync.js (#6004) chore: fix JavaScript lint errors Mar 17, 2025
@kgryte kgryte changed the title chore: fix JavaScript lint errors chore: fix JavaScript lint errors Mar 17, 2025
@kgryte kgryte removed the Needs Review A pull request which needs code review. label Mar 17, 2025
@kgryte
Copy link
Member

kgryte commented Mar 17, 2025

As the CI failure does not stem from changes introduced in this PR and tests pass, I'll go ahead and merge.

@kgryte kgryte merged commit 09d4050 into stdlib-js:develop Mar 17, 2025
16 of 19 checks passed
@kgryte kgryte mentioned this pull request Mar 17, 2025
1 task
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix JavaScript lint errors
3 participants