Skip to content

@typescript-eslint/max-params#480

Open
ScriptedAlchemy wants to merge 22 commits intomainfrom
codex/ts-eslint-max-params-ac37
Open

@typescript-eslint/max-params#480
ScriptedAlchemy wants to merge 22 commits intomainfrom
codex/ts-eslint-max-params-ac37

Conversation

@ScriptedAlchemy
Copy link
Copy Markdown
Contributor

Summary: Port @typescript-eslint/max-params from ScriptedAlchemy#13.

Related Links:

Checklist:

  • Tests updated
  • Documentation updated (rule md)

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @ScriptedAlchemy, 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 @typescript-eslint/max-params rule into the linter, enhancing code quality by limiting the number of parameters in functions. This addition helps maintain cleaner, more readable, and testable code by preventing overly complex function signatures. The rule is fully tested and documented, providing a robust new check for TypeScript projects.

Highlights

  • New Rule Added: The @typescript-eslint/max-params rule has been introduced, enforcing a maximum number of parameters in function-like declarations.
  • Rule Configuration: The new rule includes configurable options for max (defaulting to 3) and countVoidThis (defaulting to false), allowing flexibility in parameter counting.
  • Comprehensive Testing: Extensive unit tests and snapshot tests have been added to validate the rule's behavior across various function types and configurations.
  • Documentation: Dedicated documentation for the max-params rule has been created, including examples of correct and incorrect code usage.
  • Default State: The @typescript-eslint/max-params rule is initially configured as 'off' in the rslint.json file, allowing users to enable it explicitly.
Changelog
  • internal/config/config.go
    • Imported the new max_params rule package.
    • Registered the @typescript-eslint/max-params rule in the global rule registry.
  • internal/plugins/typescript/rules/max_params/max_params.go
    • Added the core implementation for the max-params rule.
    • Included MaxParamsOptions struct for rule configuration.
    • Implemented parseNumericOption and parseOptions functions for handling rule options.
    • Developed isVoidThisParameter helper to identify this: void parameters.
    • Created buildExceedMessage for consistent error reporting.
    • Defined the MaxParamsRule with listeners for various AST node kinds (functions, methods, accessors, signatures) to check parameter counts.
  • internal/plugins/typescript/rules/max_params/max_params.md
    • Added documentation for the max-params rule.
    • Provided examples of both incorrect and correct code for the rule.
  • internal/plugins/typescript/rules/max_params/max_params_test.go
    • Added unit tests for the max-params rule.
    • Included ValidTestCase scenarios covering functions with acceptable parameter counts and various rule options.
    • Included InvalidTestCase scenarios demonstrating functions exceeding parameter limits and different rule configurations.
  • packages/rslint-test-tools/rstest.config.mts
    • Uncommented the entry to enable the max-params.test.ts file in the test configuration.
  • packages/rslint-test-tools/tests/typescript-eslint/rules/snapshots/max-params.test.ts.snap
    • Added snapshot test results for the max-params rule's invalid cases.
  • rslint.json
    • Added the @typescript-eslint/max-params rule to the default configuration, setting its severity to 'off'.
Activity
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

The pull request successfully ports the @typescript-eslint/max-params rule to the linter. The implementation is robust, covering a wide range of function-like nodes and correctly handling the special this: void parameter in TypeScript through the countVoidThis option. The unit tests are comprehensive, and the documentation is clear. I have provided one suggestion to simplify the options parsing logic by removing redundant type checks.

@ScriptedAlchemy ScriptedAlchemy marked this pull request as ready for review February 26, 2026 03:45
Copilot AI review requested due to automatic review settings February 26, 2026 03:45
@ScriptedAlchemy ScriptedAlchemy enabled auto-merge (squash) February 26, 2026 03:47
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Ports the @typescript-eslint/max-params rule into the TypeScript plugin, wiring it into the global registry and enabling its test runner coverage.

Changes:

  • Added a new TypeScript rule implementation for @typescript-eslint/max-params with option parsing and diagnostics.
  • Added Go rule tests plus rstest snapshots, and enabled the TypeScript rule test file in rstest.config.mts.
  • Registered the rule in the global config registry and updated rslint.json defaults.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
rslint.json Adds the new rule to the repo config (currently disabled).
packages/rslint-test-tools/rstest.config.mts Enables the TypeScript rule test file for max-params.
packages/rslint-test-tools/tests/typescript-eslint/rules/snapshots/max-params.test.ts.snap Adds snapshots for the new rule’s diagnostics.
internal/plugins/typescript/rules/max_params/max_params.go Implements the rule logic, option parsing, and reporting.
internal/plugins/typescript/rules/max_params/max_params_test.go Adds Go-side rule tests for valid/invalid cases and options.
internal/plugins/typescript/rules/max_params/max_params.md Adds rule documentation page.
internal/config/config.go Registers @typescript-eslint/max-params in the global rule registry.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +81 to +99
{
Code: `
interface Foo {
method(a: number, b: number, c: number, d: number): void;
}
`,
},
{
Code: `
type CallSig = {
(a: number, b: number, c: number, d: number): void;
};
`,
},
{
Code: `
type Ctor = new (a: number, b: number, c: number, d: number) => Foo;
`,
},
Copy link

Copilot AI Feb 26, 2026

Choose a reason for hiding this comment

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

These “valid” cases include interface/type signatures with 4 parameters while the default max is 3. Given the current listener list, they won’t be checked at all, so this test may be accidentally encoding a coverage gap. Either add coverage + listeners for the relevant TS signature node kinds (and move these to invalid), or remove them and clarify that the rule only targets runtime functions.

Suggested change
{
Code: `
interface Foo {
method(a: number, b: number, c: number, d: number): void;
}
`,
},
{
Code: `
type CallSig = {
(a: number, b: number, c: number, d: number): void;
};
`,
},
{
Code: `
type Ctor = new (a: number, b: number, c: number, d: number) => Foo;
`,
},

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 94ffd147f3

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages bot commented Mar 3, 2026

Deploying rslint with  Cloudflare Pages  Cloudflare Pages

Latest commit: a63a0ec
Status: ✅  Deploy successful!
Preview URL: https://9351beda.rslint.pages.dev
Branch Preview URL: https://codex-ts-eslint-max-params-a.rslint.pages.dev

View logs

func buildExceedMessage(count int, maxCount int) rule.RuleMessage {
return rule.RuleMessage{
Id: "exceed",
Description: fmt.Sprintf("Function has too many parameters (%d). Maximum allowed is %d.", count, maxCount),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The original ESLint core max-params rule uses a dynamic name in the message — e.g. "Function 'foo'...", "Arrow function...", "Method 'bar'..." depending on the function type. Currently this is hardcoded as "Function" for all cases.

It might be worth generating the appropriate name based on the node kind to stay consistent with the upstream behavior. Something like:

  • KindFunctionDeclarationFunction 'name'
  • KindArrowFunctionArrow function
  • KindMethodDeclarationMethod 'name'
  • KindConstructorConstructor
  • KindGetAccessorGetter 'name'
  • KindSetAccessorSetter 'name'
  • KindFunctionTypeFunction type

Not a blocker, but would be nice to align!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants