feat: port rule @typescript-eslint/no-inferrable-types#449
Conversation
Summary of ChangesHello @fansenze, 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 a new TypeScript ESLint rule into the rslint project, focusing on code style and maintainability. The primary goal is to eliminate unnecessary type annotations that TypeScript can infer, thereby making the codebase cleaner and more concise. This enhancement not only adds a valuable linting check but also improves the underlying reporting mechanism to better support automated code corrections. Highlights
Using Gemini Code AssistThe 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
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 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
|
There was a problem hiding this comment.
Code Review
This pull request ports the @typescript-eslint/no-inferrable-types rule to rslint. The implementation is comprehensive, covering various inferrable types, expressions, and rule options. The changes include the rule logic, extensive tests, documentation, and necessary adjustments to the linter's rule context. The code is well-structured and follows existing patterns. I have one minor suggestion to improve clarity in the test code.
internal/plugins/typescript/rules/no_inferrable_types/no_inferrable_types_test.go
Outdated
Show resolved
Hide resolved
b27f9cb to
a0710f8
Compare
… with JS/official suite - Add prefer_readonly.md documentation file following PR #449 pattern - Expand Go test cases from 48 to 158 (76 valid + 82 invalid), fully aligned with JS/official test suite - Cover all missing patterns: # private fields, optional chaining, non-null assertions, nested property access, method calls, enum/literal/null/Promise type widening, ClassWithName, conditional constructors, etc.
This rule disallows explicit type declarations for variables or parameters initialized to a number, string, boolean, or other primitives that TypeScript can automatically infer. Features: - Supports all inferrable types: bigint, boolean, number, null, RegExp, string, symbol, undefined - Handles function calls (BigInt, Boolean, Number, String, Symbol, RegExp) - Handles unary expressions (!, +, -) - Handles void expressions - Options: ignoreParameters, ignoreProperties - Properly handles readonly properties (skipped) - Properly handles optional properties with ? (skipped) - Properly handles definite assignment assertion (!) - Properly handles auto-accessor properties with accessor keyword - Includes auto-fix to remove redundant type annotations - Added ReportRangeWithFixes to rule context for custom range reporting
a0710f8 to
36f6ced
Compare
Summary
Port the
@typescript-eslint/no-inferrable-typesrule to rslint.This rule disallows explicit type declarations for variables or parameters initialized to a number, string, boolean, or other primitives that TypeScript can automatically infer.
Features
ignoreParameters,ignoreProperties?(skipped)!)accessorkeywordInfrastructure Changes
ReportRangeWithFixesto rule context for custom range reporting with fixesRelated Links
Checklist