Skip to content

Commit 8ce4f72

Browse files
committed
(demo) fix lint errors
1 parent fa59fb6 commit 8ce4f72

File tree

4 files changed

+93
-56
lines changed

4 files changed

+93
-56
lines changed

demo/.eslintrc.js

Lines changed: 37 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,39 @@
11
module.exports = {
2-
root: true,
3-
env: {
4-
node: true
5-
},
6-
extends: ['plugin:vue/essential', 'eslint:recommended'],
7-
rules: {
8-
'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off',
9-
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
10-
'no-empty-pattern': 'off',
11-
'no-unused-vars': 'warn'
12-
},
13-
parserOptions: {
14-
parser: 'babel-eslint'
15-
}
2+
root: true,
3+
env: {
4+
node: true
5+
},
6+
extends: ['standard', 'plugin:vue/recommended'],
7+
rules: {
8+
'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off',
9+
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
10+
'vue/no-unused-properties': [
11+
'error',
12+
{
13+
groups: ['props', 'data', 'computed', 'methods', 'setup'],
14+
deepData: true
15+
}
16+
],
17+
'no-empty-pattern': 'off',
18+
'no-unused-vars': 'warn',
19+
'valid-typeof': 'off',
20+
indent: 'off',
21+
'no-tabs': 'off',
22+
'vue/html-indent': 'off',
23+
'space-before-function-paren': 'off',
24+
'vue/max-attributes-per-line': 'off',
25+
'vue/html-self-closing': [
26+
'error',
27+
{
28+
html: {
29+
void: 'always',
30+
normal: 'always',
31+
component: 'always'
32+
}
33+
}
34+
]
35+
},
36+
parserOptions: {
37+
parser: 'babel-eslint'
38+
}
1639
}

demo/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"@vue/eslint-config-standard": "^4.0.0",
2626
"babel-eslint": "^10.0.3",
2727
"eslint": "^6.7.2",
28-
"eslint-plugin-vue": "^6.2.2",
28+
"eslint-plugin-vue": "^7.5.0",
2929
"node-sass": "^4.14.1",
3030
"sass-loader": "^10.1.1",
3131
"vue-template-compiler": "^2.6.11"

demo/src/App.vue

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,25 @@
99
<button @click="addData" :disabled="updatingData">Add Data</button>
1010
</div> -->
1111
<span
12+
v-if="showOptions"
1213
class="user-logged"
1314
:class="{ 'user-logged-dark': theme === 'dark' }"
14-
v-if="showOptions"
1515
>
1616
Logged as
1717
</span>
18-
<select v-model="currentUserId" v-if="showOptions">
18+
<select v-if="showOptions" v-model="currentUserId">
1919
<option v-for="user in users" :key="user._id" :value="user._id">
2020
{{ user.username }}
2121
</option>
2222
</select>
2323

24-
<div class="button-theme" v-if="showOptions">
25-
<button @click="theme = 'light'" class="button-light">Light</button>
26-
<button @click="theme = 'dark'" class="button-dark">Dark</button>
24+
<div v-if="showOptions" class="button-theme">
25+
<button class="button-light" @click="theme = 'light'">
26+
Light
27+
</button>
28+
<button class="button-dark" @click="theme = 'dark'">
29+
Dark
30+
</button>
2731
<button class="button-github">
2832
<a href="https://github.com/antoine92190/vue-advanced-chat">
2933
<img src="@/assets/github.svg" />
@@ -32,11 +36,11 @@
3236
</div>
3337

3438
<chat-container
35-
:currentUserId="currentUserId"
39+
v-if="showChat"
40+
:current-user-id="currentUserId"
3641
:theme="theme"
37-
:isDevice="isDevice"
42+
:is-device="isDevice"
3843
@show-demo-options="showDemoOptions = $event"
39-
v-if="showChat"
4044
/>
4145

4246
<!-- <div class="version-container">
@@ -84,11 +88,10 @@ export default {
8488
}
8589
},
8690
87-
mounted() {
88-
this.isDevice = window.innerWidth < 500
89-
window.addEventListener('resize', ev => {
90-
if (ev.isTrusted) this.isDevice = window.innerWidth < 500
91-
})
91+
computed: {
92+
showOptions() {
93+
return !this.isDevice || this.showDemoOptions
94+
}
9295
},
9396
9497
watch: {
@@ -98,10 +101,11 @@ export default {
98101
}
99102
},
100103
101-
computed: {
102-
showOptions() {
103-
return !this.isDevice || this.showDemoOptions
104-
}
104+
mounted() {
105+
this.isDevice = window.innerWidth < 500
106+
window.addEventListener('resize', ev => {
107+
if (ev.isTrusted) this.isDevice = window.innerWidth < 500
108+
})
105109
},
106110
107111
methods: {

demo/src/ChatContainer.vue

Lines changed: 34 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<template>
22
<div class="window-container" :class="{ 'window-mobile': isDevice }">
3-
<form @submit.prevent="createRoom" v-if="addNewRoom">
4-
<input type="text" placeholder="Add username" v-model="addRoomUsername" />
3+
<form v-if="addNewRoom" @submit.prevent="createRoom">
4+
<input v-model="addRoomUsername" type="text" placeholder="Add username" />
55
<button type="submit" :disabled="disableForm || !addRoomUsername">
66
Create Room
77
</button>
@@ -10,8 +10,8 @@
1010
</button>
1111
</form>
1212

13-
<form @submit.prevent="addRoomUser" v-if="inviteRoomId">
14-
<input type="text" placeholder="Add username" v-model="invitedUsername" />
13+
<form v-if="inviteRoomId" @submit.prevent="addRoomUser">
14+
<inpu v-model="invitedUsername" type="text" placeholder="Add username" />
1515
<button type="submit" :disabled="disableForm || !invitedUsername">
1616
Add User
1717
</button>
@@ -20,9 +20,11 @@
2020
</button>
2121
</form>
2222

23-
<form @submit.prevent="deleteRoomUser" v-if="removeRoomId">
23+
<form v-if="removeRoomId" @submit.prevent="deleteRoomUser">
2424
<select v-model="removeUserId">
25-
<option default value="">Select User</option>
25+
<option default value="">
26+
Select User
27+
</option>
2628
<option v-for="user in removeUsers" :key="user._id" :value="user._id">
2729
{{ user.username }}
2830
</option>
@@ -91,7 +93,11 @@ export default {
9193
ChatWindow
9294
},
9395
94-
props: ['currentUserId', 'theme', 'isDevice'],
96+
props: {
97+
currentUserId: { type: String, required: true },
98+
theme: { type: String, required: true },
99+
isDevice: { type: Boolean, required: true }
100+
},
95101
96102
data() {
97103
return {
@@ -138,15 +144,6 @@ export default {
138144
}
139145
},
140146
141-
mounted() {
142-
this.fetchRooms()
143-
this.updateUserOnlineStatus()
144-
},
145-
146-
destroyed() {
147-
this.resetRooms()
148-
},
149-
150147
computed: {
151148
loadedRooms() {
152149
return this.rooms.slice(0, this.roomsLoadedCount)
@@ -156,6 +153,15 @@ export default {
156153
}
157154
},
158155
156+
mounted() {
157+
this.fetchRooms()
158+
this.updateUserOnlineStatus()
159+
},
160+
161+
destroyed() {
162+
this.resetRooms()
163+
},
164+
159165
methods: {
160166
resetRooms() {
161167
this.loadingRooms = true
@@ -311,9 +317,10 @@ export default {
311317
if (!message.timestamp) return
312318
313319
let content = message.content
314-
if (message.file)
320+
if (message.file) {
315321
content = `${message.file.name}.${message.file.extension ||
316322
message.file.type}`
323+
}
317324
318325
return {
319326
...message,
@@ -346,8 +353,9 @@ export default {
346353
this.roomId = room.roomId
347354
}
348355
349-
if (this.endMessages && !this.startMessages)
356+
if (this.endMessages && !this.startMessages) {
350357
return (this.messagesLoaded = true)
358+
}
351359
352360
let ref = messagesRef(room.roomId)
353361
@@ -368,10 +376,12 @@ export default {
368376
369377
let listenerQuery = ref.orderBy('timestamp')
370378
371-
if (this.startMessages)
379+
if (this.startMessages) {
372380
listenerQuery = listenerQuery.startAfter(this.startMessages)
373-
if (this.endMessages)
381+
}
382+
if (this.endMessages) {
374383
listenerQuery = listenerQuery.endAt(this.endMessages)
384+
}
375385
376386
if (options.reset) this.messages = []
377387
@@ -421,12 +431,12 @@ export default {
421431
user => message.data().sender_id === user._id
422432
)
423433
424-
const { sender_id, timestamp } = message.data()
434+
const { timestamp } = message.data()
425435
426436
return {
427437
...message.data(),
428438
...{
429-
senderId: sender_id,
439+
senderId: message.data().sender_id,
430440
_id: message.id,
431441
seconds: timestamp.seconds,
432442
timestamp: parseTimestamp(timestamp, 'HH:mm'),
@@ -595,7 +605,7 @@ export default {
595605
await messagesRef(roomId)
596606
.doc(messageId)
597607
.update({
598-
['file.url']: url
608+
'file.url': url
599609
})
600610
},
601611
@@ -677,7 +687,7 @@ export default {
677687
.database()
678688
.ref('.info/connected')
679689
.on('value', snapshot => {
680-
if (snapshot.val() == false) return
690+
if (snapshot.val() === false) return
681691
682692
userStatusRef
683693
.onDisconnect()

0 commit comments

Comments
 (0)