From 59fc0ddf96e83308992efc3648b39e3d81fedf2e Mon Sep 17 00:00:00 2001 From: xpadev Date: Fri, 12 Apr 2024 11:51:14 +0900 Subject: [PATCH] fix: eslint error --- src/comments/FlashComment.ts | 2 +- src/comments/HTML5Comment.ts | 8 ++++---- src/utils/array.ts | 3 --- src/utils/comment.ts | 8 ++++---- src/utils/commentArt.ts | 2 +- 5 files changed, 10 insertions(+), 13 deletions(-) diff --git a/src/comments/FlashComment.ts b/src/comments/FlashComment.ts index a66ddf7a..2496aaae 100755 --- a/src/comments/FlashComment.ts +++ b/src/comments/FlashComment.ts @@ -36,7 +36,7 @@ class FlashComment extends BaseComment { override buttonImage: IRenderer; constructor(comment: FormattedComment, renderer: IRenderer, index: number) { super(comment, renderer, index); - this._globalScale ??= getConfig(config.commentScale, true); + this._globalScale = getConfig(config.commentScale, true); this.buttonImage = renderer.getCanvas(); } diff --git a/src/comments/HTML5Comment.ts b/src/comments/HTML5Comment.ts index e25c0858..46fbaabf 100755 --- a/src/comments/HTML5Comment.ts +++ b/src/comments/HTML5Comment.ts @@ -148,7 +148,7 @@ class HTML5Comment extends BaseComment { for (let i = 0, n = comment.content.length; i < n; i++) { const item = comment.content[i]; - if (item?.type !== "text" || !itemWidth) continue; + if (item?.type !== "text" || !itemWidth[i]) continue; item.width = itemWidth[i]; } comment.fontSize = (comment.charSize ?? 0) * 0.8; @@ -247,7 +247,7 @@ class HTML5Comment extends BaseComment { (this.comment.lineHeight * (i + 1) + (this.comment.charSize - this.comment.lineHeight) / 2 + this.comment.lineHeight * -0.16 + - (config.fonts.html5[this.comment.font]?.offset || 0)) * + (config.fonts.html5[this.comment.font].offset || 0)) * scale; this.renderer.setStrokeStyle("rgba(255,255,0,0.5)"); this.renderer.strokeRect( @@ -287,9 +287,9 @@ class HTML5Comment extends BaseComment { const offsetY = (this.comment.charSize - this.comment.lineHeight) / 2 + this.comment.lineHeight * -0.16 + - (config.fonts.html5[this.comment.font]?.offset || 0); + (config.fonts.html5[this.comment.font].offset || 0); for (const item of this.comment.content) { - if (item?.type === "spacer") { + if (item.type === "spacer") { lineCount += item.count * item.charWidth * this.comment.fontSize; continue; } diff --git a/src/utils/array.ts b/src/utils/array.ts index c2ab7ebe..b6d68520 100755 --- a/src/utils/array.ts +++ b/src/utils/array.ts @@ -11,9 +11,6 @@ const arrayPush = ( key: string | number, push: IComment, ) => { - if (!array) { - array = {}; - } if (!array[Number(key)]) { array[Number(key)] = []; } diff --git a/src/utils/comment.ts b/src/utils/comment.ts index 912cf296..50df6c05 100755 --- a/src/utils/comment.ts +++ b/src/utils/comment.ts @@ -87,7 +87,7 @@ const nicoscriptReplaceIgnoreable = ( (item.condition === "\u5b8c\u5168\u4e00\u81f4" && comment.content !== item.keyword) || (item.condition === "\u90e8\u5206\u4e00\u81f4" && - comment.content.indexOf(item.keyword) === -1); + !comment.content.includes(item.keyword)); /** * 置換コマンドを適用する @@ -408,9 +408,9 @@ const processAtButton = ( groups: { before?: string; body?: string; after?: string }; }; const message = { - before: content.groups?.before ?? "", - body: content.groups?.body ?? "", - after: content.groups?.after ?? "", + before: content.groups.before ?? "", + body: content.groups.body ?? "", + after: content.groups.after ?? "", }; commands.button = { message, diff --git a/src/utils/commentArt.ts b/src/utils/commentArt.ts index 5d42696d..0b234904 100755 --- a/src/utils/commentArt.ts +++ b/src/utils/commentArt.ts @@ -48,7 +48,7 @@ const getUsersScore = ( ): { [key: string]: number } => { const userScoreList: { [key: number]: number } = {}; for (const comment of comments) { - if (comment.user_id === undefined || comment.user_id === -1) continue; + if (comment.user_id === -1) continue; userScoreList[comment.user_id] ||= 0; if ( comment.mail.includes("ca") ||