aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2023-05-19 02:39:47 +0300
committerGravatar Vitaly Takmazov2023-05-19 02:54:34 +0300
commit71acbc9791ad42f99757feb9ed03e208fd09aa70 (patch)
tree02be8ff9af14bcc3592c442c95fe1596391856f6
parent56c7241c2ff3e62b2f6f8064f985181f4387dd3d (diff)
Fix linter warnings
-rw-r--r--package.json2
-rw-r--r--vnext/server/common/MessageUtils.js8
-rw-r--r--vnext/server/middleware/event.js6
-rw-r--r--vnext/server/middleware/oembed.js1
-rw-r--r--vnext/server/middleware/urlexpand.js1
-rw-r--r--vnext/src/api/index.js8
-rw-r--r--vnext/src/ui/Avatar.js1
-rw-r--r--vnext/src/ui/Chat.js1
-rw-r--r--vnext/src/ui/Contact.js1
-rw-r--r--vnext/src/ui/Icon.js1
-rw-r--r--vnext/src/ui/Login.js1
-rw-r--r--vnext/src/ui/Message.js2
-rw-r--r--vnext/src/ui/MessageInput.js2
-rw-r--r--vnext/src/ui/Settings.js38
-rw-r--r--vnext/src/ui/Thread.js5
-rw-r--r--vnext/src/ui/UploadButton.js1
-rw-r--r--vnext/src/ui/UserInfo.js3
-rw-r--r--vnext/src/ui/Users.js1
-rw-r--r--vnext/src/ui/VisitorContext.js1
-rw-r--r--vnext/src/utils/embed.js5
20 files changed, 24 insertions, 65 deletions
diff --git a/package.json b/package.json
index 60c10a14..cdcbd35b 100644
--- a/package.json
+++ b/package.json
@@ -10,7 +10,7 @@
"vnext:build:ssr": "npm run vnext:build && webpack -c vnext/server/webpack.config.js --mode production",
"vnext:start-ssr": "npm run vnext:build:ssr && cross-env DEBUG=http node --enable-source-maps public/server.js",
"vnext:start": "cross-env NODE_ENV=development webpack serve -c vnext/webpack.config.js --mode development",
- "vnext:lint": "eslint vnext/src/**/*.js"
+ "vnext:lint": "eslint vnext/src/**/*.js vnext/server/**/*.js"
},
"repository": {
"type": "git",
diff --git a/vnext/server/common/MessageUtils.js b/vnext/server/common/MessageUtils.js
index 74638c02..b7ed8ec0 100644
--- a/vnext/server/common/MessageUtils.js
+++ b/vnext/server/common/MessageUtils.js
@@ -1,8 +1,5 @@
-import config from 'config';
-
/**
* check if message is PM
- *
* @param {import('../../src/api').Message} msg message
*/
export function isPM(msg) {
@@ -11,7 +8,6 @@ import config from 'config';
/**
* check if message is reply
- *
* @param {import('../../src/api').Message} msg message
*/
export function isReply(msg) {
@@ -20,7 +16,6 @@ export function isReply(msg) {
/**
* check if message is service one
- *
* @param {import('../../src/api').Message} msg message
*/
export function isService(msg) {
@@ -29,7 +24,6 @@ export function isService(msg) {
/**
* format notification title
- *
* @param {import('../../src/api').Message} msg message
* @returns {string} formatted title
*/
@@ -44,7 +38,6 @@ export function formatTitle(msg) {
/**
* format notification quote
- *
* @param { import('../../src/api').Message } msg message
* @returns {string} formatted quote line
*/
@@ -59,7 +52,6 @@ export function formatQuote(msg) {
/**
* format notification body
- *
* @param {import('../../src/api').Message} msg message
* @returns {string} formatted body
*/
diff --git a/vnext/server/middleware/event.js b/vnext/server/middleware/event.js
index 136ae268..5681eb59 100644
--- a/vnext/server/middleware/event.js
+++ b/vnext/server/middleware/event.js
@@ -12,7 +12,6 @@ const allSandboxIds = [];
/**
* handle message event
- *
* @param {import('../../client').Message} msg message
*/
function processMessageEvent(msg) {
@@ -45,14 +44,15 @@ function processMessageEvent(msg) {
.filter(t => t.type === 'hcm')
.map(t => t.token);
log(`${user.uname}: ${hmsIds}`);
- send(msg, hmsIds).then(() => {}).catch(log);
+ send(msg, hmsIds).then(() => {
+ // TODO: handle results
+ }).catch(log);
});
}).catch(log);
}
/**
* Handle new events
- *
* @type {import('express').RequestParamHandler}
*/
export default function handleMessage(req, res) {
diff --git a/vnext/server/middleware/oembed.js b/vnext/server/middleware/oembed.js
index 4ac2d337..8b1ed61d 100644
--- a/vnext/server/middleware/oembed.js
+++ b/vnext/server/middleware/oembed.js
@@ -2,7 +2,6 @@ import { embeddedTweet } from '../../src/api';
/**
* Return content for embedding
- *
* @type {import('express').RequestParamHandler}
*/
const oembed = async (req, res) => {
diff --git a/vnext/server/middleware/urlexpand.js b/vnext/server/middleware/urlexpand.js
index 730e2e8f..f78d1cc0 100644
--- a/vnext/server/middleware/urlexpand.js
+++ b/vnext/server/middleware/urlexpand.js
@@ -2,7 +2,6 @@ import { expandShortenedLink } from '../../src/api';
/**
* Expand URLs
- *
* @param {import("next").NextApiRequest} req
* @param {import("next").NextApiResponse} res
*/
diff --git a/vnext/src/api/index.js b/vnext/src/api/index.js
index 2af6c867..ef753eaf 100644
--- a/vnext/src/api/index.js
+++ b/vnext/src/api/index.js
@@ -87,7 +87,6 @@ client.interceptors.request.use(config => {
/**
* fetch my info
- *
* @param {string} username
* @param {string} password
* @returns {Promise<SecureUser, Error>} me object
@@ -184,7 +183,6 @@ export function comment(mid, rid, body, attach) {
}
/**
* Edit message
- *
* @param {number} mid
* @param {number} rid
* @param {string?} body
@@ -198,7 +196,6 @@ export function update(mid, rid, body) {
}
/**
* Update user avatar
- *
* @param {string} newAvatar
*/
export function updateAvatar(newAvatar) {
@@ -247,7 +244,6 @@ let profileCache = {};
/**
* Fetch user profile
- *
* @param {string} profileUrl User profile URL
*/
export function fetchUserUri(profileUrl) {
@@ -283,7 +279,6 @@ export function fetchUserUri(profileUrl) {
/**
* Fetch Tweet content
- *
* @param {string} url Tweet URL
* @returns {Promise<string>} HTML content
*/
@@ -300,7 +295,6 @@ export function fetchUserUri(profileUrl) {
/**
* Checks if HTTP error code is redirection code
- *
* @param {number} code HTTP error code
* @returns {boolean} is HTTP request redirected or not
*/
@@ -310,7 +304,6 @@ function isHttpRedirected(code = 200) {
/**
* Checks if HTTP error code is successful code
- *
* @param {number} code HTTP error code
* @returns {boolean} is HTTP request successful or not
*/
@@ -320,7 +313,6 @@ function isHttpSuccessful(code = 200) {
/**
* Resolves shortened url to actual one
- *
* @param {string} url URL to resolve
* @returns {Promise<string>} full URL
*/
diff --git a/vnext/src/ui/Avatar.js b/vnext/src/ui/Avatar.js
index 0de225b2..9d93521f 100644
--- a/vnext/src/ui/Avatar.js
+++ b/vnext/src/ui/Avatar.js
@@ -13,7 +13,6 @@ import Icon from './Icon';
/**
* Avatar component
- *
* @param {AvatarProps} props
*/
function Avatar({ user, style, link, children }) {
diff --git a/vnext/src/ui/Chat.js b/vnext/src/ui/Chat.js
index 392b12a0..4fdeaac7 100644
--- a/vnext/src/ui/Chat.js
+++ b/vnext/src/ui/Chat.js
@@ -21,7 +21,6 @@ import { Helmet } from 'react-helmet';
/**
* Chat component
- *
* @param {ChatProps} props
*/
export default function Chat(props) {
diff --git a/vnext/src/ui/Contact.js b/vnext/src/ui/Contact.js
index a0d32e84..75c80332 100644
--- a/vnext/src/ui/Contact.js
+++ b/vnext/src/ui/Contact.js
@@ -10,7 +10,6 @@ import Avatar from './Avatar';
/**
* Contact component
- *
* @param {ContactProps} props
*/
function Contact({ user, style }) {
diff --git a/vnext/src/ui/Icon.js b/vnext/src/ui/Icon.js
index a9cd8a95..6d10df16 100644
--- a/vnext/src/ui/Icon.js
+++ b/vnext/src/ui/Icon.js
@@ -13,7 +13,6 @@ import evilIcons from 'evil-icons/assets/sprite.svg';
/**
* Icon inner component
- *
* @param {IconProps} props - icon props
*/
function IconElement(props) {
diff --git a/vnext/src/ui/Login.js b/vnext/src/ui/Login.js
index 58d1a16b..73da49c8 100644
--- a/vnext/src/ui/Login.js
+++ b/vnext/src/ui/Login.js
@@ -16,7 +16,6 @@ import { useVisitor } from './VisitorContext';
/**
* Login page
- *
* @param {LoginProps} props
*/
function Login({ onAuth }) {
diff --git a/vnext/src/ui/Message.js b/vnext/src/ui/Message.js
index 595d2178..c5ad175d 100644
--- a/vnext/src/ui/Message.js
+++ b/vnext/src/ui/Message.js
@@ -28,7 +28,6 @@ import { useVisitor } from './VisitorContext';
/**
* Message component
- *
* @param {React.PropsWithChildren<{}> & MessageProps} props props
*/
export default function Message({ data, isThread, onToggleSubscription, children }) {
@@ -156,7 +155,6 @@ function MessageContainer({ isCode, data }) {
/**
* Tags component
- *
* @param {{user: import('../client').User, data: string[]}} props props
*/
function Tags({ data, user }) {
diff --git a/vnext/src/ui/MessageInput.js b/vnext/src/ui/MessageInput.js
index de4edc7f..3d24e728 100644
--- a/vnext/src/ui/MessageInput.js
+++ b/vnext/src/ui/MessageInput.js
@@ -9,7 +9,6 @@ import toast from 'react-hot-toast';
/**
* StackOverflow-driven development: https://stackoverflow.com/a/10158364/1097384
- *
* @param {HTMLTextAreaElement & {createTextRange?: Function}} el element
*/
function moveCaretToEnd(el) {
@@ -37,7 +36,6 @@ function moveCaretToEnd(el) {
/**
* MessageInput
- *
* @param {React.ComponentProps<React.FC> & MessageInputProps} props props
*/
export default function MessageInput({ text, rows, placeholder, onSend }) {
diff --git a/vnext/src/ui/Settings.js b/vnext/src/ui/Settings.js
index 6e9d4f36..380d8ff6 100644
--- a/vnext/src/ui/Settings.js
+++ b/vnext/src/ui/Settings.js
@@ -32,16 +32,14 @@ function ChangeAvatarForm({ onChange }) {
if (preview) {
previewUser = { ...visitor, avatar: preview, uname: '<preview>' };
}
- let onSubmitAvatar = (event) => {
+ let onSubmitAvatar = async (event) => {
if (event.preventDefault) {
event.preventDefault();
}
- updateAvatar(avatarInput.current.files[0]).then(() => {
- avatarChanged('');
- me().then(visitor => {
- onChange(visitor);
- }).catch(console.error);
- }).catch(console.error);
+ await updateAvatar(avatarInput.current.files[0]);
+ avatarChanged('');
+ let visitor = await me();
+ onChange(visitor);
};
return (
<form>
@@ -124,20 +122,20 @@ export default function Settings({ onChange }) {
{visitor.telegramName ? (
<form>
<div>Telegram: <b> {visitor.telegramName} </b> &mdash;
- <Button onClick={disableTelegram}>Disable</Button>
+ <Button onClick={disableTelegram}>Disable</Button>
</div>
</form>
) : (
- <p>To connect Telegram account: send any text message to <a href="https://telegram.me/Juick_bot">@Juick_bot</a>
- </p>
- )}
+ <p>To connect Telegram account: send any text message to <a href="https://telegram.me/Juick_bot">@Juick_bot</a>
+ </p>
+ )}
</fieldset>
{
visitor.jids && (
<form>
<fieldset>
<legend>XMPP accounts
- </legend>
+ </legend>
<p>Your accounts:</p>
<p>
{
@@ -205,7 +203,7 @@ export default function Settings({ onChange }) {
{/** /email_off */}
<p>&nbsp;</p>
<p>You can post to Juick via e-mail. Send your <u>plain text</u> messages to <a href="mailto:juick@juick.com">juick@juick.com</a>.
- You can attach one photo or video file.</p>
+ You can attach one photo or video file.</p>
</>
}
</fieldset>
@@ -228,19 +226,19 @@ export default function Settings({ onChange }) {
</div>
</form>
) : (
- <p>Cross-posting to Facebook:
- <a href="/_fblogin">
- <img src="//static.juick.com/facebook-connect.png" alt="Connect to Facebook" />
- </a>
- </p>
- )}
+ <p>Cross-posting to Facebook:
+ <a href="/_fblogin">
+ <img src="//static.juick.com/facebook-connect.png" alt="Connect to Facebook" />
+ </a>
+ </p>
+ )}
</fieldset>
<fieldset>
<legend><Icon name="ei-sc-twitter" size="m" />Twitter</legend>
{visitor.twitterName ?
<form action="/settings" method="post">
<div>Twitter: <b>{visitor.twitterName}</b>&mdash;
- <input type="hidden" name="page" value="twitter-del" />
+ <input type="hidden" name="page" value="twitter-del" />
<Button onClick={disableTwitter}>Disable</Button>
</div>
</form>
diff --git a/vnext/src/ui/Thread.js b/vnext/src/ui/Thread.js
index f26eead6..a3136c35 100644
--- a/vnext/src/ui/Thread.js
+++ b/vnext/src/ui/Thread.js
@@ -15,9 +15,8 @@ import { Helmet } from 'react-helmet';
const emptyMessage = {};
/**
- * @param {{
- connection: EventSource?
- }} props
+ * Thread component
+ * @param {import('react').PropsWithChildren<{}>} props
*/
export default function Thread(props) {
const location = useLocation();
diff --git a/vnext/src/ui/UploadButton.js b/vnext/src/ui/UploadButton.js
index f07501de..b652e522 100644
--- a/vnext/src/ui/UploadButton.js
+++ b/vnext/src/ui/UploadButton.js
@@ -9,7 +9,6 @@ import Icon from './Icon';
/**
* Upload button
- *
* @param {UploadButtonProps} props
*/
export default function UploadButton(props) {
diff --git a/vnext/src/ui/UserInfo.js b/vnext/src/ui/UserInfo.js
index 5bcc2507..2ca8c431 100644
--- a/vnext/src/ui/UserInfo.js
+++ b/vnext/src/ui/UserInfo.js
@@ -11,7 +11,6 @@ let isMounted;
/**
* User info component
- *
* @param {{uname: string, onUpdate?: Function, children?: import('react').ReactElement}} props
*/
export default function UserInfo({ uname, onUpdate, children }) {
@@ -65,7 +64,6 @@ export default function UserInfo({ uname, onUpdate, children }) {
/**
* User summary component
- *
* @param {{user: import('../api').User}} props
*/
function Summary({ user }) {
@@ -89,7 +87,6 @@ const UserSummary = memo(Summary);
/**
* Link to user
- *
* @param {{ user: import('../api').User}} props
*/
export function UserLink(props) {
diff --git a/vnext/src/ui/Users.js b/vnext/src/ui/Users.js
index b0e19dfa..32ff2d03 100644
--- a/vnext/src/ui/Users.js
+++ b/vnext/src/ui/Users.js
@@ -37,7 +37,6 @@ export function Readers() {
/**
* UserInfo list component
- *
* @param {{uname: string, prop: string}} props
*/
function Users({ uname, prop }) {
diff --git a/vnext/src/ui/VisitorContext.js b/vnext/src/ui/VisitorContext.js
index 8c5364e7..240b709b 100644
--- a/vnext/src/ui/VisitorContext.js
+++ b/vnext/src/ui/VisitorContext.js
@@ -17,7 +17,6 @@ export function VisitorProvider({ children }) {
/**
* Visitor hook
- *
* @returns {[
* import('../api').SecureUser,
* import('react').Dispatch<import('react').SetStateAction<import('../api').SecureUser>>
diff --git a/vnext/src/utils/embed.js b/vnext/src/utils/embed.js
index 8fde80d0..f16342cf 100644
--- a/vnext/src/utils/embed.js
+++ b/vnext/src/utils/embed.js
@@ -119,7 +119,6 @@ function messageReplyReplace(messageId) {
/**
* Given "txt" message in unescaped plaintext with Juick markup, this function
* returns escaped formatted HTML string.
- *
* @param {string} txt text message
* @param {string} messageId current message id
* @param {boolean} isCode set when message contains *code tag
@@ -169,7 +168,6 @@ function juickFormat(txt, messageId, isCode) {
/**
* Get supported embeddable formats
- *
* @returns {LinkFormatData[]} list of supported formats
*/
function getEmbeddableLinkTypes() {
@@ -315,7 +313,6 @@ function getEmbeddableLinkTypes() {
/**
* Embed a link
- *
* @param { HTMLAnchorElement } aNode a DOM node of the link
* @param { LinkFormatData[] } linkTypes supported link types
* @param { HTMLElement } container a target DOM element with the link content
@@ -362,7 +359,6 @@ function embedLinks(aNodes, container) {
* All the embedded media is placed inside "div.embedContainer".
* "div.embedContainer" is inserted before an element matched by "beforeNodeSelector"
* if not present. Existing container is used otherwise.
- *
* @param {Element} x
* @param {string} beforeNodeSelector
* @param {string} allLinksSelector
@@ -397,7 +393,6 @@ export function embedAll() {
}
/**
* Embed URLs to container
- *
* @param {NodeListOf<Element>} urls
* @param {HTMLDivElement} embedContainer
*/