-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy patherror-messages.ts
More file actions
21 lines (19 loc) · 1.09 KB
/
error-messages.ts
File metadata and controls
21 lines (19 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import { SyntaxKind } from 'typescript';
export const ERROR_MESSAGES = {
[SyntaxKind.IfStatement]: 'A hook cannot appear inside an if statement',
[SyntaxKind.SwitchStatement]:
'A hook cannot appear inside a switch statement',
[SyntaxKind.BinaryExpression]:
'A hook cannot be used in a conditional expression',
[SyntaxKind.ConditionalExpression]:
'A hook cannot be used in a conditional expression',
[SyntaxKind.SourceFile]:
'A hook cannot be used outside of a component or another hook',
[SyntaxKind.ClassDeclaration]: 'A hook cannot be used in a class component',
iterationStatement: 'A hook cannot appear inside a loop',
invalidFunctionDeclaration:
'A hook cannot be used inside of another function',
invalidFunctionExpression: 'A hook cannot be used inside of another function',
hookAfterEarlyReturn: 'A hook should not appear after a return statement',
anonymousFunctionIllegalCallback: `Hook is in an anonymous function that is passed to an illegal callback. Legal callbacks identifiers that can receive anonymous functions as arguments are memo and forwardRef`,
};