Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Linting (major) #263

Merged
merged 3 commits into from
Nov 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions packages/inngest/etc/inngest.api.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions packages/inngest/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -161,14 +161,14 @@
"@types/ms": "^0.7.31",
"@types/node": "^18.16.16",
"@types/sha.js": "^2.4.0",
"@typescript-eslint/eslint-plugin": "^5.47.0",
"@typescript-eslint/parser": "^5.47.0",
"@typescript-eslint/eslint-plugin": "^6.0.0",
"@typescript-eslint/parser": "^6.0.0",
"@vercel/node": "^2.15.9",
"concurrently": "^7.4.0",
"eslint": "^8.30.0",
"eslint-config-prettier": "^8.5.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-prettier": "^5.0.0",
"express": "^4.18.2",
"fastify": "^4.21.0",
"genversion": "^3.1.1",
Expand All @@ -180,7 +180,7 @@
"nock": "^13.2.9",
"node-mocks-http": "^1.11.0",
"nodemon": "^2.0.20",
"prettier": "^2.7.1",
"prettier": "^3.1.0",
"shx": "^0.3.4",
"ts-jest": "^29.1.0",
"tsx": "^3.12.7",
Expand Down
11 changes: 7 additions & 4 deletions packages/inngest/scripts/integrationTestRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,10 +244,13 @@ async function runIntegrationTest(
exampleServerPort: number
): Promise<void> {
// Start a 10 minute timeout. If we don't finish within 10 minutes, something is wrong.
setTimeout(() => {
console.error("Integration test timed out");
process.exit(1);
}, 10 * 60 * 1000);
setTimeout(
() => {
console.error("Integration test timed out");
process.exit(1);
},
10 * 60 * 1000
);

const rootPath = path.join(__dirname, "..", "..", "..");
const sdkPath = path.join(rootPath, "packages", "inngest");
Expand Down
6 changes: 3 additions & 3 deletions packages/inngest/src/components/EventSchemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@ export type LiteralToRecordZodSchemas<T> = PickLiterals<
[I in keyof T as GetName<T[I]>]: InferZodShape<T[I]>;
}
: T extends ZodEventSchemas
? T
: never
? T
: never
>;

/**
Expand Down Expand Up @@ -177,7 +177,7 @@ export type StandardEventSchemaToPayload<T> = Simplify<{
*/
export type Combine<
TCurr extends Record<string, EventPayload>,
TInc extends StandardEventSchemas
TInc extends StandardEventSchemas,
> = IsStringLiteral<keyof TCurr & string> extends true
? Simplify<
Omit<TCurr, keyof StandardEventSchemaToPayload<TInc>> &
Expand Down
2 changes: 1 addition & 1 deletion packages/inngest/src/components/Inngest.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -758,7 +758,7 @@ describe("helper types", () => {

type GetUnionKeyValue<
T,
K extends string | number | symbol
K extends string | number | symbol,
> = T extends Record<K, infer U> ? U : never;

describe("type GetFunctionInput", () => {
Expand Down
16 changes: 8 additions & 8 deletions packages/inngest/src/components/Inngest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -345,8 +345,8 @@ export class Inngest<TOpts extends ClientOptions = ClientOptions> {
let payloads: EventPayload[] = Array.isArray(payload)
? (payload as EventPayload[])
: payload
? ([payload] as [EventPayload])
: [];
? ([payload] as [EventPayload])
: [];

const inputChanges = await hooks.transformInput?.({
payloads: [...payloads],
Expand Down Expand Up @@ -454,7 +454,7 @@ export class Inngest<TOpts extends ClientOptions = ClientOptions> {
TMiddleware extends MiddlewareStack,
TTrigger extends TriggerOptions<keyof EventsFromOpts<TOpts> & string>,
TTriggerName extends keyof EventsFromOpts<TOpts> &
string = EventNameFromTrigger<EventsFromOpts<TOpts>, TTrigger>
string = EventNameFromTrigger<EventsFromOpts<TOpts>, TTrigger>,
>(
options: ExclusiveKeys<
Omit<
Expand All @@ -477,7 +477,7 @@ export class Inngest<TOpts extends ClientOptions = ClientOptions> {
[
typeof builtInMiddleware,
NonNullable<TOpts["middleware"]>,
TMiddleware
TMiddleware,
],
FailureEventArgs<EventsFromOpts<TOpts>[TTriggerName]>
>
Expand Down Expand Up @@ -519,7 +519,7 @@ export class Inngest<TOpts extends ClientOptions = ClientOptions> {
[
typeof builtInMiddleware,
NonNullable<TOpts["middleware"]>,
TMiddleware
TMiddleware,
]
>
>
Expand Down Expand Up @@ -672,7 +672,7 @@ export type GetStepTools<
// eslint-disable-next-line @typescript-eslint/no-explicit-any
TInngest extends Inngest<any>,
TTrigger extends keyof GetEvents<TInngest> &
string = keyof GetEvents<TInngest> & string
string = keyof GetEvents<TInngest> & string,
> = GetFunctionInput<TInngest, TTrigger> extends { step: infer TStep }
? TStep
: never;
Expand All @@ -697,7 +697,7 @@ export type GetFunctionInput<
// eslint-disable-next-line @typescript-eslint/no-explicit-any
TInngest extends Inngest<any>,
TTrigger extends keyof GetEvents<TInngest> &
string = keyof GetEvents<TInngest> & string
string = keyof GetEvents<TInngest> & string,
> = Parameters<
Handler<
ClientOptionsFromInngest<TInngest>,
Expand All @@ -706,7 +706,7 @@ export type GetFunctionInput<
ExtendWithMiddleware<
[
typeof builtInMiddleware,
NonNullable<ClientOptionsFromInngest<TInngest>["middleware"]>
NonNullable<ClientOptionsFromInngest<TInngest>["middleware"]>,
]
>
>
Expand Down
8 changes: 4 additions & 4 deletions packages/inngest/src/components/InngestCommHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ interface InngestCommHandlerOptions<
// eslint-disable-next-line @typescript-eslint/no-explicit-any
Output = any,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
StreamOutput = any
StreamOutput = any,
> extends RegisterOptions {
/**
* The name of the framework this handler is designed for. Should be
Expand Down Expand Up @@ -210,7 +210,7 @@ export class InngestCommHandler<
// eslint-disable-next-line @typescript-eslint/no-explicit-any
Output = any,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
StreamOutput = any
StreamOutput = any,
> {
/**
* The ID of this serve handler, e.g. `"my-app"`. It's recommended that this
Expand Down Expand Up @@ -1234,7 +1234,7 @@ export type Handler<
// eslint-disable-next-line @typescript-eslint/no-explicit-any
Output = any,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
StreamOutput = any
StreamOutput = any,
> = (...args: Input) => HandlerResponse<Output, StreamOutput>;

// eslint-disable-next-line @typescript-eslint/no-explicit-any
Expand Down Expand Up @@ -1304,7 +1304,7 @@ export type HandlerResponse<Output = any, StreamOutput = any> = {
* framework-compatible response by an {@link InngestCommHandler} instance.
*/
export interface ActionResponse<
TBody extends string | ReadableStream = string
TBody extends string | ReadableStream = string,
> {
/**
* The HTTP status code to return.
Expand Down
6 changes: 3 additions & 3 deletions packages/inngest/src/components/InngestFunction.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ describe("runFn", () => {
event?: EventPayload;
onFailure?: boolean;
},
U extends Record<keyof T["steps"], string>
U extends Record<keyof T["steps"], string>,
>(
fnName: string,
createTools: () => T,
Expand Down Expand Up @@ -446,8 +446,8 @@ describe("runFn", () => {
ret!.type === "step-ran"
? [ret!.step]
: ret!.type === "steps-found"
? ret!.steps
: [];
? ret!.steps
: [];

outgoingOps.forEach((op) => {
expect(op.id).toMatch(/^[a-f0-9]{40}$/i);
Expand Down
2 changes: 1 addition & 1 deletion packages/inngest/src/components/InngestFunction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export class InngestFunction<
Opts extends FunctionOptions<
Events,
EventNameFromTrigger<Events, Trigger>
> = FunctionOptions<Events, EventNameFromTrigger<Events, Trigger>>
> = FunctionOptions<Events, EventNameFromTrigger<Events, Trigger>>,
> {
static stepId = "step";
static failureSuffix = "-failure";
Expand Down
50 changes: 27 additions & 23 deletions packages/inngest/src/components/InngestMiddleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,20 +73,20 @@ export class InngestMiddleware<TOpts extends MiddlewareOptions> {

type FnsWithSameInputAsOutput<
// eslint-disable-next-line @typescript-eslint/no-explicit-any
TRecord extends Record<string, (arg: any) => any>
TRecord extends Record<string, (arg: any) => any>,
> = {
[K in keyof TRecord as Await<TRecord[K]> extends Parameters<TRecord[K]>[0]
? K
: Await<TRecord[K]> extends void | undefined
? Parameters<TRecord[K]>[0] extends void | undefined
? K
: never
: never]: TRecord[K];
? Parameters<TRecord[K]>[0] extends void | undefined
? K
: never
: never]: TRecord[K];
};

type PromisifiedFunctionRecord<
// eslint-disable-next-line @typescript-eslint/no-explicit-any
TRecord extends Record<string, (arg: any) => any>
TRecord extends Record<string, (arg: any) => any>,
> = Pick<
Partial<{
[K in keyof TRecord]: (
Expand Down Expand Up @@ -124,7 +124,8 @@ export const getHookStack = async <
TMiddleware extends Record<string, (arg: any) => any>,
TKey extends keyof TMiddleware,
TResult extends Await<TMiddleware[TKey]>,
TRet extends PromisifiedFunctionRecord<TResult> = PromisifiedFunctionRecord<TResult>
TRet extends
PromisifiedFunctionRecord<TResult> = PromisifiedFunctionRecord<TResult>,
>(
/**
* The stack of middleware that will be used to run hooks.
Expand Down Expand Up @@ -152,26 +153,29 @@ export const getHookStack = async <
[K in keyof TResult as Await<TResult[K]> extends Parameters<TResult[K]>[0]
? K
: Await<TResult[K]> extends void | undefined
? Parameters<TResult[K]>[0] extends void | undefined
? K
: never
: never]: void;
? Parameters<TResult[K]>[0] extends void | undefined
? K
: never
: never]: void;
}
>
): Promise<TRet> => {
// Wait for middleware to initialize
const mwStack = await middleware;

// Step through each middleware and get the hook for the given key
const keyFns = mwStack.reduce((acc, mw) => {
const fn = mw[key];
const keyFns = mwStack.reduce(
(acc, mw) => {
const fn = mw[key];

if (fn) {
return [...acc, fn];
}
if (fn) {
return [...acc, fn];
}

return acc;
}, [] as NonNullable<TMiddleware[TKey]>[]);
return acc;
},
[] as NonNullable<TMiddleware[TKey]>[]
);

// Run each hook found in sequence and collect the results
const hooksRegistered = await keyFns.reduce<
Expand Down Expand Up @@ -473,7 +477,7 @@ type MiddlewareRunOutput = (ctx: {
* @internal
*/
type GetMiddlewareRunInputMutation<
TMiddleware extends InngestMiddleware<MiddlewareOptions>
TMiddleware extends InngestMiddleware<MiddlewareOptions>,
> = TMiddleware extends InngestMiddleware<infer TOpts>
? TOpts["init"] extends MiddlewareRegisterFn
? Await<
Expand All @@ -495,7 +499,7 @@ type GetMiddlewareRunInputMutation<
* @internal
*/
type GetMiddlewareSendEventOutputMutation<
TMiddleware extends InngestMiddleware<MiddlewareOptions>
TMiddleware extends InngestMiddleware<MiddlewareOptions>,
> = TMiddleware extends InngestMiddleware<infer TOpts>
? TOpts["init"] extends MiddlewareRegisterFn
? Await<
Expand All @@ -518,7 +522,7 @@ type GetMiddlewareSendEventOutputMutation<
*/
export type MiddlewareStackSendEventOutputMutation<
TContext,
TMiddleware extends MiddlewareStack
TMiddleware extends MiddlewareStack,
> = ObjectAssign<
{
[K in keyof TMiddleware]: GetMiddlewareSendEventOutputMutation<
Expand All @@ -531,7 +535,7 @@ export type MiddlewareStackSendEventOutputMutation<
export type ExtendWithMiddleware<
TMiddlewareStacks extends MiddlewareStack[],
// eslint-disable-next-line @typescript-eslint/ban-types
TContext = {}
TContext = {},
> = ObjectAssign<
{
[K in keyof TMiddlewareStacks]: MiddlewareStackRunInputMutation<
Expand All @@ -548,7 +552,7 @@ export type ExtendWithMiddleware<
*/
export type MiddlewareStackRunInputMutation<
TContext,
TMiddleware extends MiddlewareStack
TMiddleware extends MiddlewareStack,
> = ObjectAssign<
{
[K in keyof TMiddleware]: GetMiddlewareRunInputMutation<TMiddleware[K]>;
Expand Down
12 changes: 6 additions & 6 deletions packages/inngest/src/components/InngestStepTools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export interface FoundStep extends HashedOp {
export type MatchOpFn<
T extends (...args: unknown[]) => Promise<unknown> = (
...args: unknown[]
) => Promise<unknown>
) => Promise<unknown>,
> = (
stepOptions: StepOptions,
/**
Expand All @@ -52,7 +52,7 @@ export type StepHandler = (info: {
export interface StepToolOptions<
T extends (...args: unknown[]) => Promise<unknown> = (
...args: unknown[]
) => Promise<unknown>
) => Promise<unknown>,
> {
/**
* Optionally, we can also provide a function that will be called when
Expand Down Expand Up @@ -108,7 +108,7 @@ export const STEP_INDEXING_SUFFIX = ":";
export const createStepTools = <
TOpts extends ClientOptions,
Events extends EventsFromOpts<TOpts>,
TriggeringEvent extends keyof Events & string
TriggeringEvent extends keyof Events & string,
>(
client: Inngest<TOpts>,
stepHandler: StepHandler
Expand Down Expand Up @@ -277,8 +277,8 @@ export const createStepTools = <
T extends () => Promise<infer U>
? Awaited<U extends void ? null : U>
: ReturnType<T> extends void
? null
: ReturnType<T>
? null
: ReturnType<T>
>
>
>
Expand Down Expand Up @@ -381,7 +381,7 @@ export const createStepTools = <
type WaitForEventOpts<
Events extends Record<string, EventPayload>,
TriggeringEvent extends keyof Events,
IncomingEvent extends keyof Events
IncomingEvent extends keyof Events,
> = {
event: IncomingEvent;

Expand Down
Loading
Loading