lint: enable jest/prefer-jest-mocked#115791
Conversation
📊 Type Coverage Diff✅ No new type safety issues introduced. Coverage: 93.56% |
| @@ -0,0 +1,48 @@ | |||
| import {ESLintUtils} from '@typescript-eslint/utils'; | |||
|
|
|||
| export const noJestMockCast = ESLintUtils.RuleCreator.withoutDocs({ | |||
There was a problem hiding this comment.
Apologies for being a stickler, but in lint-land terminology a "cast" is a wholly different thing (runtime). Assertions are the type system feature. They're not technically interchangeable terms (even though everyone generally does in casual speak).
| export const noJestMockCast = ESLintUtils.RuleCreator.withoutDocs({ | |
| export const noJestMockAssertion = ESLintUtils.RuleCreator.withoutDocs({ |
| schema: [], | ||
| messages: { | ||
| noJestMockCast: | ||
| 'Use `jest.mocked({{expression}})` instead of casting with `as jest.Mock`.', |
There was a problem hiding this comment.
| 'Use `jest.mocked({{expression}})` instead of casting with `as jest.Mock`.', | |
| 'Use `jest.mocked({{expression}})` instead of asserting with `as jest.Mock`.', |
cd2dd54 to
ed67da5
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit ed67da5. Configure here.
ed67da5 to
b39419a
Compare
|
@JoshuaKGoldberg will update the terminology before merging this! |
|
Let me see if we can just use |
….mocked()` Enables jest/prefer-jest-mocked from eslint-plugin-jest, which covers `jest.Mock`, `jest.MockedFunction`, `jest.MockedClass`, and `jest.MockedObject` assertions and includes an autofix to jest.mocked().
b39419a to
cb500e2
Compare
as jest.Mock with jest.mocked()
Enables
jest/prefer-jest-mockedfromeslint-plugin-jest(already a dep). It coversjest.Mock,jest.MockedFunction,jest.MockedClass, andjest.MockedObjectassertions and autofixes tojest.mocked(). The five remaining offending files are fixed in this PR as well.