From 52954539482826573ad7858d28f7b70ad0edb72b Mon Sep 17 00:00:00 2001 From: kakkokari-gtyih <67428053+kakkokari-gtyih@users.noreply.github.com> Date: Sat, 22 Jun 2024 22:39:39 +0900 Subject: [PATCH] fix lint --- .../misskey-js/generator/src/generator.ts | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/packages/misskey-js/generator/src/generator.ts b/packages/misskey-js/generator/src/generator.ts index 7f21413877..204105d54f 100644 --- a/packages/misskey-js/generator/src/generator.ts +++ b/packages/misskey-js/generator/src/generator.ts @@ -96,12 +96,14 @@ async function generateEndpointErrors( const errorResponseCodes = Object.keys(operation.responses).filter((key) => !okResponses.includes(key)); const errorTypes = new Map(); errorResponseCodes.forEach((code) => { - const response = operation.responses![code]; + if (operation.responses == null) return; + const response = operation.responses[code]; if ('content' in response && response.content != null && 'application/json' in response.content) { const errors = response.content['application/json'].examples; if (errors != null) { Object.keys(errors).forEach((key) => { const error = errors[key]; + // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition if (error != null && 'value' in error && error.value != null) { errorTypes.set(key, error.value); } @@ -270,17 +272,17 @@ async function generateApiClientJSDoc( endpointOutputLine.push(''); endpointOutputLine.push( - `interface IErrPromise {`, - ` then(onfulfilled?: ((value: TSuccess) => TResult1 | PromiseLike) | undefined | null, onrejected?: ((reason: TError) => TResult2 | PromiseLike) | undefined | null): Promise;`, - ``, - ` catch(onrejected?: ((reason: TError) => TResult | PromiseLike) | undefined | null): Promise;`, - `}`, - ``, - `class ErrPromise extends Promise implements IErrPromise {`, - ` constructor(executor: (resolve: (value: TSuccess | PromiseLike) => void, reject: (reason: TError) => void) => void) {`, - ` super(executor);`, - ` }`, - `}`, + 'interface IErrPromise {', + ' then(onfulfilled?: ((value: TSuccess) => TResult1 | PromiseLike) | undefined | null, onrejected?: ((reason: TError) => TResult2 | PromiseLike) | undefined | null): Promise;', + '', + ' catch(onrejected?: ((reason: TError) => TResult | PromiseLike) | undefined | null): Promise;', + '}', + '', + 'class ErrPromise extends Promise implements IErrPromise {', + ' constructor(executor: (resolve: (value: TSuccess | PromiseLike) => void, reject: (reason: TError) => void) => void) {', + ' super(executor);', + ' }', + '}', ); endpointOutputLine.push('');