Skip to content

feat: port rule no-new-wrappers#530

Merged
chenjiahan merged 1 commit intomainfrom
feat/port-rule-no-new-wrappers-20260317
Apr 3, 2026
Merged

feat: port rule no-new-wrappers#530
chenjiahan merged 1 commit intomainfrom
feat/port-rule-no-new-wrappers-20260317

Conversation

@fansenze
Copy link
Copy Markdown
Contributor

@fansenze fansenze commented Mar 17, 2026

Summary

Port the no-new-wrappers rule from ESLint to rslint.

Disallow new operators with the String, Number, and Boolean functions

Related Links

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces the no-new-wrappers rule, a direct port from ESLint, to prevent the misuse of primitive wrapper objects in JavaScript. By disallowing the new operator with String, Number, and Boolean constructors, it helps developers avoid common pitfalls associated with the differing behavior of primitive wrappers versus their primitive counterparts, promoting more robust and predictable code.

Highlights

  • New Rule Ported: The no-new-wrappers rule has been ported from ESLint to rslint.
  • Functionality: This rule disallows the use of the new operator with the String, Number, and Boolean functions as constructors, promoting better JavaScript practices.
  • Documentation and Testing: Comprehensive documentation and both Go-based and JavaScript-based tests have been added for the new rule to ensure its correctness and provide clear usage guidelines.
Changelog
  • internal/config/config.go
    • Imported the no_new_wrappers package.
    • Registered the no-new-wrappers rule in the global registry.
  • internal/rules/no_new_wrappers/no_new_wrappers.go
    • Implemented the core logic for the no-new-wrappers rule.
  • internal/rules/no_new_wrappers/no_new_wrappers.md
    • Created detailed documentation for the no-new-wrappers rule.
  • internal/rules/no_new_wrappers/no_new_wrappers_test.go
    • Added Go-based unit tests for the no-new-wrappers rule.
  • packages/rslint-test-tools/rstest.config.mts
    • Updated the test configuration to include the new no-new-wrappers test file.
  • packages/rslint-test-tools/tests/eslint/rules/snapshots/no-new-wrappers.test.ts.snap
    • Generated snapshot tests for the no-new-wrappers rule.
  • packages/rslint-test-tools/tests/eslint/rules/no-new-wrappers.test.ts
    • Added JavaScript-based test cases for the no-new-wrappers rule using RuleTester.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request successfully ports the no-new-wrappers rule from ESLint to rslint. The changes are well-structured, including the rule implementation, tests, and documentation. I have one minor suggestion to improve the Go code by defining a map at the package level to avoid re-initialization, which is a common practice for performance and code clarity.

Comment thread internal/rules/no_new_wrappers/no_new_wrappers.go Outdated
@fansenze fansenze force-pushed the feat/port-rule-no-new-wrappers-20260317 branch 2 times, most recently from e05e81a to 72a04f5 Compare March 17, 2026 11:09
@fansenze fansenze force-pushed the feat/port-rule-no-new-wrappers-20260317 branch from 72a04f5 to 95eb0fd Compare March 18, 2026 03:02
@fansenze fansenze force-pushed the feat/port-rule-no-new-wrappers-20260317 branch from 95eb0fd to c92a7db Compare April 3, 2026 01:55
@chenjiahan chenjiahan merged commit dca5410 into main Apr 3, 2026
10 checks passed
@chenjiahan chenjiahan deleted the feat/port-rule-no-new-wrappers-20260317 branch April 3, 2026 02:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants