( functionName: string, restOptions: Record<string, unknown>, // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type callsite: Function, )
| 10 | * @param callsite - The function where the validation is called from (e.g., render, renderHook) |
| 11 | */ |
| 12 | export function validateOptions( |
| 13 | functionName: string, |
| 14 | restOptions: Record<string, unknown>, |
| 15 | // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type |
| 16 | callsite: Function, |
| 17 | ): void { |
| 18 | const unknownKeys = Object.keys(restOptions); |
| 19 | if (unknownKeys.length > 0) { |
| 20 | // Pass the callsite function (e.g., render) to remove it from stack |
| 21 | // This leaves only where the user called the function from (e.g., test file) |
| 22 | const stackTraceError = new ErrorWithStack('STACK_TRACE_ERROR', callsite); |
| 23 | const stackLines = stackTraceError.stack ? stackTraceError.stack.split('\n') : []; |
| 24 | // Skip the first line (Error: STACK_TRACE_ERROR) to show the actual call sites |
| 25 | // The remaining lines show where the user called the function from |
| 26 | const stackTrace = stackLines.length > 1 ? `\n\n${stackLines.slice(1).join('\n')}` : ''; |
| 27 | logger.warn( |
| 28 | `Unknown option(s) passed to ${functionName}: ${unknownKeys.join(', ')}${stackTrace}`, |
| 29 | ); |
| 30 | } |
| 31 | } |
no outgoing calls
searching dependent graphs…