From c9aefa81ca1950121d2357fc66afe15eb400f537 Mon Sep 17 00:00:00 2001 From: Leonardo Bishop Date: Fri, 15 Mar 2024 00:13:40 +0000 Subject: Fix eslint errors --- components/base/ItemStack/ItemStackForm.vue | 272 ++++++++++++++++++++-------- 1 file changed, 192 insertions(+), 80 deletions(-) (limited to 'components/base/ItemStack/ItemStackForm.vue') diff --git a/components/base/ItemStack/ItemStackForm.vue b/components/base/ItemStack/ItemStackForm.vue index ef13abd..ddf8144 100644 --- a/components/base/ItemStack/ItemStackForm.vue +++ b/components/base/ItemStack/ItemStackForm.vue @@ -16,25 +16,27 @@ const yamlCode = ref(''); const switchToYamlEditor = () => { yamlCode.value = stringify({ - type: model.value.type || model.value.material || model.value.item || "", - ...("name" in model.value && { name: model.value.name }), - ...("lore" in model.value && { lore: model.value.lore }), - ...("enchantments" in model.value && { enchantments: model.value.enchantments }), - ...("itemflags" in model.value && { itemflags: model.value.itemflags }), - ...("custommodeldata" in model.value && { custommodeldata: model.value.custommodeldata }), - ...("unbreakable" in model.value && { unbreakable: model.value.unbreakable }), - ...("attributemodifiers" in model.value && { attributemodifiers: model.value.attributemodifiers }), - ...("owner-base64" in model.value && { ["owner-base64"]: model.value["owner-base64"] }), - ...("owner-username" in model.value && { ["owner-username"]: model.value["owner-username"] }), - ...("owner-uuid" in model.value && { ["owner-uuid"]: model.value["owner-uuid"] }) - }) + type: model.value.type || model.value.material || model.value.item || '', + ...('name' in model.value && { name: model.value.name }), + ...('lore' in model.value && { lore: model.value.lore }), + ...('enchantments' in model.value && { enchantments: model.value.enchantments }), + ...('itemflags' in model.value && { itemflags: model.value.itemflags }), + ...('custommodeldata' in model.value && { custommodeldata: model.value.custommodeldata }), + ...('unbreakable' in model.value && { unbreakable: model.value.unbreakable }), + ...('attributemodifiers' in model.value && { + attributemodifiers: model.value.attributemodifiers, + }), + ...('owner-base64' in model.value && { ['owner-base64']: model.value['owner-base64'] }), + ...('owner-username' in model.value && { ['owner-username']: model.value['owner-username'] }), + ...('owner-uuid' in model.value && { ['owner-uuid']: model.value['owner-uuid'] }), + }); editAsYaml.value = true; -} +}; const switchToGuiEditor = () => { parseAndSetYamlValues(); editAsYaml.value = false; -} +}; const parseAndSetYamlValues = (): boolean => { let newValues; @@ -45,19 +47,31 @@ const parseAndSetYamlValues = (): boolean => { } model.value.type = newValues.type; - if ("name" in newValues) model.value.name = String(newValues.name); - if ("lore" in newValues) model.value.lore = Array.isArray(newValues.lore) ? newValues.lore : [newValues.lore]; - if ("enchantments" in newValues) model.value.enchantments = Array.isArray(newValues.enchantments) ? newValues.enchantments : [newValues.enchantments]; - if ("itemflags" in newValues) model.value.itemflags = Array.isArray(newValues.itemflags) ? newValues.itemflags : [newValues.itemflags]; - if ("custommodeldata" in newValues) model.value.custommodeldata = Number(newValues.custommodeldata) || 0; - if ("unbreakable" in newValues) model.value.unbreakable = !!newValues.unbreakable; - if ("attributemodifiers" in newValues) model.value.attributemodifiers = Array.isArray(newValues.attributemodifiers) ? newValues.attributemodifiers : [newValues.attributemodifiers]; - if ("owner-base64" in newValues) model.value["owner-base64"] = String(newValues["owner-base64"]); - if ("owner-username" in newValues) model.value["owner-username"] = String(newValues["owner-username"]); - if ("owner-uuid" in newValues) model.value["owner-uuid"] = String(newValues["owner-uuid"]); + if ('name' in newValues) model.value.name = String(newValues.name); + if ('lore' in newValues) + model.value.lore = Array.isArray(newValues.lore) ? newValues.lore : [newValues.lore]; + if ('enchantments' in newValues) + model.value.enchantments = Array.isArray(newValues.enchantments) + ? newValues.enchantments + : [newValues.enchantments]; + if ('itemflags' in newValues) + model.value.itemflags = Array.isArray(newValues.itemflags) + ? newValues.itemflags + : [newValues.itemflags]; + if ('custommodeldata' in newValues) + model.value.custommodeldata = Number(newValues.custommodeldata) || 0; + if ('unbreakable' in newValues) model.value.unbreakable = !!newValues.unbreakable; + if ('attributemodifiers' in newValues) + model.value.attributemodifiers = Array.isArray(newValues.attributemodifiers) + ? newValues.attributemodifiers + : [newValues.attributemodifiers]; + if ('owner-base64' in newValues) model.value['owner-base64'] = String(newValues['owner-base64']); + if ('owner-username' in newValues) + model.value['owner-username'] = String(newValues['owner-username']); + if ('owner-uuid' in newValues) model.value['owner-uuid'] = String(newValues['owner-uuid']); return true; -} +}; const itemName = computed({ get() { @@ -70,7 +84,7 @@ const itemName = computed({ const isOptionSet = (option: string) => { return option in model.value; -} +}; const setOption = (option: string, type: 'string' | 'string-list' | 'number' | 'boolean') => { switch (type) { @@ -87,11 +101,11 @@ const setOption = (option: string, type: 'string' | 'string-list' | 'number' | ' model.value[option] = []; break; } -} +}; const removeOption = (option: string) => { delete model.value[option]; -} +}; const itemType = computed({ get() { @@ -114,8 +128,8 @@ const itemLore = computed({ }, set(newValue: string) { model.value.lore = newValue.split('\n'); - } -}) + }, +}); const itemEnchantments = computed({ get() { @@ -123,8 +137,8 @@ const itemEnchantments = computed({ }, set(newValue: any) { model.value.enchantments = newValue; - } -}) + }, +}); const itemCustomModelData = computed({ get() { @@ -132,8 +146,8 @@ const itemCustomModelData = computed({ }, set(newValue: any) { model.value.custommodeldata = newValue; - } -}) + }, +}); const itemItemflags = computed({ get() { @@ -141,8 +155,8 @@ const itemItemflags = computed({ }, set(newValue: any) { model.value.itemflags = newValue; - } -}) + }, +});