Migrate util, types, state, sticker-creator to ESLint

This commit is contained in:
Sidney Keese
2020-09-14 14:56:35 -07:00
committed by Josh Perez
parent 372aa44e49
commit 2ade4acd52
115 changed files with 647 additions and 448 deletions
+30 -14
View File
@@ -64,7 +64,7 @@ export function getExtensionForDisplay({
}
if (!contentType) {
return;
return undefined;
}
const slash = contentType.indexOf('/');
@@ -72,10 +72,12 @@ export function getExtensionForDisplay({
return contentType.slice(slash + 1);
}
return;
return undefined;
}
export function isAudio(attachments?: Array<AttachmentType>) {
export function isAudio(
attachments?: Array<AttachmentType>
): boolean | undefined {
return (
attachments &&
attachments[0] &&
@@ -84,7 +86,9 @@ export function isAudio(attachments?: Array<AttachmentType>) {
);
}
export function canDisplayImage(attachments?: Array<AttachmentType>) {
export function canDisplayImage(
attachments?: Array<AttachmentType>
): boolean | 0 | undefined {
const { height, width } =
attachments && attachments[0] ? attachments[0] : { height: 0, width: 0 };
@@ -98,7 +102,7 @@ export function canDisplayImage(attachments?: Array<AttachmentType>) {
);
}
export function getThumbnailUrl(attachment: AttachmentType) {
export function getThumbnailUrl(attachment: AttachmentType): string {
if (attachment.thumbnail) {
return attachment.thumbnail.url;
}
@@ -106,7 +110,7 @@ export function getThumbnailUrl(attachment: AttachmentType) {
return getUrl(attachment);
}
export function getUrl(attachment: AttachmentType) {
export function getUrl(attachment: AttachmentType): string {
if (attachment.screenshot) {
return attachment.screenshot.url;
}
@@ -114,7 +118,9 @@ export function getUrl(attachment: AttachmentType) {
return attachment.url;
}
export function isImage(attachments?: Array<AttachmentType>) {
export function isImage(
attachments?: Array<AttachmentType>
): boolean | undefined {
return (
attachments &&
attachments[0] &&
@@ -123,14 +129,18 @@ export function isImage(attachments?: Array<AttachmentType>) {
);
}
export function isImageAttachment(attachment: AttachmentType) {
export function isImageAttachment(
attachment: AttachmentType
): boolean | undefined {
return (
attachment &&
attachment.contentType &&
isImageTypeSupported(attachment.contentType)
);
}
export function hasImage(attachments?: Array<AttachmentType>) {
export function hasImage(
attachments?: Array<AttachmentType>
): string | boolean | undefined {
return (
attachments &&
attachments[0] &&
@@ -138,11 +148,15 @@ export function hasImage(attachments?: Array<AttachmentType>) {
);
}
export function isVideo(attachments?: Array<AttachmentType>) {
export function isVideo(
attachments?: Array<AttachmentType>
): boolean | undefined {
return attachments && isVideoAttachment(attachments[0]);
}
export function isVideoAttachment(attachment?: AttachmentType) {
export function isVideoAttachment(
attachment?: AttachmentType
): boolean | undefined {
return (
attachment &&
attachment.contentType &&
@@ -150,7 +164,9 @@ export function isVideoAttachment(attachment?: AttachmentType) {
);
}
export function hasVideoScreenshot(attachments?: Array<AttachmentType>) {
export function hasVideoScreenshot(
attachments?: Array<AttachmentType>
): string | null | undefined {
const firstAttachment = attachments ? attachments[0] : null;
return (
@@ -308,7 +324,7 @@ export const isFile = (attachment: Attachment): boolean => {
export const isVoiceMessage = (attachment: Attachment): boolean => {
const flag = SignalService.AttachmentPointer.Flags.VOICE_MESSAGE;
const hasFlag =
// tslint:disable-next-line no-bitwise
// eslint-disable-next-line no-bitwise
!is.undefined(attachment.flags) && (attachment.flags & flag) === flag;
if (hasFlag) {
return true;
@@ -390,7 +406,7 @@ export const getFileExtension = (
attachment: Attachment
): string | undefined => {
if (!attachment.contentType) {
return;
return undefined;
}
switch (attachment.contentType) {