Skip to content

feat(eslint-plugin-jest): add expect-expect rule - #950

Merged
fansenze merged 8 commits into
web-infra-dev:mainfrom
eryue0220:feat/jest-expect-expect
May 21, 2026
Merged

fansenze merged 8 commits into
web-infra-dev:mainfrom
eryue0220:feat/jest-expect-expect

Conversation

@eryue0220

Copy link
Copy Markdown
Contributor

Summary

Port expect-expect from eslint-plugin-jest to rslint.

Related Links

Tracking issue: #476
eslint-plugin-jest/expect-expect doc code

Checklist

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

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

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 implements the jest/expect-expect rule, which ensures that every Jest test callback contains at least one assertion. The implementation includes logic to handle custom assertion function names, additional test block functions, and attribution of assertions within named functions passed as callbacks. Feedback highlights a potential panic risk and overly restrictive character matching in the regex compilation for assertion patterns. Additionally, there are concerns regarding the performance and correctness of the function attribution logic, specifically related to O(N*M) complexity and false positives caused by function hoisting. A refactoring of the AST walker to remove goto statements was also suggested for better readability.

Comment thread internal/plugins/jest/rules/expect_expect/expect_expect.go
Comment thread internal/plugins/jest/rules/expect_expect/expect_expect.go Outdated
Comment thread internal/plugins/jest/rules/expect_expect/expect_expect.go Outdated
fansenze

This comment was marked as resolved.

fansenze

This comment was marked as resolved.

eryue0220 added 2 commits May 19, 2026 15:33
… into feat/jest-expect-expect

* 'feat/jest-expect-expect' of github.com:eryue0220/rslint: (22 commits)
  chore: sync typescript-go submodule to 6a088fbd7 (web-infra-dev#968)
  chore(deps): update tailwindcss monorepo to ^4.3.0 (web-infra-dev#967)
  fix: handle exhaustive-deps shorthand references (web-infra-dev#963)
  feat: port rule @typescript-eslint/no-unnecessary-type-conversion (web-infra-dev#960)
  feat: port rule @typescript-eslint/no-unnecessary-parameter-property-assignment (web-infra-dev#958)
  feat: port rule @typescript-eslint/no-unnecessary-qualifier (web-infra-dev#959)
  feat: port rule @typescript-eslint/no-invalid-this (web-infra-dev#957)
  feat: port rule @typescript-eslint/no-import-type-side-effects (web-infra-dev#956)
  feat: port rule @typescript-eslint/init-declarations (web-infra-dev#955)
  feat: port rule @typescript-eslint/no-confusing-non-null-assertion (web-infra-dev#954)
  feat: port rule @typescript-eslint/explicit-module-boundary-types (web-infra-dev#953)
  feat: port rule @typescript-eslint/class-methods-use-this (web-infra-dev#952)
  feat: port rule @typescript-eslint/no-wrapper-object-types (web-infra-dev#951)
  feat: port rule @typescript-eslint/no-unsafe-declaration-merging (web-infra-dev#949)
  feat: port rule @typescript-eslint/no-empty-object-type (web-infra-dev#946)
  feat: port rule no-unsafe-function-type (web-infra-dev#947)
  ci: disable Swatinem/rust-cache cache-bin to fix flaky macos rust jobs (web-infra-dev#945)
  feat: port rule jsx-a11y/prefer-tag-over-role (web-infra-dev#942)
  feat: port rule jsx-a11y/no-aria-hidden-on-focusable (web-infra-dev#943)
  chore: sync typescript-go submodule to c282336ea (web-infra-dev#944)
  ...

@fansenze fansenze left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@eryue0220 Thanks for the port! All 5 of my earlier comments are addressed (including the trickier hoisting + nested-it refactors), and the 3 gemini-bot suggestions are folded in cleanly too. Cross-checked against eslint-plugin-jest@main and found one remaining divergence cluster — all rooted in CalleeChainName's ElementAccessExpression handling.

Details in the inline comment below. Once this is addressed, this is good to merge from my side.

(Worth noting CalleeChainName is shared infrastructure for the jest plugin, so fixing here will help future rules too.)

Comment thread internal/plugins/jest/utils/jest.go
@fansenze
fansenze merged commit 092f984 into web-infra-dev:main May 21, 2026
12 checks passed
@eryue0220
eryue0220 deleted the feat/jest-expect-expect branch May 21, 2026 12:23
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