Conversation
Summary of ChangesHello @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 Highlights
Changelog
Activity
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
The pull request ports the @typescript-eslint/prefer-includes rule to the Go-based linter. The implementation correctly identifies indexOf comparisons and /regex/.test(str) calls that can be replaced with includes(). However, I identified a few critical issues in the auto-fix logic: specifically, incorrect range calculations when parentheses are present in indexOf checks, and an incorrect order of fix applications in the regex conversion logic. I also suggested adding a missing nil check for the type checker and improving numeric literal parsing to support non-decimal formats.
internal/plugins/typescript/rules/prefer_includes/prefer_includes.go
Outdated
Show resolved
Hide resolved
internal/plugins/typescript/rules/prefer_includes/prefer_includes.go
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Pull request overview
This pull request ports the @typescript-eslint/prefer-includes rule from the ScriptedAlchemy/rslint repository. The rule encourages the use of includes() method instead of indexOf() comparisons (like indexOf() !== -1), and also suggests using String#includes() instead of simple regex patterns with .test() when appropriate. This leads to more readable and expressive code.
Changes:
- Implemented the
prefer-includesrule in Go with comprehensive type checking and auto-fix capabilities - Added test coverage in both TypeScript and Go test files with multiple edge cases
- Enabled the rule in test configuration and registered it in the global rule registry
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| rslint.json | Added rule configuration (set to "off" by default) |
| packages/rslint-test-tools/tests/typescript-eslint/rules/prefer-includes.test.ts | Added valid and invalid test cases including edge cases for optional chaining, regex patterns, and type arrays |
| packages/rslint-test-tools/tests/typescript-eslint/rules/snapshots/prefer-includes.test.ts.snap | New snapshot file containing expected diagnostic outputs for all test cases |
| packages/rslint-test-tools/rstest.config.mts | Enabled the prefer-includes test file in test configuration |
| internal/plugins/typescript/rules/prefer_includes/prefer_includes_test.go | Go test implementation with key test cases |
| internal/plugins/typescript/rules/prefer_includes/prefer_includes.md | Documentation explaining the rule with examples |
| internal/plugins/typescript/rules/prefer_includes/prefer_includes.go | Core implementation with logic for detecting indexOf comparisons and regex patterns, including auto-fix generation |
| internal/config/config.go | Imported and registered the new rule in the global rule registry |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ed912357d6
ℹ️ 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".
Summary: Port @typescript-eslint/prefer-includes from ScriptedAlchemy#13.
Related Links:
Checklist: