feat(eslint-plugin-jest): add expect-expect rule - #950
Conversation
There was a problem hiding this comment.
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.
… 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
left a comment
There was a problem hiding this comment.
@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.)
Summary
Port
expect-expectfrom eslint-plugin-jest to rslint.Related Links
Tracking issue: #476
eslint-plugin-jest/expect-expect doc code
Checklist