What problem does this feature solve?
Related discussion: web-infra-dev/rstest#85 (comment)
Most of the rules for jest may also be applicable to Rstest. In a typical repo which using Rstest - web-infra-dev/rsbuild - around 2/3 of the eslint-plugin-jest rules can pass directly.
So I have a proposal: we could share an abstraction layer under both Jest and Rstest lint rules in our repo. Consider Rslint is now porting rules from eslint-plugin-jest actively, we can extract some utils outside first. once the jest rules become stable, we can start building Rstest rules on top of the existing things.
Tracker
Jest Recommended (13/13)
| Rule Name |
Will implement |
Status |
Level |
| expect-expect |
✅ |
Merged #1614 |
warn |
| no-alias-methods |
✅ |
Merged #1837 |
Not recommended1 |
| no-conditional-expect |
✅ |
Merged #1548 |
error |
| no-deprecated-functions |
🚫 |
🚫 |
🚫 |
| no-commented-out-tests |
✅ |
Merged #1339 |
warn |
| no-disabled-tests |
✅ |
Merged #1475 |
warn |
| no-done-callback |
🚫 |
🚫 |
🚫 |
| no-export |
🚫 |
🚫 |
🚫 |
| no-focused-tests |
✅ |
Merged #1363 |
error |
| no-identical-title |
✅ |
Merged #1473 |
error |
| no-interpolation-in-snapshots |
✅ |
Merged #1604 |
error |
| no-jasmine-globals |
🚫 |
🚫 |
🚫 |
| no-mocks-import |
✅ |
Merged #1295 |
error |
| no-standalone-expect |
✅ |
Merged #1701 |
error |
| no-test-prefixes |
🚫 |
🚫 |
🚫 |
| valid-describe-callback |
🚫 |
🚫 |
🚫 |
| valid-expect |
✅ |
Merged #1695 |
error |
| valid-expect-in-promise |
✅ |
Merged #1696 |
error |
| valid-title |
✅ |
Merged #1606 |
error |
Vitest Recommended not in Jest Recommended (3/3)
| Rule Name |
Will implement |
Status |
Level |
| no-import-node-test |
✅ |
Merged #1775 |
error |
| prefer-called-exactly-once-with |
✅ |
Merged #1776 |
error |
| require-local-test-context-for-concurrent-snapshots |
✅ |
Merged #1778 |
error |
Jest Not Recommended (6/47)
| Rule Name |
Ready for Jest |
Will implement |
Status |
| consistent-test-it |
— |
✅ |
— |
| max-expects |
✅ |
✅ |
Merged #1838 |
| max-nested-describe |
✅ |
✅ |
— |
| no-conditional-in-test |
✅ |
✅ |
Merged #1839 |
| no-confusing-set-timeout |
✅ |
🚫 |
🚫 |
| no-duplicate-hooks |
✅ |
✅ |
— |
| no-hooks |
✅ |
✅ |
Merged #1835 |
| no-large-snapshots |
— |
✅ |
— |
| no-restricted-jest-methods |
✅ |
🚫 |
🚫 |
| no-restricted-matchers |
✅ |
✅ |
— |
| no-test-return-statement |
— |
✅ |
— |
| no-unneeded-async-expect-function |
✅ |
✅ |
— |
| no-untyped-mock-factory |
— |
✅ |
— |
| padding-around-after-all-blocks |
— |
✅ |
— |
| padding-around-after-each-blocks |
— |
✅ |
— |
| padding-around-all |
— |
✅ |
— |
| padding-around-before-all-blocks |
— |
✅ |
— |
| padding-around-before-each-blocks |
— |
✅ |
— |
| padding-around-describe-blocks |
— |
✅ |
— |
| padding-around-expect-groups |
— |
✅ |
— |
| padding-around-test-blocks |
— |
✅ |
— |
| prefer-to-be |
✅ |
✅ |
— |
| prefer-to-contain |
✅ |
✅ |
— |
| prefer-to-have-length |
✅ |
✅ |
— |
| prefer-called-with |
✅ |
✅ |
— |
| prefer-comparison-matcher |
✅ |
✅ |
— |
| prefer-each |
✅ |
✅ |
Merged #1841 |
| prefer-ending-with-an-expect |
— |
✅ |
— |
| prefer-equality-matcher |
✅ |
✅ |
— |
| prefer-expect-assertions |
— |
✅ |
— |
| prefer-expect-resolves |
✅ |
✅ |
— |
| prefer-hooks-in-order |
✅ |
✅ |
Merged #1836 |
| prefer-hooks-on-top |
✅ |
✅ |
— |
| prefer-importing-jest-globals |
— |
🚫 |
🚫 |
| prefer-jest-mocked |
✅ |
🚫 |
🚫 |
| prefer-lowercase-title |
— |
✅ |
— |
| prefer-mock-promise-shorthand |
— |
✅ |
— |
| prefer-mock-return-shorthand |
— |
✅ |
— |
| prefer-snapshot-hint |
— |
✅ |
— |
| prefer-spy-on |
✅ |
✅ |
— |
| prefer-strict-equal |
✅ |
✅ |
— |
| prefer-to-have-been-called |
✅ |
✅ |
— |
| prefer-to-have-been-called-times |
✅ |
✅ |
— |
| prefer-todo |
✅ |
✅ |
Merged #1840 |
| require-hook |
✅ |
✅ |
— |
| require-to-throw-message |
✅ |
✅ |
— |
| require-top-level-describe |
✅ |
✅ |
— |
| valid-mock-module-path |
— |
🚫 |
🚫 |
| no-error-equal |
— |
✅ |
— |
| no-unnecessary-assertion |
— |
✅ |
— |
| unbound-method |
— |
✅ |
— |
| valid-expect-with-promise |
— |
✅ |
— |
Vitest Not Recommended not in Jest (7/15)
| Rule Name |
Will implement |
Status |
| consistent-each-for |
✅ |
— |
| consistent-test-filename |
✅ |
— |
| consistent-vitest-vi |
🚫2 |
🚫 |
| hoisted-apis-on-top |
✅ |
Merged #1929 |
| no-conditional-tests |
✅ |
PR #1919 |
| no-importing-vitest-globals |
🚫2 |
🚫 |
| no-restricted-vi-methods |
🚫2 |
🚫 |
| prefer-called-once |
✅ |
Merged #1921 |
| prefer-called-times |
✅ |
Merged #1890 |
| prefer-describe-function-title |
🚫 |
🚫 |
| prefer-expect-type-of |
✅ |
Merged #1885 |
| prefer-import-in-mock |
✅ |
Merged #1930 |
| prefer-importing-vitest-globals |
🚫2 |
🚫 |
| prefer-strict-boolean-matchers |
✅ |
— |
| prefer-to-be-falsy |
✅ |
— |
| prefer-to-be-object |
🚫 |
🚫 |
| prefer-to-be-truthy |
✅ |
— |
| prefer-vi-mocked |
🚫2 |
🚫 |
| require-awaited-expect-poll |
✅ |
PR #1920 |
| require-mock-type-parameters |
✅ |
PR #1944 |
| require-test-timeout |
✅ |
Merged #1918 |
| warn-todo |
✅ |
Merged #1889 |
Rstest-only Rules (0/5)
| Rule Name |
Will implement |
Status |
| consistent-rstest-namespace |
✅ |
PR #1942 |
| no-importing-rstest-globals |
✅ |
— |
| no-restricted-rstest-methods |
✅ |
— |
| prefer-importing-rstest-globals |
✅ |
— |
| prefer-rs-mocked |
✅ |
— |
What problem does this feature solve?
Related discussion: web-infra-dev/rstest#85 (comment)
Most of the rules for jest may also be applicable to Rstest. In a typical repo which using Rstest - web-infra-dev/rsbuild - around 2/3 of the
eslint-plugin-jestrules can pass directly.So I have a proposal: we could share an abstraction layer under both Jest and Rstest lint rules in our repo. Consider Rslint is now porting rules from
eslint-plugin-jestactively, we can extract some utils outside first. once the jest rules become stable, we can start building Rstest rules on top of the existing things.Tracker
Jest Recommended (13/13)
warnerrorwarnwarnerrorerrorerrorerrorerrorerrorerrorerrorVitest Recommended not in Jest Recommended (3/3)
errorerrorerrorJest Not Recommended (6/47)
Vitest Not Recommended not in Jest (7/15)
Rstest-only Rules (0/5)
Footnotes
Jest deprecated these aliases in Jest 26 and removed them in Jest 30. Vitest still supports them and keeps
no-alias-methodsoutside itsrecommendedconfig, so canonical naming is primarily an opt-in style preference there. Rstest follows Vitest because itsexpectimplementation is based on@vitest/expect. ↩These rules are all defined in terms of the
viobject or thevitestmodule specifier, neither of which exists in Rstest — the equivalent utilities are exported asrstest/rsand are also reachable throughimport.meta.rstest. So they cannot be ported under the same name. Where the underlying idea still applies, it belongs to a separately named Rstest rule (for exampleno-restricted-rstest-methods,prefer-rs-mocked), not to a port of the Vitest rule. ↩ ↩2 ↩3 ↩4 ↩5