Apply suggestions from code review
authorMatthias Schmidt <gravatronics@live.com>
Tue, 12 Jan 2021 10:25:52 +0000 (11:25 +0100)
committerMatthias Schmidt <gravatronics@live.com>
Tue, 12 Jan 2021 10:25:52 +0000 (11:25 +0100)
wcfsetup/install/files/js/WoltLabSuite/Core/Acp/Form/Builder/Field/Devtools/Project/Instructions.js
wcfsetup/install/files/ts/WoltLabSuite/Core/Acp/Form/Builder/Field/Devtools/Project/AbstractPackageList.ts
wcfsetup/install/files/ts/WoltLabSuite/Core/Acp/Form/Builder/Field/Devtools/Project/Instructions.ts

index 0540afe1ba209a601d6bc7e7c4f5bc72c67749ee..85cafa54539fb3fe66ff75b21f7dea102ff18c67 100644 (file)
@@ -69,7 +69,7 @@ define(["require", "exports", "tslib", "../../../../../../Core", "../../../../..
             event.preventDefault();
             event.stopPropagation();
             const instructionsId = event.currentTarget.closest("li.section").dataset
-                .instrictionsId;
+                .instructionsId;
             // note: data will be validated/filtered by the server
             const pipField = document.getElementById(`${this.formFieldId}_instructions${instructionsId}_pip`);
             // ignore pressing button if no PIP has been selected
index 955a36a22f0429164def99d46bf94ea1a03ad644..d068933962490379b289aa60059deab5d16816d8 100644 (file)
@@ -23,10 +23,10 @@ abstract class AbstractPackageList<TPackageData extends PackageData = PackageDat
   protected readonly packageIdentifier: HTMLInputElement;
 
   // see `wcf\data\package\Package::isValidPackageName()`
-  protected static packageIdentifierRegExp = new RegExp(/^[a-zA-Z0-9_-]+\.[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/);
+  protected static readonly packageIdentifierRegExp = new RegExp(/^[a-zA-Z0-9_-]+\.[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/);
 
   // see `wcf\data\package\Package::isValidVersion()`
-  protected static versionRegExp = new RegExp(
+  protected static readonly versionRegExp = new RegExp(
     /^([0-9]+).([0-9]+)\.([0-9]+)( (a|alpha|b|beta|d|dev|rc|pl) ([0-9]+))?$/i,
   );
 
index 1c782b862f9b329b096c9c38eeea30c4cdb34eff..eafe90534937f3f4f7d2daad292592e424132797 100644 (file)
@@ -30,10 +30,12 @@ interface InstructionsData {
   errors?: string[];
   fromVersion?: string;
   instructions?: Instruction[];
-  type: "install" | "update";
+  type: InstructionsType;
 }
 
+type InstructionsType = "install" | "update";
 type InstructionsId = number | string;
+type PipFilenameMap = { [k: string]: string };
 
 class Instructions {
   protected readonly addButton: HTMLAnchorElement;
@@ -47,15 +49,15 @@ class Instructions {
   protected readonly instructionsType: HTMLSelectElement;
   protected readonly instructionsTemplate: Template;
   protected readonly instructionEditDialogTemplate: Template;
-  protected readonly pipDefaultFilenames: { [k: string]: string };
+  protected readonly pipDefaultFilenames: PipFilenameMap;
 
-  protected static applicationPips = ["acpTemplate", "file", "script", "template"];
+  protected static readonly applicationPips = ["acpTemplate", "file", "script", "template"];
 
   // see `wcf\data\package\Package::isValidPackageName()`
-  protected static packageIdentifierRegExp = new RegExp(/^[a-zA-Z0-9_-]+\.[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/);
+  protected static readonly packageIdentifierRegExp = new RegExp(/^[a-zA-Z0-9_-]+\.[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/);
 
   // see `wcf\data\package\Package::isValidVersion()`
-  protected static versionRegExp = new RegExp(
+  protected static readonly versionRegExp = new RegExp(
     /^([0-9]+).([0-9]+)\.([0-9]+)( (a|alpha|b|beta|d|dev|rc|pl) ([0-9]+))?$/i,
   );
 
@@ -64,7 +66,7 @@ class Instructions {
     instructionsTemplate: Template,
     instructionsEditDialogTemplate: Template,
     instructionEditDialogTemplate: Template,
-    pipDefaultFilenames: { [k: string]: string },
+    pipDefaultFilenames: PipFilenameMap,
     existingInstructions: InstructionsData[],
   ) {
     this.formFieldId = formFieldId;
@@ -126,7 +128,7 @@ class Instructions {
     event.stopPropagation();
 
     const instructionsId = ((event.currentTarget as HTMLElement).closest("li.section") as HTMLElement).dataset
-      .instrictionsId!;
+      .instructionsId!;
 
     // note: data will be validated/filtered by the server
 
@@ -244,7 +246,7 @@ class Instructions {
 
     this.addInstructionsByData({
       fromVersion: this.instructionsType.value === "update" ? this.fromVersion.value : "",
-      type: this.instructionsType.value as "install" | "update",
+      type: this.instructionsType.value as InstructionsType,
     });
 
     // empty fields