Skip to content

feat: port rule no-setter-return#525

Open
fansenze wants to merge 1 commit intomainfrom
feat/port-rule-no-setter-return-20260317
Open

feat: port rule no-setter-return#525
fansenze wants to merge 1 commit intomainfrom
feat/port-rule-no-setter-return-20260317

Conversation

@fansenze
Copy link
Copy Markdown
Contributor

@fansenze fansenze commented Mar 17, 2026

Summary

Port the no-setter-return rule from ESLint to rslint.

Disallow returning values from setters

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 a new linting rule to enforce best practices in JavaScript/TypeScript. The rule prevents developers from returning values from setter methods, which is a common source of confusion as return values from setters are silently ignored by the JavaScript engine. This enhancement improves code quality and helps catch potential bugs early.

Highlights

  • New Linting Rule: Implemented the no-setter-return rule, ported from ESLint, to disallow returning values from JavaScript/TypeScript setters.
Changelog
  • internal/config/config.go
    • Imported the no_setter_return package.
    • Registered the no-setter-return rule in the global registry.
  • internal/rules/no_setter_return/no_setter_return.go
    • Added the core implementation of the no-setter-return rule.
    • Included helper functions buildSetterMessage and findEnclosingSetter to detect and report violations.
  • internal/rules/no_setter_return/no_setter_return.md
    • Created comprehensive documentation for the no-setter-return rule.
    • Provided examples of both correct and incorrect code usage.
  • internal/rules/no_setter_return/no_setter_return_test.go
    • Implemented Go-based unit tests for the no-setter-return rule.
    • Covered various valid and invalid code scenarios to ensure rule correctness.
  • packages/rslint-test-tools/rstest.config.mts
    • Updated the test configuration to include the new no-setter-return rule's tests.
  • packages/rslint-test-tools/tests/eslint/rules/snapshots/no-setter-return.test.ts.snap
    • Generated snapshot test results for the no-setter-return rule, capturing expected diagnostic output.
  • packages/rslint-test-tools/tests/eslint/rules/no-setter-return.test.ts
    • Added JavaScript-based rule tester tests for the no-setter-return rule.
    • Defined valid and invalid code snippets for testing.
Activity
  • The author, fansenze, created this pull request to port the no-setter-return rule.
  • Tests and documentation have been updated as per the checklist in the PR description.
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-setter-return rule from ESLint. The implementation in Go is clean, correct, and adheres to the rule's logic of disallowing return values from setters while permitting bare returns for control flow. The accompanying tests are comprehensive, covering a good range of valid and invalid cases, and the documentation is clear. I've found one minor issue in the test configuration where a test file is included twice, which I've commented on. Overall, this is a solid contribution.

@fansenze fansenze force-pushed the feat/port-rule-no-setter-return-20260317 branch from 084ce73 to 8a34066 Compare March 17, 2026 10:29
@fansenze fansenze force-pushed the feat/port-rule-no-setter-return-20260317 branch 3 times, most recently from 65df7c8 to b7d9414 Compare March 18, 2026 02:59
@fansenze fansenze force-pushed the feat/port-rule-no-setter-return-20260317 branch from b7d9414 to 94f164c Compare March 18, 2026 03:11
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