Skip to content

fix: align rule implementations with typescript-eslint#502

Merged
fansenze merged 1 commit intomainfrom
fix/rule-alignment-20260311
Mar 11, 2026
Merged

fix: align rule implementations with typescript-eslint#502
fansenze merged 1 commit intomainfrom
fix/rule-alignment-20260311

Conversation

@fansenze
Copy link
Copy Markdown
Contributor

@fansenze fansenze commented Mar 11, 2026

Summary

  • no-invalid-void-type: Fix false positives for void in generic type arguments, default type parameters, and heritage clauses (extends/implements). Add overload signature detection (hasOverloadSignatures). Support allowAsThisParameter and whitelist-based allowInGenericTypeArguments options.
  • consistent-type-definitions: Add autofix for typeinterface conversion, handling export, declare, type parameters, extends→intersection, export default interface splitting, and parenthesized types. Fix missing detection for index signature types. Fix isInDeclareGlobal to properly check for declare keyword modifier.
  • only-throw-error: Add allowRethrowing option support. Add typeMatchesSpecifier utility for type specifier matching.
  • ban-ts-comment: Fix description length calculation to include colon/dash separators per original typescript-eslint behavior. Fix message ID for too-short description reports.
  • Add comprehensive Go and JS tests for all rules with edge cases.
  • Update rule documentation to reflect new behavior and options.

Related Links

Checklist

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

@gemini-code-assist
Copy link
Copy Markdown

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 enhances the rslint TypeScript plugin by updating and improving three key rules to maintain better compatibility with typescript-eslint. These changes include bug fixes, new features, and improved documentation, ensuring more accurate and customizable linting for TypeScript code.

Highlights

  • Rule Updates: This PR updates three rules: no-invalid-void-type, consistent-type-definitions, and only-throw-error to align with typescript-eslint.
  • Enhancements and Fixes: The PR includes fixes for false positives, adds new options for customization, and introduces autofixes for certain rules.
  • Testing and Documentation: Comprehensive Go and JS tests have been added for all three rules, covering edge cases. Rule documentation has been updated to reflect new behavior and options.
Changelog
  • internal/plugins/typescript/rules/consistent_type_definitions/consistent_type_definitions.go
    • Refactors code for converting type aliases to interfaces, handling modifiers, type parameters, and comments.
    • Improves detection of interfaces within declare global blocks.
    • Adds logic to handle export default interface conversions.
  • internal/plugins/typescript/rules/consistent_type_definitions/consistent_type_definitions.md
    • Updates documentation to reflect autofix capabilities and behavior of consistent-type-definitions rule.
    • Adds examples of incorrect and correct code for both interface and type options.
  • internal/plugins/typescript/rules/consistent_type_definitions/consistent_type_definitions_test.go
    • Adds new test cases for consistent-type-definitions rule, covering various scenarios including index signatures, comments, whitespace, and export declare.
  • internal/plugins/typescript/rules/no_invalid_void_type/no_invalid_void_type.go
    • Implements overload signature detection for no-invalid-void-type.
    • Adds support for allowAsThisParameter and whitelist-based allowInGenericTypeArguments options.
    • Fixes false positives for void in generic type arguments, default type parameters, and heritage clauses.
  • internal/plugins/typescript/rules/no_invalid_void_type/no_invalid_void_type.md
    • Updates documentation for no-invalid-void-type to include new options and behaviors.
    • Adds examples for allowInGenericTypeArguments and allowAsThisParameter options.
  • internal/plugins/typescript/rules/no_invalid_void_type/no_invalid_void_type_test.go
    • Adds numerous test cases for no-invalid-void-type covering various scenarios and options.
  • internal/plugins/typescript/rules/only_throw_error/only_throw_error.go
    • Adds allowRethrowing option support to only-throw-error.
    • Adds typeMatchesSpecifier utility for type specifier matching.
  • internal/plugins/typescript/rules/only_throw_error/only_throw_error_test.go
    • Adds new test cases for only-throw-error including rethrowing and generic union types.
  • internal/utils/type_matches_specifier.go
    • Adds TypeOrValueSpecifierFromString to TypeOrValueSpecifierFrom enum.
    • Adds UnmarshalJSON method to TypeOrValueSpecifier to handle string shorthand.
    • Handles union types in typeMatchesStringSpecifierWithCalleeNames and typeMatchesSpecifier.
  • packages/rslint-test-tools/rstest.config.mts
    • Enables no-invalid-void-type.test.ts and only-throw-error.test.ts in rstest configuration.
  • packages/rslint-test-tools/tests/typescript-eslint/rules/snapshots/consistent-type-definitions.test.ts.snap
    • Updates snapshot for consistent-type-definitions.test.ts.
  • packages/rslint-test-tools/tests/typescript-eslint/rules/snapshots/no-invalid-void-type.test.ts.snap
    • Adds snapshot for no-invalid-void-type.test.ts.
  • packages/rslint-test-tools/tests/typescript-eslint/rules/snapshots/only-throw-error.test.ts.snap
    • Adds snapshot for only-throw-error.test.ts.
Activity
  • fansenze updated tests and documentation for the updated rules.
  • fansenze added new options and fixed false positives in the rules.
  • fansenze aligned the rules with typescript-eslint.
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

This pull request significantly improves three linting rules (no-invalid-void-type, consistent-type-definitions, and only-throw-error) to better align with their typescript-eslint counterparts. The changes are substantial and well-implemented, including new rule options, robust autofixing capabilities, and more precise type checking logic. The Go implementation is well-structured, and the accompanying test suites have been impressively expanded to cover a wide range of edge cases. I've identified one minor issue in the autofix logic for consistent-type-definitions where single-line comments may not be preserved, but overall this is an excellent contribution.

Note: Security Review did not run due to the size of the PR.

@fansenze fansenze force-pushed the fix/rule-alignment-20260311 branch 2 times, most recently from ff9a89a to 861a118 Compare March 11, 2026 07:19
…row-error and ban-ts-comment with typescript-eslint

- no-invalid-void-type: fix false positives for void in generic type arguments,
  default type parameters, and heritage clauses (extends/implements); add
  overload signature detection; support allowAsThisParameter and whitelist options
- consistent-type-definitions: add autofix for type/interface conversion;
  fix missing detection for index signature types; fix isInDeclareGlobal to
  check for declare keyword modifier
- only-throw-error: add allowRethrowing option support; add type specifier
  matching utility
- ban-ts-comment: fix description length calculation to include colon/dash
  separators per original typescript-eslint behavior; fix message ID for
  too-short descriptions
- Add comprehensive Go and JS tests for all rules
- Update rule documentation
@fansenze fansenze force-pushed the fix/rule-alignment-20260311 branch from 861a118 to 80252ae Compare March 11, 2026 07:46
@fansenze fansenze changed the title fix: align no-invalid-void-type, consistent-type-definitions and only-throw-error with typescript-eslint fix: align rule implementations with typescript-eslint Mar 11, 2026
@fansenze fansenze merged commit 7304258 into main Mar 11, 2026
16 checks passed
@fansenze fansenze deleted the fix/rule-alignment-20260311 branch March 11, 2026 08:06
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