aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rw-r--r--scripts/apidoc/diff.ts6
-rw-r--r--scripts/apidoc/signature.ts39
-rw-r--r--scripts/generateLocales.ts8
3 files changed, 23 insertions, 30 deletions
diff --git a/scripts/apidoc/diff.ts b/scripts/apidoc/diff.ts
index 913062c8..654f44b0 100644
--- a/scripts/apidoc/diff.ts
+++ b/scripts/apidoc/diff.ts
@@ -35,11 +35,7 @@ async function loadLocal(path: string): Promise<DocsApiDiffIndex> {
* @param source The source to load the diff index from.
*/
async function load(source: string): Promise<DocsApiDiffIndex> {
- if (source.startsWith('https://')) {
- return loadRemote(source);
- } else {
- return loadLocal(source);
- }
+ return source.startsWith('https://') ? loadRemote(source) : loadLocal(source);
}
/**
diff --git a/scripts/apidoc/signature.ts b/scripts/apidoc/signature.ts
index 113aba1d..05944ba7 100644
--- a/scripts/apidoc/signature.ts
+++ b/scripts/apidoc/signature.ts
@@ -95,13 +95,13 @@ function mdToHtml(md: string, inline: boolean = false): string {
// Revert some escaped characters for comparison.
if (comparableSanitizedHtml(rawHtml) === comparableSanitizedHtml(safeHtml)) {
return safeHtml;
- } else {
- console.debug('Rejected unsafe md:', md);
- console.error('Rejected unsafe html:', rawHtml);
- console.error('Rejected unsafe html:', comparableSanitizedHtml(rawHtml));
- console.error('Expected safe html:', comparableSanitizedHtml(safeHtml));
- throw new Error('Found unsafe html');
}
+
+ console.debug('Rejected unsafe md:', md);
+ console.error('Rejected unsafe html:', rawHtml);
+ console.error('Rejected unsafe html:', comparableSanitizedHtml(rawHtml));
+ console.error('Expected safe html:', comparableSanitizedHtml(safeHtml));
+ throw new Error('Found unsafe html');
}
export function analyzeSignature(
@@ -264,11 +264,8 @@ function typeToText(type_?: Type, short = false): string {
switch (type.type) {
case 'array': {
const text = typeToText(type.elementType, short);
- if (text.includes('|') || text.includes('{')) {
- return `Array<${text}>`;
- } else {
- return `${text}[]`;
- }
+ const isComplexType = text.includes('|') || text.includes('{');
+ return isComplexType ? `Array<${text}>` : `${text}[]`;
}
case 'union':
@@ -288,20 +285,20 @@ function typeToText(type_?: Type, short = false): string {
!type.name.match(/Char$/)
) {
return typeToText(reflectionType, short);
- } else {
- return type.name;
}
+
+ return type.name;
} else if (type.name === 'LiteralUnion') {
return [
typeToText(type.typeArguments[0], short),
typeToText(type.typeArguments[1], short),
].join(' | ');
- } else {
- return `${type.name}<${type.typeArguments
- .map((t) => typeToText(t, short))
- .join(', ')}>`;
}
+ return `${type.name}<${type.typeArguments
+ .map((t) => typeToText(t, short))
+ .join(', ')}>`;
+
case 'reflection':
return declarationTypeToText(type.declaration, short);
@@ -318,9 +315,9 @@ function typeToText(type_?: Type, short = false): string {
const text = typeToText(type.target, short);
if (short && type.operator === 'readonly') {
return text;
- } else {
- return `${type.operator} ${text}`;
}
+
+ return `${type.operator} ${text}`;
}
default:
@@ -353,10 +350,10 @@ function declarationTypeToText(
return `{\n${list}\n}`;
} else if (declaration.signatures?.length) {
return signatureTypeToText(declaration.signatures[0]);
- } else {
- return declaration.toString();
}
+ return declaration.toString();
+
default:
return declaration.toString();
}
diff --git a/scripts/generateLocales.ts b/scripts/generateLocales.ts
index b721cb90..2af0c46a 100644
--- a/scripts/generateLocales.ts
+++ b/scripts/generateLocales.ts
@@ -102,17 +102,17 @@ function removeTsSuffix(files: string[]): string[] {
function escapeImport(parent: string, module: string): string {
if (['name', 'type', 'switch', parent].includes(module)) {
return `${module}_`;
- } else {
- return module;
}
+
+ return module;
}
function escapeField(parent: string, module: string): string {
if (['name', 'type', 'switch', parent].includes(module)) {
return `${module}: ${module}_`;
- } else {
- return module;
}
+
+ return module;
}
function generateLocaleFile(locale: string): void {