Skip to content

feat: port 3 @typescript-eslint prefer rules#462

Merged
fansenze merged 2 commits intomainfrom
feat/port-prefer-rules
Feb 9, 2026
Merged

feat: port 3 @typescript-eslint prefer rules#462
fansenze merged 2 commits intomainfrom
feat/port-prefer-rules

Conversation

@fansenze
Copy link
Copy Markdown
Contributor

@fansenze fansenze commented Feb 6, 2026

Summary

Port the following @typescript-eslint rules:

  • prefer-literal-enum-member: Ensures enum members use literal values only. Supports allowBitwiseExpressions option.
  • prefer-namespace-keyword: Suggests using namespace instead of module keyword. Auto-fixable.
  • prefer-string-starts-ends-with: Suggests using String#startsWith/endsWith instead of manual string comparison patterns (s[0], charAt, indexOf, lastIndexOf, match, slice, substring, RegExp.test). Auto-fixable with allowSingleElementEquality option.

Also fixes an IPC message length encoding bug in packages/rslint/src/node.ts — was using JS string length (UTF-16 code units) instead of UTF-8 byte length, causing protocol corruption with non-ASCII characters.

Additionally, improves the port-rule skill by adding persistent task tracking via TaskCreate/TaskUpdate, preventing progress loss during context compression.

Related Links

Checklist

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

@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello @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 ports three new rules from @typescript-eslint to enhance the rslint linter with more specific TypeScript linting capabilities. It also fixes a critical bug related to message encoding in the rslint node service, ensuring reliable communication across different character sets.

Highlights

  • New Rules: Introduces three new @typescript-eslint rules: prefer-literal-enum-member, prefer-namespace-keyword, and prefer-string-starts-ends-with.
  • Bug Fix: Addresses an issue in packages/rslint/src/node.ts related to IPC message length encoding, preventing protocol corruption with non-ASCII characters.
  • Auto-Fixes: The prefer-namespace-keyword and prefer-string-starts-ends-with rules are auto-fixable, improving code style and consistency.
Changelog
  • internal/config/config.go
    • Registers the new @typescript-eslint/prefer-literal-enum-member, @typescript-eslint/prefer-namespace-keyword, and @typescript-eslint/prefer-string-starts-ends-with rules.
    • Adds the corresponding rule implementations to the global rule registry.
  • internal/plugins/typescript/rules/prefer_literal_enum_member/prefer_literal_enum_member.go
    • Implements the prefer-literal-enum-member rule to enforce the use of literal values in enum members.
    • Provides an option to allow bitwise expressions in enum values.
  • internal/plugins/typescript/rules/prefer_literal_enum_member/prefer_literal_enum_member_test.go
    • Adds comprehensive test cases for the prefer-literal-enum-member rule, covering both valid and invalid scenarios.
  • internal/plugins/typescript/rules/prefer_namespace_keyword/prefer_namespace_keyword.go
    • Implements the prefer-namespace-keyword rule to suggest using namespace instead of module for TypeScript modules.
    • Includes auto-fix functionality to automatically replace module with namespace.
  • internal/plugins/typescript/rules/prefer_namespace_keyword/prefer_namespace_keyword_test.go
    • Adds test cases for the prefer-namespace-keyword rule, ensuring correct identification and auto-fixing of module declarations.
  • internal/plugins/typescript/rules/prefer_string_starts_ends_with/prefer_string_starts_ends_with.go
    • Implements the prefer-string-starts-ends-with rule to suggest using String#startsWith and String#endsWith methods.
    • Provides auto-fix functionality to replace manual string comparisons with the suggested methods.
    • Includes an option to allow single element equality comparisons.
  • internal/plugins/typescript/rules/prefer_string_starts_ends_with/prefer_string_starts_ends_with_test.go
    • Adds extensive test cases for the prefer-string-starts-ends-with rule, covering various string comparison patterns and options.
  • packages/rslint/src/node.ts
    • Fixes a bug in IPC message length encoding to correctly handle non-ASCII characters, preventing protocol corruption.
Activity
  • The pull request introduces three new TypeScript-specific linting rules, enhancing code quality and consistency.
  • A bug fix ensures that rslint can reliably handle a broader range of characters in IPC communication.
  • The new rules are accompanied by comprehensive test suites, ensuring their correct behavior and preventing regressions.
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 ports three new @typescript-eslint rules: prefer-literal-enum-member, prefer-namespace-keyword, and prefer-string-starts-ends-with. It also includes a bug fix for IPC message length encoding. The implementations for prefer-namespace-keyword and prefer-string-starts-ends-with are well done. However, I've found a correctness issue in prefer-literal-enum-member where it incorrectly allows non-literal values for enum members, contrary to the original rule's behavior. I've also suggested a minor refactoring in the IPC bug fix for better clarity. Overall, good work on porting these complex rules.

@fansenze fansenze force-pushed the feat/port-prefer-rules branch 2 times, most recently from d743b37 to f5fbe9b Compare February 6, 2026 07:07
@fansenze fansenze requested a review from hardfist February 6, 2026 07:08
- prefer-literal-enum-member
- prefer-namespace-keyword
- prefer-string-starts-ends-with
Require using TaskCreate/TaskUpdate for progress tracking throughout
the porting workflow, preventing task loss during context compression.
@fansenze fansenze force-pushed the feat/port-prefer-rules branch from f5fbe9b to ec513a6 Compare February 9, 2026 03:29
@fansenze fansenze merged commit d9042dc into main Feb 9, 2026
14 checks passed
@fansenze fansenze deleted the feat/port-prefer-rules branch February 9, 2026 03:51
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