mirror of
https://github.com/outline/outline.git
synced 2026-06-13 03:14:59 +03:00
57308c46af
* chore: resolve no-redundant-type-constituents and test/mock no-explicit-any warnings Clears 36 lint warnings: all 5 no-redundant-type-constituents, 6 no-misused-spread (via narrowing getPartitionWhereClause's return type to WhereAttributeHash), and 25 no-explicit-any in test/mock files. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> * chore: resolve no-base-to-string warnings in tests Convert userProvisioner try/catch error assertions to Jest's .rejects.toThrow() idiom, and cast webhook test body to string. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> * chore: resolve no-explicit-any warnings in cancan and tracing Tighten types in the cancan policy framework and tracing decorators. Constructor / generic-function upper bounds keep `any` where TypeScript variance requires it, scoped to single-line oxlint-disable comments. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
40 lines
1.0 KiB
TypeScript
40 lines
1.0 KiB
TypeScript
/* oxlint-disable @typescript-eslint/explicit-function-return-type */
|
|
import type { Tracer } from "dd-trace";
|
|
|
|
// oxlint-disable-next-line @typescript-eslint/no-empty-function
|
|
const emptyFn = function () {};
|
|
|
|
const callableHandlers = {
|
|
get<T, P extends keyof T>(_target: T, _prop: P, _receiver: unknown): T[P] {
|
|
const newMock = new Proxy(emptyFn, callableHandlers);
|
|
return newMock as unknown as T[P];
|
|
},
|
|
|
|
apply<T extends (...args: never[]) => unknown, A extends Parameters<T>>(
|
|
_target: T,
|
|
_thisArg: unknown,
|
|
_args: A
|
|
): ReturnType<T> {
|
|
const newMock = new Proxy(emptyFn, callableHandlers);
|
|
return newMock as unknown as ReturnType<T>;
|
|
},
|
|
};
|
|
|
|
const callableMock = new Proxy(emptyFn, callableHandlers);
|
|
|
|
type MockTracer = Tracer & { isMock?: boolean };
|
|
|
|
export const mockTracer = new Proxy({} as MockTracer, {
|
|
get<K extends keyof MockTracer>(_target: Tracer, key: K) {
|
|
if (key === "isMock") {
|
|
return true;
|
|
}
|
|
|
|
if (key === "wrap") {
|
|
return (_: unknown, f: unknown) => f;
|
|
}
|
|
|
|
return callableMock;
|
|
},
|
|
});
|