-
-
Notifications
You must be signed in to change notification settings - Fork 29
Closed
Labels
Type: EnhancementEnhancements to existing featuresEnhancements to existing features
Description
Describe the bug
We have code like below in a file called hooks.test.tsx:
const mockUseSession = vi.fn().mockReturnValue(sessionUser);
vi.mock("src/components/session/session", () => ({
useSession: () => mockUseSession(),
}));The content of src/components/session/session is as following:
export const useSession = (): Session | undefined => {
const { session } = React.useContext(SessionContext);
return session;
};useSession in vi.mock is getting flagged with If your function doesn't call any Hooks, avoid the 'use' prefix. Instead, write it as a regular function without the 'use' prefix. but I would argue that useSession is a hook.
If the rule is unable to determine with certainty if it's actually a hook or not, it should rather not report on it.
Reproduction
No response
Expected behavior
Possibly eslint-react opting out of checking vi.mock blocks completely.
Platform and versions
Node.js v22.15.0
"@eslint-react/eslint-plugin": "2.0.0-beta.34"
Stack trace
Additional context
No response
Metadata
Metadata
Assignees
Labels
Type: EnhancementEnhancements to existing featuresEnhancements to existing features