Skip to content

feat: port rule prefer-rest-params#531

Open
fansenze wants to merge 1 commit intomainfrom
feat/port-rule-prefer-rest-params-20260317
Open

feat: port rule prefer-rest-params#531
fansenze wants to merge 1 commit intomainfrom
feat/port-rule-prefer-rest-params-20260317

Conversation

@fansenze
Copy link
Copy Markdown
Contributor

@fansenze fansenze commented Mar 17, 2026

Summary

Port the prefer-rest-params rule from ESLint to rslint.

Require rest parameters instead of arguments

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 the prefer-rest-params linting rule into rslint, promoting modern JavaScript syntax and best practices. By flagging the use of the arguments object in favor of rest parameters, the change aims to improve code clarity, maintainability, and leverage contemporary language features.

Highlights

  • New Linting Rule: The prefer-rest-params rule has been ported from ESLint to rslint.
  • Modern JavaScript Enforcement: This rule encourages the use of ES2015 rest parameters (...args) over the legacy arguments object for variadic functions.
Changelog
  • internal/config/config.go
    • Imported and registered the new prefer-rest-params rule into the global rule registry.
  • internal/rules/prefer_rest_params/prefer_rest_params.go
    • Implemented the core logic for the prefer-rest-params rule, including AST traversal and checks for arguments usage within functions, with various exclusion conditions.
  • internal/rules/prefer_rest_params/prefer_rest_params.md
    • Added comprehensive documentation for the prefer-rest-params rule, detailing its purpose, incorrect examples, and correct usage with rest parameters.
  • internal/rules/prefer_rest_params/prefer_rest_params_test.go
    • Introduced Go-based unit tests for the prefer-rest-params rule, verifying its behavior with both valid and invalid code snippets.
  • packages/rslint-test-tools/rstest.config.mts
    • Updated the test configuration to include the newly added prefer-rest-params test file.
  • packages/rslint-test-tools/tests/eslint/rules/snapshots/prefer-rest-params.test.ts.snap
    • Generated snapshot test results for the prefer-rest-params rule, capturing expected diagnostics for invalid code.
  • packages/rslint-test-tools/tests/eslint/rules/prefer-rest-params.test.ts
    • Added TypeScript-based test cases for the prefer-rest-params rule, defining scenarios to validate its linting behavior.
Activity
  • The author has confirmed that tests have been updated.
  • The author has confirmed that documentation has been updated.
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 prefer-rest-params rule from ESLint. The implementation is well-structured, but I found a correctness issue in the logic for detecting if the arguments object is shadowed. The current implementation doesn't account for var hoisting from nested blocks. I've provided detailed feedback on this in internal/rules/prefer_rest_params/prefer_rest_params.go. I've also suggested adding a new test case that would have caught this bug. The rest of the changes, including documentation and test configurations, look good.

@fansenze fansenze force-pushed the feat/port-rule-prefer-rest-params-20260317 branch from 2fed137 to be082ef Compare March 17, 2026 11:38
@fansenze fansenze force-pushed the feat/port-rule-prefer-rest-params-20260317 branch 2 times, most recently from 03ae7d2 to 67497ee Compare March 18, 2026 03:02
@fansenze fansenze force-pushed the feat/port-rule-prefer-rest-params-20260317 branch from 67497ee to 56102e9 Compare March 18, 2026 06:39
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