Skip to content

fix: align no-unused-vars with typescript-eslint#571

Merged
fansenze merged 1 commit intomainfrom
fix/no-unused-vars-20260326
Mar 27, 2026
Merged

fix: align no-unused-vars with typescript-eslint#571
fansenze merged 1 commit intomainfrom
fix/no-unused-vars-20260326

Conversation

@fansenze
Copy link
Copy Markdown
Contributor

@fansenze fansenze commented Mar 26, 2026

Summary

  • Align @typescript-eslint/no-unused-vars rule with the original typescript-eslint implementation
  • Add isUpdateTarget() helper to correctly track ++/-- as write references, fixing report positions and message text
  • Update recommended config to ignore _-prefixed variables and arguments (varsIgnorePattern: ^_, argsIgnorePattern: ^_), aligning with community convention
  • Split monolithic Go test file into 5 focused test files by dimension: core, typescript-specific, patterns, assignments, imports
  • Split monolithic TS test file into 7 focused test files: basic, advanced, catch-loops, patterns, report-used, declare, and the main TS-specific tests
  • Add ~130 new Go test cases and ~200 new TS test cases covering previously untested edge cases

Related Links

N/A

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 significantly enhances the no-unused-vars rule for TypeScript by bringing its behavior closer to the official TypeScript ESLint implementation. The changes improve the rule's accuracy in detecting unused variables, especially in complex scenarios involving assignments, destructuring, and type-only usages. The extensive test refactoring and addition of new test cases ensure robust and comprehensive coverage of various code patterns.

Highlights

  • Rule Alignment: Aligned the @typescript-eslint/no-unused-vars rule with the original TypeScript ESLint implementation for improved accuracy.
  • Usage Tracking: Introduced the isUpdateTarget() helper to correctly track increment/decrement operations (++/--) as write references, enhancing report positions and message text.
  • Test Refactoring: Refactored Go test files into 5 focused categories (core, TypeScript-specific, patterns, assignments, imports) and TypeScript test files into 7 focused categories (basic, advanced, catch-loops, patterns, report-used, declare, and main TS-specific tests).
  • Expanded Test Coverage: Added approximately 130 new Go test cases and 200 new TypeScript test cases to cover previously untested edge cases and ensure robustness.
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.

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 introduces a comprehensive overhaul of the no-unused-vars linting rule for TypeScript. The update significantly enhances the rule's accuracy and configurability by adding new options such as destructuredArrayIgnorePattern, ignoreClassWithStaticInitBlock, ignoreUsingDeclarations, and enableAutofixRemoval for unused imports. Key changes include a refactored usage detection logic that differentiates between 'defined but never used' and 'assigned a value but never used', improved handling of self-modifying references, declaration merging, ambient modules, and JSX factory imports. The update also provides autofix suggestions for removing unused imports and expands test coverage across various scenarios, including assignments, imports, patterns, and TypeScript-specific constructs. The default configuration for the rule has been updated to ignore variables and arguments starting with an underscore.

@fansenze fansenze force-pushed the fix/no-unused-vars-20260326 branch 3 times, most recently from a1fb56c to 8cce2f5 Compare March 26, 2026 11:08
- Implement full no-unused-vars rule with self-modifying reference detection,
  declaration merging, ambient module handling, and JSX factory usage tracking
- Support JSX factory/fragment factory imports for preserve/react-native modes
  with custom jsxFactory and jsxFragmentFactory compiler options
- Add import removal autofix with suggestions for unused imports
- Update recommended config to ignore variables and arguments prefixed with
  underscore (varsIgnorePattern: ^_, argsIgnorePattern: ^_), aligning with
  community convention
- Split large test file into focused test suites (basic, advanced, catch-loops,
  patterns, report-used, declare, typescript-specific)
- Add tsconfig fixtures for JSX modes (preserve, react-jsx, custom factory,
  fragment factory) and lenient type checking
- Update rule documentation with full options reference and TypeScript-specific
  behavior description
@fansenze fansenze force-pushed the fix/no-unused-vars-20260326 branch from 8cce2f5 to 50919e2 Compare March 26, 2026 11:25
@fansenze fansenze merged commit 480ccdd into main Mar 27, 2026
10 checks passed
@fansenze fansenze deleted the fix/no-unused-vars-20260326 branch March 27, 2026 02:43
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