Skip to content

feat: port rule no-self-assign#534

Open
fansenze wants to merge 1 commit intomainfrom
feat/port-rule-no-self-assign-20260317
Open

feat: port rule no-self-assign#534
fansenze wants to merge 1 commit intomainfrom
feat/port-rule-no-self-assign-20260317

Conversation

@fansenze
Copy link
Copy Markdown
Contributor

@fansenze fansenze commented Mar 17, 2026

Summary

Port the no-self-assign rule from ESLint to rslint.

Disallow assignments where both sides are exactly the same

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 integrates a new no-self-assign linting rule into the rslint project. The rule aims to catch potential programming errors or incomplete refactorings where a value is assigned to itself, which typically has no effect. The implementation is robust, handling various JavaScript assignment patterns and offering a configurable option for property-based self-assignments.

Highlights

  • New Linting Rule: Ported the no-self-assign rule from ESLint to rslint, which disallows assignments where both sides are exactly the same.
  • Comprehensive Self-Assignment Detection: The rule detects self-assignments across various expression types, including identifiers, array and object destructuring, property access, element access, and the this keyword.
  • Configurable Property Checks: Introduced a props option (defaulting to true) to control whether member expression self-assignments (e.g., a.b = a.b) are checked.
Changelog
  • internal/config/config.go
    • Imported the no_self_assign rule package.
    • Registered the no-self-assign rule in the global rule registry.
  • internal/rules/no_self_assign/no_self_assign.go
    • Added the core implementation for the no-self-assign rule.
    • Implemented logic to detect self-assignments for identifiers, array/object destructuring, property access, element access, and this keywords.
    • Included an option parser for the props configuration.
  • internal/rules/no_self_assign/no_self_assign.md
    • Added documentation for the no-self-assign rule.
    • Provided examples of correct and incorrect code.
    • Detailed the props option for the rule.
  • internal/rules/no_self_assign/no_self_assign_test.go
    • Added comprehensive unit tests for the no-self-assign rule.
    • Included test cases for valid and invalid self-assignments, covering various expression types and logical assignment operators.
    • Tested the props option functionality.
  • packages/rslint-test-tools/rstest.config.mts
    • Updated the test configuration to include the new no-self-assign.test.ts file.
  • packages/rslint-test-tools/tests/eslint/rules/snapshots/no-self-assign.test.ts.snap
    • Added snapshot test results for the no-self-assign rule.
  • packages/rslint-test-tools/tests/eslint/rules/no-self-assign.test.ts
    • Added a new test file for the no-self-assign rule using the RuleTester.
Activity
  • The author, fansenze, created this pull request to port the no-self-assign rule.
  • Tests have been updated to cover the new rule's functionality.
  • Documentation for the new rule has been added.
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 ports the no-self-assign rule from ESLint. The implementation is a good start, but there's a significant issue in handling object destructuring assignments with spread syntax on the right-hand side, which can lead to incorrect linting results. Additionally, the test suite for the new rule could be improved by adding cases for object destructuring. My review includes specific feedback on these points.

@fansenze fansenze force-pushed the feat/port-rule-no-self-assign-20260317 branch 3 times, most recently from c1a9848 to 872b355 Compare March 17, 2026 11:20
@fansenze fansenze force-pushed the feat/port-rule-no-self-assign-20260317 branch 2 times, most recently from 9480a8b to 869b125 Compare March 18, 2026 03:23
@fansenze fansenze force-pushed the feat/port-rule-no-self-assign-20260317 branch from 869b125 to eb25ba6 Compare March 18, 2026 03:43
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.

1 participant