From becb0cc2701517287b5e87bd8c758c74a7fa7a8d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bence=20Nagygy=C3=B6rgy?= <robot9706@gmail.com>
Date: Wed, 4 Dec 2024 12:50:09 +0100
Subject: [PATCH] fix: lint

---
 web/crux-ui/src/validations/container.ts | 46 ++++++++++++------------
 web/crux/src/app/image/image.service.ts  |  4 +--
 web/crux/src/domain/validation.ts        |  8 ++---
 3 files changed, 30 insertions(+), 28 deletions(-)

diff --git a/web/crux-ui/src/validations/container.ts b/web/crux-ui/src/validations/container.ts
index 79a25f6f0..bcc35d3e5 100644
--- a/web/crux-ui/src/validations/container.ts
+++ b/web/crux-ui/src/validations/container.ts
@@ -503,28 +503,30 @@ const testRules = (rules: [string, EnvironmentRule][], arr: UniqueKeyValue[], fi
 }
 
 const createContainerConfigBaseSchema = (imageLabels: Record<string, string>) =>
-  yup.object().shape({
-    name: matchContainerName(yup.string().nullable().optional().label('container:common.containerName')),
-    environment: uniqueKeyValuesSchema
-      .default(null)
-      .nullable()
-      .optional()
-      .label('container:common.environment')
-      .test('ruleValidation', 'errors:yup.mixed.required', testEnvironment(imageLabels)),
-    routing: routingRule,
-    expose: exposeRule,
-    user: yup.number().default(null).min(UID_MIN).max(UID_MAX).nullable().optional().label('container:common.user'),
-    workingDirectory: yup.string().default(null).nullable().optional().label('container:common.workingDirectory'),
-    tty: yup.boolean().default(null).nullable().optional().label('container:common.tty'),
-    configContainer: configContainerRule,
-    ports: portConfigRule,
-    portRanges: portRangeConfigRule,
-    volumes: volumeConfigRule,
-    commands: shellCommandSchema.default(null).nullable().optional(),
-    args: shellCommandSchema.default(null).nullable().optional(),
-    initContainers: initContainerRule,
-    capabilities: uniqueKeyValuesSchema.default(null).nullable().optional().label('container:common.capabilities'),
-    storage: storageRule,
+  yup
+    .object()
+    .shape({
+      name: matchContainerName(yup.string().nullable().optional().label('container:common.containerName')),
+      environment: uniqueKeyValuesSchema
+        .default(null)
+        .nullable()
+        .optional()
+        .label('container:common.environment')
+        .test('ruleValidation', 'errors:yup.mixed.required', testEnvironment(imageLabels)),
+      routing: routingRule,
+      expose: exposeRule,
+      user: yup.number().default(null).min(UID_MIN).max(UID_MAX).nullable().optional().label('container:common.user'),
+      workingDirectory: yup.string().default(null).nullable().optional().label('container:common.workingDirectory'),
+      tty: yup.boolean().default(null).nullable().optional().label('container:common.tty'),
+      configContainer: configContainerRule,
+      ports: portConfigRule,
+      portRanges: portRangeConfigRule,
+      volumes: volumeConfigRule,
+      commands: shellCommandSchema.default(null).nullable().optional(),
+      args: shellCommandSchema.default(null).nullable().optional(),
+      initContainers: initContainerRule,
+      capabilities: uniqueKeyValuesSchema.default(null).nullable().optional().label('container:common.capabilities'),
+      storage: storageRule,
 
       // dagent:
       logConfig: logConfigRule,
diff --git a/web/crux/src/app/image/image.service.ts b/web/crux/src/app/image/image.service.ts
index fd63f8e21..d55206abc 100644
--- a/web/crux/src/app/image/image.service.ts
+++ b/web/crux/src/app/image/image.service.ts
@@ -318,7 +318,7 @@ export default class ImageService {
       }, {}) ?? {}
 
     const mergedEnv = Object.entries(rules)
-      .filter(([_, rule]) => !rule.secret)
+      .filter(([, rule]) => !rule.secret)
       .reduce((map, it) => {
         const [key, rule] = it
 
@@ -345,7 +345,7 @@ export default class ImageService {
       }, {}) ?? {}
 
     const mergedSecrets = Object.entries(rules)
-      .filter(([_, rule]) => rule.secret)
+      .filter(([, rule]) => rule.secret)
       .reduce((map, it) => {
         const [key, rule] = it
 
diff --git a/web/crux/src/domain/validation.ts b/web/crux/src/domain/validation.ts
index 1950df8d2..c785a2870 100644
--- a/web/crux/src/domain/validation.ts
+++ b/web/crux/src/domain/validation.ts
@@ -398,14 +398,14 @@ const validateLabelRule = (rule: EnvironmentRule, field: string, env: KeyValueLi
 }
 
 const testRules = (rules: [string, EnvironmentRule][], arr: UniqueKeyValue[], fieldName: string) => {
-  if (rules.length == 0) {
+  if (rules.length === 0) {
     return null
   }
 
   const requiredKeys = rules.map(([key]) => key)
   const foundKeys = arr.map(it => it.key)
 
-  if (requiredKeys.length > 0 && (!arr || arr.length == 0)) {
+  if (requiredKeys.length > 0 && (!arr || arr.length === 0)) {
     return new yup.ValidationError('errors:yup.mixed.required', fieldName, fieldName)
   }
 
@@ -472,8 +472,8 @@ export const createStartDeploymentSchema = (instanceValidation: Record<string, I
 
             const requiredRules = Object.entries(validation.environmentRules).filter(([, rule]) => rule.required)
 
-            const envRules = requiredRules.filter(([_, rule]) => !rule.secret)
-            const secretRules = requiredRules.filter(([_, rule]) => rule.secret)
+            const envRules = requiredRules.filter(([, rule]) => !rule.secret)
+            const secretRules = requiredRules.filter(([, rule]) => rule.secret)
 
             const envError = testRules(envRules, it.config.environment as UniqueKeyValue[], 'environment')
             if (envError) {