From 1a9fb01bcf64a4016fc8167f51871df1a85b692d Mon Sep 17 00:00:00 2001
From: Vitaly Takmazov
Date: Mon, 8 Apr 2019 20:53:45 +0300
Subject: Cleanup ESLint warnings
---
vnext/src/App.js | 17 ++++++++++++-----
vnext/src/components/Chat.js | 10 ++++++----
vnext/src/components/Input.js | 12 ++++++++++--
vnext/src/components/Message.css | 1 -
vnext/src/components/MessageInput.js | 2 +-
vnext/src/components/Post.js | 2 +-
vnext/src/components/Settings.js | 9 +++++++--
vnext/src/components/Thread.js | 25 ++++++++++++++++---------
vnext/src/components/UserInfo.js | 4 ++--
9 files changed, 55 insertions(+), 27 deletions(-)
(limited to 'vnext')
diff --git a/vnext/src/App.js b/vnext/src/App.js
index 6fcf3d9c..4931af0a 100644
--- a/vnext/src/App.js
+++ b/vnext/src/App.js
@@ -1,4 +1,6 @@
import React, { useState, useEffect } from 'react';
+import PropTypes from 'prop-types';
+import ReactRouterPropTypes from 'react-router-prop-types';
import { BrowserRouter as Router, Route, Link, Switch } from 'react-router-dom';
import qs from 'qs';
@@ -29,7 +31,7 @@ export default function App(props) {
uid: 0,
hash: cookies.load('hash')
});
-
+
let updateStatus = () => {
// refresh server visitor state (unread counters)
me().then(visitor => {
@@ -52,20 +54,20 @@ export default function App(props) {
};
es.onerror = () => {
es.removeEventListener('read', updateStatus);
- }
+ };
setEs(es);
}, []);
-
+
let search = (history, pathname, searchString) => {
let location = {};
location.pathname = pathname;
location.search = `?search=${searchString}`;
history.push(location);
- }
+ };
let auth = (visitor) => {
setVisitor(visitor);
- }
+ };
return (
<>
@@ -157,3 +159,8 @@ export default function App(props) {
);
}
+
+App.propTypes = {
+ match: ReactRouterPropTypes.match.isRequired
+};
+
diff --git a/vnext/src/components/Chat.js b/vnext/src/components/Chat.js
index e2b8d2f1..9ac2f2e5 100644
--- a/vnext/src/components/Chat.js
+++ b/vnext/src/components/Chat.js
@@ -1,4 +1,5 @@
import React, { useEffect, useState } from 'react';
+import PropTypes from 'prop-types';
import ReactRouterPropTypes from 'react-router-prop-types';
import { UserType } from './Types';
import moment from 'moment';
@@ -35,21 +36,21 @@ export default function Chat(props) {
setChats(response.data);
});
}
- }
+ };
let onMessage = (json) => {
const msg = JSON.parse(json.data);
if (msg.user.uname === props.match.params.user) {
setChats([msg, ...chats]);
}
- }
+ };
let onSend = (template) => {
pm(template.to.uname, template.body)
.then(res => {
loadChat(props.match.params.user);
}).catch(console.log);
- }
+ };
const uname = props.match.params.user;
return (
@@ -77,5 +78,6 @@ export default function Chat(props) {
Chat.propTypes = {
visitor: UserType.isRequired,
- match: ReactRouterPropTypes.match.isRequired
+ match: ReactRouterPropTypes.match.isRequired,
+ connection: PropTypes.shape.isRequired
};
diff --git a/vnext/src/components/Input.js b/vnext/src/components/Input.js
index 5c150ec3..c74d595d 100644
--- a/vnext/src/components/Input.js
+++ b/vnext/src/components/Input.js
@@ -1,9 +1,17 @@
import React from 'react';
+import PropTypes from 'prop-types';
import './Input.css';
function Input({ name, value, ...rest }) {
- return(
)
+ return (
+
+ );
}
-export default React.memo(Input);
\ No newline at end of file
+Input.propTypes = {
+ name: PropTypes.string.isRequired,
+ value: PropTypes.string.isRequired
+};
+
+export default React.memo(Input);
diff --git a/vnext/src/components/Message.css b/vnext/src/components/Message.css
index 1522c166..18d3d0d5 100644
--- a/vnext/src/components/Message.css
+++ b/vnext/src/components/Message.css
@@ -208,4 +208,3 @@ blockquote {
.msg-cont .nsfw .ir img:hover {
opacity: 1;
}
-
diff --git a/vnext/src/components/MessageInput.js b/vnext/src/components/MessageInput.js
index 311284cf..ef96b3b5 100644
--- a/vnext/src/components/MessageInput.js
+++ b/vnext/src/components/MessageInput.js
@@ -23,7 +23,7 @@ export default function MessageInput({ text, data, rows, children, onSend }) {
useEffect(() => {
textareaRef.current.value = text || '';
updateFocus();
- }, []);
+ }, [text]);
let handleCtrlEnter = (event) => {
if (event.ctrlKey && (event.charCode == 10 || event.charCode == 13)) {
diff --git a/vnext/src/components/Post.js b/vnext/src/components/Post.js
index 7958c36d..3dc23613 100644
--- a/vnext/src/components/Post.js
+++ b/vnext/src/components/Post.js
@@ -20,7 +20,7 @@ function PostComponent(props) {
this.props.history.push(`/${this.props.visitor.uname}/${msg.mid}`);
}
}).catch(console.log);
- }
+ };
return (
diff --git a/vnext/src/components/Settings.js b/vnext/src/components/Settings.js
index 29d1b4b5..cf6926f8 100644
--- a/vnext/src/components/Settings.js
+++ b/vnext/src/components/Settings.js
@@ -1,5 +1,6 @@
import React, { useState, useEffect, useRef } from 'react';
import PropTypes from 'prop-types';
+import ReactRouterPropTypes from 'react-router-prop-types';
import { me, updateAvatar } from '../api';
@@ -24,7 +25,7 @@ function ChangeAvatarForm({ visitor }) {
};
reader.readAsDataURL(avatarInput.current.files[0]);
}
- }
+ };
let previewUser = { ...visitor, uname: '' };
if (preview) {
previewUser = { ...visitor, avatar: preview, uname: '' };
@@ -39,7 +40,7 @@ function ChangeAvatarForm({ visitor }) {
this.props.onChange(visitor);
});
});
- }
+ };
return (