Skip to content

Commit 042d6af

Browse files
committed
client: Fix Biome linter warnings
1 parent 95370f7 commit 042d6af

File tree

1 file changed

+25
-14
lines changed

1 file changed

+25
-14
lines changed

client/src/index.tsx

+25-14
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
import React, { useRef, useEffect } from 'react'
22
import { createRoot } from 'react-dom/client'
3-
import { createStore } from 'redux'
43
import { Provider, connect } from 'react-redux'
5-
import { v4 as uuidv4 } from 'uuid'
6-
import ReconnectingWebSocket from 'reconnectingwebsocket'
7-
import { Base64 } from 'js-base64'
8-
import { library, dom } from '@fortawesome/fontawesome-svg-core'
4+
import { createStore } from 'redux'
5+
6+
import { dom, library } from '@fortawesome/fontawesome-svg-core'
97
import { faPencilAlt } from '@fortawesome/free-solid-svg-icons/faPencilAlt'
108
import { faTrash } from '@fortawesome/free-solid-svg-icons/faTrash'
9+
import { Base64 } from 'js-base64'
10+
import ReconnectingWebSocket from 'reconnectingwebsocket'
11+
import { v4 as uuidv4 } from 'uuid'
1112

1213
import nicks from './nicks'
1314

@@ -57,7 +58,8 @@ const init: State = ((_) => {
5758

5859
let init = getBase64Hash()
5960
if (!init) {
60-
setBase64Hash((init = 'general'))
61+
init = 'general'
62+
setBase64Hash(init)
6163
} // Default channel
6264
if (!(init in channels)) {
6365
channels[init] = new_channel()
@@ -83,6 +85,7 @@ type Action = {
8385
}
8486
type Dispatch = (action: Action) => Action
8587

88+
// biome-ignore lint/style/useDefaultParameterLast: This is normal in Redux
8689
const reducer = (state: State = init, action: Action): State => {
8790
const { channel: ch, msg, msg_id, msg_txt } = action
8891
switch (action.type) {
@@ -108,17 +111,19 @@ const reducer = (state: State = init, action: Action): State => {
108111
return state
109112
}
110113

114+
const next = Object.assign({}, state)
115+
111116
// 내가 모르는 채널의 메세지 수정일경우, 무시
112-
if (!(ch in state.channels)) {
117+
if (!(ch in next.channels)) {
113118
return state
114119
}
115120
// 내가 받은적 없는 메세지의 수정일경우, 무시
116-
if (state.channels[ch].get(msg_id) == null) {
121+
const msg = next.channels[ch].get(msg_id)
122+
if (msg == null) {
117123
return state
118124
}
119125

120-
const next = Object.assign({}, state)
121-
next.channels[ch].get(msg_id)!.txt = msg_txt
126+
msg.txt = msg_txt
122127
return next
123128
}
124129
case 'DeleteMsg': {
@@ -223,16 +228,21 @@ const ChannelView = (props: Props) => {
223228
value={txt}
224229
ref={elemEdit}
225230
onBlur={stopEdit}
226-
onChange={() => updateMsg(ch, elemEdit.current!.value, id)}
231+
onChange={() =>
232+
elemEdit.current != null &&
233+
updateMsg(ch, elemEdit.current.value, id)
234+
}
227235
/>
228236
</form>
229237
)}
230238
{is_editable && (
231239
<span className="control">
240+
{/* biome-ignore lint/a11y/useKeyWithClickEvents: TODO: Ensure accessibility by making it usable without a mouse. */}
232241
<span onClick={() => startEdit(id)}>
233242
<i className="fas fa-pencil-alt" />
234243
</span>
235244
&nbsp;
245+
{/* biome-ignore lint/a11y/useKeyWithClickEvents: TODO: Ensure accessibility by making it usable without a mouse. */}
236246
<span onClick={() => deleteMsg(ch, id)}>
237247
<i className="fas fa-trash" />
238248
</span>
@@ -248,8 +258,8 @@ const ChannelView = (props: Props) => {
248258
const View = (props: Props) => {
249259
const { state, createMsg, createChannel, changeChannel } = props
250260

251-
let field = React.createRef<HTMLInputElement>()
252-
let field_channel = React.createRef<HTMLInputElement>()
261+
const field = React.createRef<HTMLInputElement>()
262+
const field_channel = React.createRef<HTMLInputElement>()
253263

254264
const onSubmit = (e: React.FormEvent) => {
255265
e.preventDefault()
@@ -267,7 +277,7 @@ const View = (props: Props) => {
267277
return
268278
}
269279

270-
let ch = field_channel.current.value
280+
const ch = field_channel.current.value
271281
field_channel.current.value = ''
272282
createChannel(ch)
273283
changeChannel(ch)
@@ -281,6 +291,7 @@ const View = (props: Props) => {
281291
</form>
282292
<ul>
283293
{Object.keys(state.channels).map((ch) => (
294+
// biome-ignore lint/a11y/useKeyWithClickEvents: TODO: Ensure accessibility by making it usable without a mouse.
284295
<li
285296
id={ch === state.current_channel ? 'current' : undefined}
286297
key={ch}

0 commit comments

Comments
 (0)