Skip to content

feat: port eslint core rule no-ex-assign#485

Merged
fansenze merged 15 commits intoweb-infra-dev:mainfrom
eryue0220:feat/eslint-no-ex-assign
Mar 18, 2026
Merged

feat: port eslint core rule no-ex-assign#485
fansenze merged 15 commits intoweb-infra-dev:mainfrom
eryue0220:feat/eslint-no-ex-assign

Conversation

@eryue0220
Copy link
Copy Markdown
Contributor

Summary

Port 8 ESLint core rules to rslint.

Rules Ported

Rule Description Doc
no-ex-assign Disallow assign another value to the exception parameter a catch clause in a try statement link

Related Links

Related Issues: #223

Checklist

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

@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello @eryue0220, 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 the no-ex-assign rule, originally from ESLint, into the rslint project. This rule is crucial for maintaining code integrity by disallowing the reassignment of exception parameters in catch blocks, which can lead to loss of the original error context and introduce subtle bugs. The changes include the rule's core logic, comprehensive test cases, and user-facing documentation, ensuring robust error handling practices.

Highlights

  • New ESLint Rule Ported: The no-ex-assign core rule from ESLint has been ported to rslint, preventing reassignment of exception parameters within catch clauses.
  • Rule Implementation: The rule's logic has been implemented in Go, including functions to identify catch binding names and detect assignments to these names within the catch block.
  • Comprehensive Testing and Documentation: Dedicated Go unit tests, TypeScript rule tester tests, and detailed markdown documentation with examples have been added for the new rule.
Changelog
  • internal/config/config.go
    • Imported the no_ex_assign rule package.
    • Registered the no-ex-assign rule in the global rule registry.
  • internal/rules/no_ex_assign/no_ex_assign.go
    • Added the implementation for the no-ex-assign rule, including functions to collect catch binding names and check expressions for assignments to these names.
  • internal/rules/no_ex_assign/no_ex_assign.md
    • Added documentation for the no-ex-assign rule, explaining its purpose and providing correct and incorrect code examples.
  • internal/rules/no_ex_assign/no_ex_assign_test.go
    • Added Go-based unit tests for the no-ex-assign rule, covering valid and invalid code scenarios.
  • packages/rslint-test-tools/rstest.config.mts
    • Updated the test configuration to include the new no-ex-assign.test.ts file.
  • packages/rslint-test-tools/tests/eslint/rules/snapshots/no-ex-assign.test.ts.snap
    • Added snapshot test results for the no-ex-assign rule's invalid cases.
  • packages/rslint-test-tools/tests/eslint/rules/no-ex-assign.test.ts
    • Added TypeScript-based rule tester tests for the no-ex-assign rule, including valid and invalid code examples.
Activity
  • No specific activity (comments, reviews, or progress updates) has been recorded for this pull request yet.
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

@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

The pull request successfully ports the no-ex-assign ESLint core rule to rslint. The changes include adding the rule to the configuration, implementing the rule logic in no_ex_assign.go, and adding corresponding test cases and documentation. The implementation appears correct and follows the intent of the original ESLint rule. I've identified a few areas for improvement regarding the test cases and documentation examples.

@fansenze

This comment was marked as resolved.

Copy link
Copy Markdown
Contributor

@fansenze fansenze left a comment

Choose a reason for hiding this comment

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

Thanks for porting this rule and addressing the earlier feedback! I took another look at the full implementation and spotted a few remaining things — mostly around alignment with how no_class_assign and no_const_assign handle similar logic in this repo.

Copy link
Copy Markdown
Contributor

@fansenze fansenze left a comment

Choose a reason for hiding this comment

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

Thanks for the updates — great progress! Most of the earlier feedback has been addressed nicely. I noticed a few remaining things worth looking at before merging, mostly around edge cases in isInDestructuringAssignment and related helpers.

@fansenze fansenze merged commit 6eb70f2 into web-infra-dev:main Mar 18, 2026
10 checks passed
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