From a273940348c662bd2968a0a221e9313fc80e5707 Mon Sep 17 00:00:00 2001 From: Andreas Nedbal Date: Thu, 19 May 2022 10:35:43 +0200 Subject: [PATCH] fix(client): fix lint issues in Deck UI components (#8681) --- .../client/src/ui/deck/antenna-column.vue | 4 +-- packages/client/src/ui/deck/column-core.vue | 2 +- packages/client/src/ui/deck/column.vue | 26 +++++++++---------- packages/client/src/ui/deck/deck-store.ts | 18 ++++++------- packages/client/src/ui/deck/direct-column.vue | 2 +- packages/client/src/ui/deck/list-column.vue | 4 +-- packages/client/src/ui/deck/main-column.vue | 2 +- .../client/src/ui/deck/mentions-column.vue | 2 +- .../src/ui/deck/notifications-column.vue | 2 +- packages/client/src/ui/deck/tl-column.vue | 4 +-- .../client/src/ui/deck/widgets-column.vue | 2 +- 11 files changed, 34 insertions(+), 34 deletions(-) diff --git a/packages/client/src/ui/deck/antenna-column.vue b/packages/client/src/ui/deck/antenna-column.vue index e0f56c2800..f12f5c6b25 100644 --- a/packages/client/src/ui/deck/antenna-column.vue +++ b/packages/client/src/ui/deck/antenna-column.vue @@ -22,8 +22,8 @@ const props = defineProps<{ }>(); const emit = defineEmits<{ - (e: 'loaded'): void; - (e: 'parent-focus', direction: 'up' | 'down' | 'left' | 'right'): void; + (ev: 'loaded'): void; + (ev: 'parent-focus', direction: 'up' | 'down' | 'left' | 'right'): void; }>(); let timeline = $ref>(); diff --git a/packages/client/src/ui/deck/column-core.vue b/packages/client/src/ui/deck/column-core.vue index 485e89a062..2667b6d745 100644 --- a/packages/client/src/ui/deck/column-core.vue +++ b/packages/client/src/ui/deck/column-core.vue @@ -29,7 +29,7 @@ defineProps<{ }>(); const emit = defineEmits<{ - (e: 'parent-focus', direction: 'up' | 'down' | 'left' | 'right'): void; + (ev: 'parent-focus', direction: 'up' | 'down' | 'left' | 'right'): void; }>(); /* diff --git a/packages/client/src/ui/deck/column.vue b/packages/client/src/ui/deck/column.vue index 5f8da8cf8f..fbaea64f56 100644 --- a/packages/client/src/ui/deck/column.vue +++ b/packages/client/src/ui/deck/column.vue @@ -61,8 +61,8 @@ const props = withDefaults(defineProps<{ }); const emit = defineEmits<{ - (e: 'parent-focus', direction: 'up' | 'down' | 'left' | 'right'): void; - (e: 'change-active-state', v: boolean): void; + (ev: 'parent-focus', direction: 'up' | 'down' | 'left' | 'right'): void; + (ev: 'change-active-state', v: boolean): void; }>(); let body = $ref(); @@ -193,9 +193,9 @@ function goTop() { }); } -function onDragstart(e) { - e.dataTransfer.effectAllowed = 'move'; - e.dataTransfer.setData(_DATA_TRANSFER_DECK_COLUMN_, props.column.id); +function onDragstart(ev) { + ev.dataTransfer.effectAllowed = 'move'; + ev.dataTransfer.setData(_DATA_TRANSFER_DECK_COLUMN_, props.column.id); // Chromeのバグで、Dragstartハンドラ内ですぐにDOMを変更する(=リアクティブなプロパティを変更する)とDragが終了してしまう // SEE: https://stackoverflow.com/questions/19639969/html5-dragend-event-firing-immediately @@ -204,21 +204,21 @@ function onDragstart(e) { }, 10); } -function onDragend(e) { +function onDragend(ev) { dragging = false; } -function onDragover(e) { +function onDragover(ev) { // 自分自身がドラッグされている場合 if (dragging) { // 自分自身にはドロップさせない - e.dataTransfer.dropEffect = 'none'; + ev.dataTransfer.dropEffect = 'none'; return; } - const isDeckColumn = e.dataTransfer.types[0] == _DATA_TRANSFER_DECK_COLUMN_; + const isDeckColumn = ev.dataTransfer.types[0] === _DATA_TRANSFER_DECK_COLUMN_; - e.dataTransfer.dropEffect = isDeckColumn ? 'move' : 'none'; + ev.dataTransfer.dropEffect = isDeckColumn ? 'move' : 'none'; if (!dragging && isDeckColumn) draghover = true; } @@ -227,12 +227,12 @@ function onDragleave() { draghover = false; } -function onDrop(e) { +function onDrop(ev) { draghover = false; os.deckGlobalEvents.emit('column.dragEnd'); - const id = e.dataTransfer.getData(_DATA_TRANSFER_DECK_COLUMN_); - if (id != null && id != '') { + const id = ev.dataTransfer.getData(_DATA_TRANSFER_DECK_COLUMN_); + if (id != null && id !== '') { swapColumn(props.column.id, id); } } diff --git a/packages/client/src/ui/deck/deck-store.ts b/packages/client/src/ui/deck/deck-store.ts index f7c39ad8fd..c2c9ae540b 100644 --- a/packages/client/src/ui/deck/deck-store.ts +++ b/packages/client/src/ui/deck/deck-store.ts @@ -72,8 +72,8 @@ export const loadDeck = async () => { scope: ['client', 'deck', 'profiles'], key: deckStore.state.profile, }); - } catch (e) { - if (e.code === 'NO_SUCH_KEY') { + } catch (err) { + if (err.code === 'NO_SUCH_KEY') { // 後方互換性のため if (deckStore.state.profile === 'default') { saveDeck(); @@ -94,7 +94,7 @@ export const loadDeck = async () => { deckStore.set('layout', [['a'], ['b']]); return; } - throw e; + throw err; } deckStore.set('columns', deck.columns); @@ -114,7 +114,7 @@ export const saveDeck = throttle(1000, () => { }); export function addColumn(column: Column) { - if (column.name == undefined) column.name = null; + if (column.name === undefined) column.name = null; deckStore.push('columns', column); deckStore.push('layout', [column.id]); saveDeck(); @@ -129,10 +129,10 @@ export function removeColumn(id: Column['id']) { } export function swapColumn(a: Column['id'], b: Column['id']) { - const aX = deckStore.state.layout.findIndex(ids => ids.indexOf(a) != -1); - const aY = deckStore.state.layout[aX].findIndex(id => id == a); - const bX = deckStore.state.layout.findIndex(ids => ids.indexOf(b) != -1); - const bY = deckStore.state.layout[bX].findIndex(id => id == b); + const aX = deckStore.state.layout.findIndex(ids => ids.indexOf(a) !== -1); + const aY = deckStore.state.layout[aX].findIndex(id => id === a); + const bX = deckStore.state.layout.findIndex(ids => ids.indexOf(b) !== -1); + const bY = deckStore.state.layout[bX].findIndex(id => id === b); const layout = copy(deckStore.state.layout); layout[aX][aY] = b; layout[bX][bY] = a; @@ -259,7 +259,7 @@ export function removeColumnWidget(id: Column['id'], widget: ColumnWidget) { const columnIndex = deckStore.state.columns.findIndex(c => c.id === id); const column = copy(deckStore.state.columns[columnIndex]); if (column == null) return; - column.widgets = column.widgets.filter(w => w.id != widget.id); + column.widgets = column.widgets.filter(w => w.id !== widget.id); columns[columnIndex] = column; deckStore.set('columns', columns); saveDeck(); diff --git a/packages/client/src/ui/deck/direct-column.vue b/packages/client/src/ui/deck/direct-column.vue index ebaba574f4..4837c0ce38 100644 --- a/packages/client/src/ui/deck/direct-column.vue +++ b/packages/client/src/ui/deck/direct-column.vue @@ -18,7 +18,7 @@ defineProps<{ }>(); const emit = defineEmits<{ - (e: 'parent-focus', direction: 'up' | 'down' | 'left' | 'right'): void; + (ev: 'parent-focus', direction: 'up' | 'down' | 'left' | 'right'): void; }>(); const pagination = { diff --git a/packages/client/src/ui/deck/list-column.vue b/packages/client/src/ui/deck/list-column.vue index b990516d05..843a3bd1cb 100644 --- a/packages/client/src/ui/deck/list-column.vue +++ b/packages/client/src/ui/deck/list-column.vue @@ -22,8 +22,8 @@ const props = defineProps<{ }>(); const emit = defineEmits<{ - (e: 'loaded'): void; - (e: 'parent-focus', direction: 'up' | 'down' | 'left' | 'right'): void; + (ev: 'loaded'): void; + (ev: 'parent-focus', direction: 'up' | 'down' | 'left' | 'right'): void; }>(); let timeline = $ref>(); diff --git a/packages/client/src/ui/deck/main-column.vue b/packages/client/src/ui/deck/main-column.vue index 57caab44cb..3c97cd4867 100644 --- a/packages/client/src/ui/deck/main-column.vue +++ b/packages/client/src/ui/deck/main-column.vue @@ -35,7 +35,7 @@ defineProps<{ }>(); const emit = defineEmits<{ - (e: 'parent-focus', direction: 'up' | 'down' | 'left' | 'right'): void; + (ev: 'parent-focus', direction: 'up' | 'down' | 'left' | 'right'): void; }>(); let pageInfo = $ref | null>(null); diff --git a/packages/client/src/ui/deck/mentions-column.vue b/packages/client/src/ui/deck/mentions-column.vue index a7a012a7fb..0b6ca3a239 100644 --- a/packages/client/src/ui/deck/mentions-column.vue +++ b/packages/client/src/ui/deck/mentions-column.vue @@ -18,7 +18,7 @@ defineProps<{ }>(); const emit = defineEmits<{ - (e: 'parent-focus', direction: 'up' | 'down' | 'left' | 'right'): void; + (ev: 'parent-focus', direction: 'up' | 'down' | 'left' | 'right'): void; }>(); const pagination = { diff --git a/packages/client/src/ui/deck/notifications-column.vue b/packages/client/src/ui/deck/notifications-column.vue index 89d618382e..6dd040cb8d 100644 --- a/packages/client/src/ui/deck/notifications-column.vue +++ b/packages/client/src/ui/deck/notifications-column.vue @@ -20,7 +20,7 @@ const props = defineProps<{ }>(); const emit = defineEmits<{ - (e: 'parent-focus', direction: 'up' | 'down' | 'left' | 'right'): void; + (ev: 'parent-focus', direction: 'up' | 'down' | 'left' | 'right'): void; }>(); function func() { diff --git a/packages/client/src/ui/deck/tl-column.vue b/packages/client/src/ui/deck/tl-column.vue index 02b9ef83a1..f3ecda5aa4 100644 --- a/packages/client/src/ui/deck/tl-column.vue +++ b/packages/client/src/ui/deck/tl-column.vue @@ -35,8 +35,8 @@ const props = defineProps<{ }>(); const emit = defineEmits<{ - (e: 'loaded'): void; - (e: 'parent-focus', direction: 'up' | 'down' | 'left' | 'right'): void; + (ev: 'loaded'): void; + (ev: 'parent-focus', direction: 'up' | 'down' | 'left' | 'right'): void; }>(); let disabled = $ref(false); diff --git a/packages/client/src/ui/deck/widgets-column.vue b/packages/client/src/ui/deck/widgets-column.vue index 904cfb58d6..10c6f5adf6 100644 --- a/packages/client/src/ui/deck/widgets-column.vue +++ b/packages/client/src/ui/deck/widgets-column.vue @@ -20,7 +20,7 @@ const props = defineProps<{ }>(); const emit = defineEmits<{ - (e: 'parent-focus', direction: 'up' | 'down' | 'left' | 'right'): void; + (ev: 'parent-focus', direction: 'up' | 'down' | 'left' | 'right'): void; }>(); let edit = $ref(false);