style: fix up lint

This commit is contained in:
iCrawl
2023-12-19 14:45:28 +01:00
parent 171cb182ed
commit d869d9b3fe
18 changed files with 44 additions and 44 deletions

View File

@@ -28,7 +28,7 @@ import { OVERLOAD_SEPARATOR } from '~/util/constants';
import { fetchMember } from '~/util/fetchMember'; import { fetchMember } from '~/util/fetchMember';
import { findMember } from '~/util/model'; import { findMember } from '~/util/model';
export const revalidate = 3_600; export const revalidate = 86_400;
export interface ItemRouteParams { export interface ItemRouteParams {
item: string; item: string;

View File

@@ -12,7 +12,7 @@ import { resolveItemURI } from '~/components/documentation/util';
import { N_RECENT_VERSIONS, PACKAGES } from '~/util/constants'; import { N_RECENT_VERSIONS, PACKAGES } from '~/util/constants';
import { Providers } from './providers'; import { Providers } from './providers';
export const revalidate = 3_600; export const revalidate = 0;
const Header = dynamic(async () => import('~/components/Header')); const Header = dynamic(async () => import('~/components/Header'));
const Footer = dynamic(async () => import('~/components/Footer')); const Footer = dynamic(async () => import('~/components/Footer'));

View File

@@ -7,7 +7,7 @@ import { fetchVersions } from '~/app/docAPI';
import { buttonVariants } from '~/styles/Button'; import { buttonVariants } from '~/styles/Button';
import { PACKAGES } from '~/util/constants'; import { PACKAGES } from '~/util/constants';
export const revalidate = 3_600; export const revalidate = 86_400;
export default async function Page({ params }: { params: { package: string } }) { export default async function Page({ params }: { params: { package: string } }) {
if (!PACKAGES.includes(params.package)) { if (!PACKAGES.includes(params.package)) {

View File

@@ -87,7 +87,7 @@ export function TSDoc({ item, tsdoc }: { readonly item: ApiItem; readonly tsdoc:
version={ version={
resolved?.package resolved?.package
? // eslint-disable-next-line unicorn/better-regex ? // eslint-disable-next-line unicorn/better-regex
item.getAssociatedPackage()?.dependencies?.[resolved.package]?.replace(/[~^]/, '') item.getAssociatedPackage()?.dependencies?.[resolved.package]?.replace(/[~^]/, '')
: undefined : undefined
} }
> >

View File

@@ -84,7 +84,7 @@ export class ApiCallSignature extends ApiTypeParameterListMixin(
const parent: DeclarationReference = this.parent const parent: DeclarationReference = this.parent
? this.parent.canonicalReference ? this.parent.canonicalReference
: // .withMeaning() requires some kind of component : // .withMeaning() requires some kind of component
DeclarationReference.empty().addNavigationStep(Navigation.Members as any, '(parent)'); DeclarationReference.empty().addNavigationStep(Navigation.Members as any, '(parent)');
return parent.withMeaning(Meaning.CallSignature as any).withOverloadIndex(this.overloadIndex); return parent.withMeaning(Meaning.CallSignature as any).withOverloadIndex(this.overloadIndex);
} }
} }

View File

@@ -97,7 +97,7 @@ export class ApiConstructSignature extends ApiTypeParameterListMixin(
const parent: DeclarationReference = this.parent const parent: DeclarationReference = this.parent
? this.parent.canonicalReference ? this.parent.canonicalReference
: // .withMeaning() requires some kind of component : // .withMeaning() requires some kind of component
DeclarationReference.empty().addNavigationStep(Navigation.Members as any, '(parent)'); DeclarationReference.empty().addNavigationStep(Navigation.Members as any, '(parent)');
return parent.withMeaning(Meaning.ConstructSignature as any).withOverloadIndex(this.overloadIndex); return parent.withMeaning(Meaning.ConstructSignature as any).withOverloadIndex(this.overloadIndex);
} }
} }

View File

@@ -75,7 +75,7 @@ export class ApiConstructor extends ApiParameterListMixin(ApiProtectedMixin(ApiR
const parent: DeclarationReference = this.parent const parent: DeclarationReference = this.parent
? this.parent.canonicalReference ? this.parent.canonicalReference
: // .withMeaning() requires some kind of component : // .withMeaning() requires some kind of component
DeclarationReference.empty().addNavigationStep(Navigation.Members as any, '(parent)'); DeclarationReference.empty().addNavigationStep(Navigation.Members as any, '(parent)');
return parent.withMeaning(Meaning.Constructor as any).withOverloadIndex(this.overloadIndex); return parent.withMeaning(Meaning.Constructor as any).withOverloadIndex(this.overloadIndex);
} }
} }

View File

@@ -74,7 +74,7 @@ export class ApiIndexSignature extends ApiParameterListMixin(
const parent: DeclarationReference = this.parent const parent: DeclarationReference = this.parent
? this.parent.canonicalReference ? this.parent.canonicalReference
: // .withMeaning() requires some kind of component : // .withMeaning() requires some kind of component
DeclarationReference.empty().addNavigationStep(Navigation.Members as any, '(parent)'); DeclarationReference.empty().addNavigationStep(Navigation.Members as any, '(parent)');
return parent.withMeaning(Meaning.IndexSignature as any).withOverloadIndex(this.overloadIndex); return parent.withMeaning(Meaning.IndexSignature as any).withOverloadIndex(this.overloadIndex);
} }
} }

View File

@@ -252,7 +252,7 @@ export class ApiNodeJSONEncoder {
parentKey: item.parent.containerKey, parentKey: item.parent.containerKey,
parentName: item.parent.displayName, parentName: item.parent.displayName,
path: generatePath(item.parent.getHierarchy(), version), path: generatePath(item.parent.getHierarchy(), version),
} }
: null, : null,
}; };
} }

View File

@@ -64,7 +64,7 @@ export function generatePath(items: readonly ApiItem[], version: string) {
return path.includes('@discordjs/') return path.includes('@discordjs/')
? path.replace(/@discordjs\/(?<package>.*)\/(?<member>.*)?/, `$<package>/${version}/$<member>`) ? path.replace(/@discordjs\/(?<package>.*)\/(?<member>.*)?/, `$<package>/${version}/$<member>`)
: path.replace(/(?<oackage>.*)\/(?<member>.*)?/, `$<package>/${version}/$<member>`); : path.replace(/(?<package>.*)\/(?<member>.*)?/, `$<package>/${version}/$<member>`);
} }
export function resolveDocComment(item: ApiDeclaredItem) { export function resolveDocComment(item: ApiDeclaredItem) {

View File

@@ -853,7 +853,7 @@ export class ExportAnalyzer {
? TypeScriptInternals.getModeForUsageLocation( ? TypeScriptInternals.getModeForUsageLocation(
importOrExportDeclaration.getSourceFile(), importOrExportDeclaration.getSourceFile(),
importOrExportDeclaration.moduleSpecifier, importOrExportDeclaration.moduleSpecifier,
) )
: undefined; : undefined;
const resolvedModule: ts.ResolvedModuleFull | undefined = TypeScriptInternals.getResolvedModule( const resolvedModule: ts.ResolvedModuleFull | undefined = TypeScriptInternals.getResolvedModule(
importOrExportDeclaration.getSourceFile(), importOrExportDeclaration.getSourceFile(),

View File

@@ -563,7 +563,7 @@ export class ApiModelGenerator {
?.map((param) => ` * @param ${param.name} - ${this._fixLinkTags(param.description) ?? ''}\n`) ?.map((param) => ` * @param ${param.name} - ${this._fixLinkTags(param.description) ?? ''}\n`)
.join('') ?? '' .join('') ?? ''
} */`, } */`,
).docComment ).docComment
: apiItemMetadata.tsdocComment; : apiItemMetadata.tsdocComment;
const releaseTag: ReleaseTag = apiItemMetadata.effectiveReleaseTag; const releaseTag: ReleaseTag = apiItemMetadata.effectiveReleaseTag;
const isProtected: boolean = (astDeclaration.modifierFlags & ts.ModifierFlags.Protected) !== 0; const isProtected: boolean = (astDeclaration.modifierFlags & ts.ModifierFlags.Protected) !== 0;
@@ -650,10 +650,10 @@ export class ApiModelGenerator {
jsDoc.deprecated jsDoc.deprecated
? ` * @deprecated ${ ? ` * @deprecated ${
typeof jsDoc.deprecated === 'string' ? this._fixLinkTags(jsDoc.deprecated) : jsDoc.deprecated typeof jsDoc.deprecated === 'string' ? this._fixLinkTags(jsDoc.deprecated) : jsDoc.deprecated
}\n` }\n`
: '' : ''
} */`, } */`,
).docComment ).docComment
: apiItemMetadata.tsdocComment; : apiItemMetadata.tsdocComment;
const releaseTag: ReleaseTag = apiItemMetadata.effectiveReleaseTag; const releaseTag: ReleaseTag = apiItemMetadata.effectiveReleaseTag;
const isAbstract: boolean = (ts.getCombinedModifierFlags(classDeclaration) & ts.ModifierFlags.Abstract) !== 0; const isAbstract: boolean = (ts.getCombinedModifierFlags(classDeclaration) & ts.ModifierFlags.Abstract) !== 0;
@@ -723,7 +723,7 @@ export class ApiModelGenerator {
?.map((param) => ` * @param ${param.name} - ${this._fixLinkTags(param.description) ?? ''}\n`) ?.map((param) => ` * @param ${param.name} - ${this._fixLinkTags(param.description) ?? ''}\n`)
.join('') ?? '' .join('') ?? ''
} */`, } */`,
).docComment ).docComment
: apiItemMetadata.tsdocComment; : apiItemMetadata.tsdocComment;
const releaseTag: ReleaseTag = apiItemMetadata.effectiveReleaseTag; const releaseTag: ReleaseTag = apiItemMetadata.effectiveReleaseTag;
const sourceLocation: ISourceLocation = this._getSourceLocation(constructSignature); const sourceLocation: ISourceLocation = this._getSourceLocation(constructSignature);
@@ -861,10 +861,10 @@ export class ApiModelGenerator {
jsDoc.deprecated jsDoc.deprecated
? ` * @deprecated ${ ? ` * @deprecated ${
typeof jsDoc.deprecated === 'string' ? this._fixLinkTags(jsDoc.deprecated) : jsDoc.deprecated typeof jsDoc.deprecated === 'string' ? this._fixLinkTags(jsDoc.deprecated) : jsDoc.deprecated
}\n` }\n`
: '' : ''
} */`, } */`,
).docComment ).docComment
: apiItemMetadata.tsdocComment; : apiItemMetadata.tsdocComment;
const releaseTag: ReleaseTag = apiItemMetadata.effectiveReleaseTag; const releaseTag: ReleaseTag = apiItemMetadata.effectiveReleaseTag;
const sourceLocation: ISourceLocation = this._getSourceLocation(functionDeclaration); const sourceLocation: ISourceLocation = this._getSourceLocation(functionDeclaration);
@@ -983,10 +983,10 @@ export class ApiModelGenerator {
jsDoc.deprecated jsDoc.deprecated
? ` * @deprecated ${ ? ` * @deprecated ${
typeof jsDoc.deprecated === 'string' ? this._fixLinkTags(jsDoc.deprecated) : jsDoc.deprecated typeof jsDoc.deprecated === 'string' ? this._fixLinkTags(jsDoc.deprecated) : jsDoc.deprecated
}\n` }\n`
: '' : ''
} */`, } */`,
).docComment ).docComment
: apiItemMetadata.tsdocComment; : apiItemMetadata.tsdocComment;
const releaseTag: ReleaseTag = apiItemMetadata.effectiveReleaseTag; const releaseTag: ReleaseTag = apiItemMetadata.effectiveReleaseTag;
const sourceLocation: ISourceLocation = this._getSourceLocation(interfaceDeclaration); const sourceLocation: ISourceLocation = this._getSourceLocation(interfaceDeclaration);
@@ -1063,10 +1063,10 @@ export class ApiModelGenerator {
jsDoc.deprecated jsDoc.deprecated
? ` * @deprecated ${ ? ` * @deprecated ${
typeof jsDoc.deprecated === 'string' ? this._fixLinkTags(jsDoc.deprecated) : jsDoc.deprecated typeof jsDoc.deprecated === 'string' ? this._fixLinkTags(jsDoc.deprecated) : jsDoc.deprecated
}\n` }\n`
: '' : ''
} */`, } */`,
).docComment ).docComment
: apiItemMetadata.tsdocComment; : apiItemMetadata.tsdocComment;
const releaseTag: ReleaseTag = apiItemMetadata.effectiveReleaseTag; const releaseTag: ReleaseTag = apiItemMetadata.effectiveReleaseTag;
if (releaseTag === ReleaseTag.Internal || releaseTag === ReleaseTag.Alpha) { if (releaseTag === ReleaseTag.Internal || releaseTag === ReleaseTag.Alpha) {
@@ -1155,10 +1155,10 @@ export class ApiModelGenerator {
jsDoc.deprecated jsDoc.deprecated
? ` * @deprecated ${ ? ` * @deprecated ${
typeof jsDoc.deprecated === 'string' ? this._fixLinkTags(jsDoc.deprecated) : jsDoc.deprecated typeof jsDoc.deprecated === 'string' ? this._fixLinkTags(jsDoc.deprecated) : jsDoc.deprecated
}\n` }\n`
: '' : ''
} */`, } */`,
).docComment ).docComment
: apiItemMetadata.tsdocComment; : apiItemMetadata.tsdocComment;
const releaseTag: ReleaseTag = apiItemMetadata.effectiveReleaseTag; const releaseTag: ReleaseTag = apiItemMetadata.effectiveReleaseTag;
const isOptional: boolean = (astDeclaration.astSymbol.followedSymbol.flags & ts.SymbolFlags.Optional) !== 0; const isOptional: boolean = (astDeclaration.astSymbol.followedSymbol.flags & ts.SymbolFlags.Optional) !== 0;
@@ -1225,8 +1225,8 @@ export class ApiModelGenerator {
const isStatic: boolean = astDeclaration const isStatic: boolean = astDeclaration
? (astDeclaration.modifierFlags & ts.ModifierFlags.Static) !== 0 ? (astDeclaration.modifierFlags & ts.ModifierFlags.Static) !== 0
: parentApiItem.kind === ApiItemKind.Class || parentApiItem.kind === ApiItemKind.Interface : parentApiItem.kind === ApiItemKind.Class || parentApiItem.kind === ApiItemKind.Interface
? (jsDoc as DocgenPropertyJson).scope === 'static' ? (jsDoc as DocgenPropertyJson).scope === 'static'
: false; : false;
const containerKey: string = ApiProperty.getContainerKey(name, isStatic); const containerKey: string = ApiProperty.getContainerKey(name, isStatic);
let apiProperty: ApiProperty | undefined = parentApiItem.tryGetMemberByKey(containerKey) as ApiProperty; let apiProperty: ApiProperty | undefined = parentApiItem.tryGetMemberByKey(containerKey) as ApiProperty;
@@ -1266,10 +1266,10 @@ export class ApiModelGenerator {
'deprecated' in jsDoc && jsDoc.deprecated 'deprecated' in jsDoc && jsDoc.deprecated
? ` * @deprecated ${ ? ` * @deprecated ${
typeof jsDoc.deprecated === 'string' ? this._fixLinkTags(jsDoc.deprecated) : jsDoc.deprecated typeof jsDoc.deprecated === 'string' ? this._fixLinkTags(jsDoc.deprecated) : jsDoc.deprecated
}\n` }\n`
: '' : ''
} */`, } */`,
).docComment ).docComment
: apiItemMetadata.tsdocComment; : apiItemMetadata.tsdocComment;
const releaseTag: ReleaseTag = apiItemMetadata.effectiveReleaseTag; const releaseTag: ReleaseTag = apiItemMetadata.effectiveReleaseTag;
const isOptional: boolean = (astDeclaration.astSymbol.followedSymbol.flags & ts.SymbolFlags.Optional) !== 0; const isOptional: boolean = (astDeclaration.astSymbol.followedSymbol.flags & ts.SymbolFlags.Optional) !== 0;
@@ -1341,10 +1341,10 @@ export class ApiModelGenerator {
'deprecated' in jsDoc && jsDoc.deprecated 'deprecated' in jsDoc && jsDoc.deprecated
? ` * @deprecated ${ ? ` * @deprecated ${
typeof jsDoc.deprecated === 'string' ? this._fixLinkTags(jsDoc.deprecated) : jsDoc.deprecated typeof jsDoc.deprecated === 'string' ? this._fixLinkTags(jsDoc.deprecated) : jsDoc.deprecated
}\n` }\n`
: '' : ''
} */`, } */`,
).docComment ).docComment
: apiItemMetadata.tsdocComment; : apiItemMetadata.tsdocComment;
const releaseTag: ReleaseTag = apiItemMetadata.effectiveReleaseTag; const releaseTag: ReleaseTag = apiItemMetadata.effectiveReleaseTag;
const isOptional: boolean = (astDeclaration.astSymbol.followedSymbol.flags & ts.SymbolFlags.Optional) !== 0; const isOptional: boolean = (astDeclaration.astSymbol.followedSymbol.flags & ts.SymbolFlags.Optional) !== 0;
@@ -1420,7 +1420,7 @@ export class ApiModelGenerator {
.join('') .join('')
: '' : ''
} */`, } */`,
).docComment ).docComment
: apiItemMetadata.tsdocComment; : apiItemMetadata.tsdocComment;
const releaseTag: ReleaseTag = apiItemMetadata.effectiveReleaseTag; const releaseTag: ReleaseTag = apiItemMetadata.effectiveReleaseTag;
const sourceLocation: ISourceLocation = this._getSourceLocation(typeAliasDeclaration); const sourceLocation: ISourceLocation = this._getSourceLocation(typeAliasDeclaration);
@@ -1554,7 +1554,7 @@ export class ApiModelGenerator {
'deprecated' in jsDoc && jsDoc.deprecated 'deprecated' in jsDoc && jsDoc.deprecated
? ` * @deprecated ${ ? ` * @deprecated ${
typeof jsDoc.deprecated === 'string' ? this._fixLinkTags(jsDoc.deprecated) : jsDoc.deprecated typeof jsDoc.deprecated === 'string' ? this._fixLinkTags(jsDoc.deprecated) : jsDoc.deprecated
}\n` }\n`
: '' : ''
} */`, } */`,
).docComment; ).docComment;

View File

@@ -164,7 +164,7 @@ export class Documentation {
file: member.sources?.[0]?.fileName, file: member.sources?.[0]?.fileName,
line: member.sources?.[0]?.line, line: member.sources?.[0]?.line,
path: dirname(member.sources?.[0]?.fileName ?? ''), path: dirname(member.sources?.[0]?.fileName ?? ''),
}; };
if (prop!.name) { if (prop!.name) {
info.push(`member of "${prop!.name}"`); info.push(`member of "${prop!.name}"`);

View File

@@ -29,7 +29,7 @@ export class DocumentedConstructor extends DocumentedItem<Constructor | Declarat
params: signature.parameters params: signature.parameters
? (signature as SignatureReflection).parameters?.map((param) => ? (signature as SignatureReflection).parameters?.map((param) =>
new DocumentedParam(param, this.config).serialize(), new DocumentedParam(param, this.config).serialize(),
) )
: undefined, : undefined,
}; };
} }

View File

@@ -71,7 +71,7 @@ export class DocumentedEvent extends DocumentedItem<DeclarationReflection | Even
}, },
this.config, this.config,
).serialize(), ).serialize(),
] ]
: undefined, : undefined,
returnsDescription: returnsDescription:
signature.comment?.blockTags signature.comment?.blockTags

View File

@@ -57,7 +57,7 @@ export class DocumentedMethod extends DocumentedItem<DeclarationReflection | Met
params: signature.parameters params: signature.parameters
? (signature as SignatureReflection).parameters?.map((param) => ? (signature as SignatureReflection).parameters?.map((param) =>
new DocumentedParam(param, this.config).serialize(), new DocumentedParam(param, this.config).serialize(),
) )
: undefined, : undefined,
returns: signature.type returns: signature.type
? [ ? [
@@ -74,7 +74,7 @@ export class DocumentedMethod extends DocumentedItem<DeclarationReflection | Met
}, },
this.config, this.config,
).serialize(), ).serialize(),
] ]
: undefined, : undefined,
returnsDescription: returnsDescription:
signature.comment?.blockTags signature.comment?.blockTags
@@ -113,7 +113,7 @@ export class DocumentedMethod extends DocumentedItem<DeclarationReflection | Met
{ names: param.type.names, description: param.description, nullable: param.nullable }, { names: param.type.names, description: param.description, nullable: param.nullable },
this.config, this.config,
).serialize(), ).serialize(),
) )
: undefined, : undefined,
meta: new DocumentedItemMeta(data.meta, this.config).serialize(), meta: new DocumentedItemMeta(data.meta, this.config).serialize(),
}; };

View File

@@ -66,7 +66,7 @@ export class DocumentedTypeDef extends DocumentedItem<DeclarationReflection | Ty
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
.trim() || undefined, .trim() || undefined,
type: [[[(child.type as LiteralType | undefined)?.value]]], type: [[[(child.type as LiteralType | undefined)?.value]]],
})) }))
: undefined, : undefined,
}; };
} }
@@ -99,7 +99,7 @@ export class DocumentedTypeDef extends DocumentedItem<DeclarationReflection | Ty
type: child.type type: child.type
? new DocumentedVarType({ names: [parseType(child.type)] }, this.config).serialize() ? new DocumentedVarType({ names: [parseType(child.type)] }, this.config).serialize()
: child.kindString === 'Method' : child.kindString === 'Method'
? new DocumentedVarType( ? new DocumentedVarType(
{ {
names: [ names: [
parseType({ parseType({
@@ -114,8 +114,8 @@ export class DocumentedTypeDef extends DocumentedItem<DeclarationReflection | Ty
.trim(), .trim(),
}, },
this.config, this.config,
).serialize() ).serialize()
: undefined, : undefined,
})); }));
return { return {
@@ -185,7 +185,7 @@ export class DocumentedTypeDef extends DocumentedItem<DeclarationReflection | Ty
}, },
this.config, this.config,
).serialize(), ).serialize(),
] ]
: undefined, : undefined,
returnsDescription: returnsDescription:
sig?.comment?.blockTags sig?.comment?.blockTags

View File

@@ -93,10 +93,10 @@ export class DiscordAPIError extends Error {
const nextKey = otherKey.startsWith('_') const nextKey = otherKey.startsWith('_')
? key ? key
: key : key
? Number.isNaN(Number(otherKey)) ? Number.isNaN(Number(otherKey))
? `${key}.${otherKey}` ? `${key}.${otherKey}`
: `${key}[${otherKey}]` : `${key}[${otherKey}]`
: otherKey; : otherKey;
if (typeof val === 'string') { if (typeof val === 'string') {
yield val; yield val;