Skip to content

@typescript-eslint/prefer-ts-expect-error#484

Open
ScriptedAlchemy wants to merge 5 commits intomainfrom
codex/ts-eslint-prefer-ts-expect-error-57f3
Open

@typescript-eslint/prefer-ts-expect-error#484
ScriptedAlchemy wants to merge 5 commits intomainfrom
codex/ts-eslint-prefer-ts-expect-error-57f3

Conversation

@ScriptedAlchemy
Copy link
Contributor

Summary: Port @typescript-eslint/prefer-ts-expect-error from ScriptedAlchemy#13.

Related Links:

Checklist:

  • Tests updated
  • Documentation updated (rule md)

@gemini-code-assist
Copy link

Summary of Changes

Hello @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 @typescript-eslint/prefer-ts-expect-error rule into the linter. This enhancement aims to improve the precision of TypeScript error suppression by promoting the use of @ts-expect-error over the less specific @ts-ignore, thereby making codebases more maintainable and type-safe. The rule is designed to automatically suggest and apply the correct directive.

Highlights

  • New Rule Implementation: Implemented the @typescript-eslint/prefer-ts-expect-error rule, which suggests using @ts-expect-error instead of @ts-ignore for better clarity and type safety.
  • Auto-Fix Capability: The new rule includes an automatic fix to replace @ts-ignore comments with @ts-expect-error.
  • Rule Registration and Configuration: The prefer-ts-expect-error rule has been registered in the linter's configuration and is initially set to 'off' in rslint.json.
  • Comprehensive Testing and Documentation: Dedicated unit tests, including snapshot tests, and markdown documentation have been added for the new rule.
Changelog
  • internal/config/config.go
    • Imported the new prefer_ts_expect_error rule package.
    • Registered the prefer-ts-expect-error rule with the global rule registry.
  • internal/plugins/typescript/rules/prefer_ts_expect_error/prefer_ts_expect_error.go
    • Added the core logic for the prefer-ts-expect-error rule.
    • Implemented functions to detect @ts-ignore directives in both single-line and multi-line comments.
    • Provided a fix mechanism to replace @ts-ignore with @ts-expect-error.
  • internal/plugins/typescript/rules/prefer_ts_expect_error/prefer_ts_expect_error.md
    • Created documentation detailing the purpose and usage of the prefer-ts-expect-error rule.
    • Included examples of both incorrect and correct code snippets.
  • internal/plugins/typescript/rules/prefer_ts_expect_error/prefer_ts_expect_error_test.go
    • Added a comprehensive test suite for the prefer-ts-expect-error rule.
    • Included valid test cases where @ts-ignore is not present or @ts-expect-error is already used.
    • Provided invalid test cases demonstrating the rule's detection and auto-fix capabilities for various @ts-ignore comment formats.
  • packages/rslint-test-tools/rstest.config.mts
    • Uncommented and enabled the test file for the prefer-ts-expect-error rule in the test configuration.
  • packages/rslint-test-tools/tests/typescript-eslint/rules/snapshots/prefer-ts-expect-error.test.ts.snap
    • Generated snapshot test output for the prefer-ts-expect-error rule's invalid test cases, capturing expected diagnostics and auto-fixed outputs.
  • rslint.json
    • Added the @typescript-eslint/prefer-ts-expect-error rule to the default configuration, setting its severity to 'off'.
Activity
  • The pull request ports the @typescript-eslint/prefer-ts-expect-error rule from an external repository (ScriptedAlchemy/rslint#13).
  • The author has confirmed that tests and documentation have been updated, as indicated by the checklist.
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

@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 new linting rule, @typescript-eslint/prefer-ts-expect-error, which encourages using @ts-expect-error over @ts-ignore. The changes include the rule's implementation, documentation, and tests. The implementation is a port from another project and seems mostly correct. I've found a minor bug in how it handles comments and a small opportunity for a code style improvement. Overall, this is a good addition to the linter.

@ScriptedAlchemy ScriptedAlchemy marked this pull request as ready for review February 26, 2026 03:45
Copilot AI review requested due to automatic review settings February 26, 2026 03:45
@ScriptedAlchemy ScriptedAlchemy enabled auto-merge (squash) February 26, 2026 03:45
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR ports the @typescript-eslint/prefer-ts-expect-error rule from ScriptedAlchemy#13. The rule encourages using @ts-expect-error over @ts-ignore in TypeScript directive comments, as @ts-expect-error provides better type safety by requiring an error to be present on the next line.

Changes:

  • Adds a new TypeScript ESLint rule that detects @ts-ignore directives and suggests replacing them with @ts-expect-error
  • Includes comprehensive tests covering single-line comments, multi-line comments, and various edge cases
  • Adds rule documentation following the codebase conventions

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.

Show a summary per file
File Description
internal/plugins/typescript/rules/prefer_ts_expect_error/prefer_ts_expect_error.go Core rule implementation with logic to find and replace @ts-ignore directives
internal/plugins/typescript/rules/prefer_ts_expect_error/prefer_ts_expect_error_test.go Comprehensive Go tests with 7 valid and 8 invalid test cases
internal/plugins/typescript/rules/prefer_ts_expect_error/prefer_ts_expect_error.md Rule documentation with examples and original documentation link
internal/config/config.go Registers the new rule in the global rule registry
rslint.json Adds the rule configuration (set to "off" by default)
packages/rslint-test-tools/rstest.config.mts Enables the TypeScript test file
packages/rslint-test-tools/tests/typescript-eslint/rules/prefer-ts-expect-error.test.ts TypeScript-based test file for validation
packages/rslint-test-tools/tests/typescript-eslint/rules/snapshots/prefer-ts-expect-error.test.ts.snap Test snapshots for all invalid test cases

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 93dc011497

ℹ️ 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".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants