eslint 8.57 WIP:
* tweaking some more rules. * fixing linting.
This commit is contained in:
@ -17,19 +17,19 @@ export const livechatEmojisPlugin = {
|
||||
livechat_custom_emojis_url: false
|
||||
})
|
||||
|
||||
_converse.api.listen.on('loadEmojis', async (_context: Object, json: any) => {
|
||||
const url = _converse.api.settings.get('livechat_custom_emojis_url')
|
||||
_converse.api.listen.on('loadEmojis', async (_context: object, json: Record<string, Record<string, unknown>>) => {
|
||||
const url = _converse.api.settings.get('livechat_custom_emojis_url') as string | undefined
|
||||
if (!url) {
|
||||
return json
|
||||
}
|
||||
|
||||
let customs
|
||||
let customs: CustomEmojiDefinition[] | undefined
|
||||
try {
|
||||
customs = await loadCustomEmojis(url)
|
||||
} catch (err) {
|
||||
console.error(err)
|
||||
}
|
||||
if (customs === undefined || !customs?.length) {
|
||||
if (!customs?.length) {
|
||||
return json
|
||||
}
|
||||
|
||||
@ -51,7 +51,7 @@ export const livechatEmojisPlugin = {
|
||||
|
||||
// We must also remove any existing emojis in category other than custom
|
||||
for (const type of Object.keys(json)) {
|
||||
const v: {[key: string]: any} = json[type]
|
||||
const v: Record<string, any> = json[type]
|
||||
if (type !== 'custom' && type !== 'modifiers' && (def.sn in v)) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
|
||||
delete v[def.sn]
|
||||
|
@ -2,7 +2,8 @@
|
||||
//
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
export function chatRoomMessageOverrides (): {[key: string]: Function} {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
|
||||
export function chatRoomMessageOverrides (): Record<string, Function> {
|
||||
return {
|
||||
/* By default, ConverseJS groups messages from the same users for a 10 minutes period.
|
||||
* This make no sense in a livechat room. So we override isFollowup to ignore. */
|
||||
|
@ -2,7 +2,8 @@
|
||||
//
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
export function chatRoomOverrides (): {[key: string]: Function} {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
|
||||
export function chatRoomOverrides (): Record<string, Function> {
|
||||
return {
|
||||
getActionInfoMessage: function getActionInfoMessage (this: any, code: string, nick: string, actor: any): any {
|
||||
if (code === '303') {
|
||||
@ -27,8 +28,9 @@ export function chatRoomOverrides (): {[key: string]: Function} {
|
||||
initOccupants: function initOccupants (this: any) {
|
||||
const r = this.__super__.initOccupants()
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
|
||||
const originalComparatorFunction: Function = this.occupants.comparator
|
||||
this.occupants.comparator = function (this: any, occupant1: any, occupant2: any): Number {
|
||||
this.occupants.comparator = function (this: any, occupant1: any, occupant2: any): number {
|
||||
// Overriding Occupants comparators, to display anonymous users at the end of the list.
|
||||
const nick1: string = occupant1.getDisplayName()
|
||||
const nick2: string = occupant2.getDisplayName()
|
||||
|
@ -19,7 +19,7 @@ export function customizeMessageAction (plugin: any): void {
|
||||
try {
|
||||
txt += this.model.getDisplayName() as string
|
||||
txt += ' - '
|
||||
const date = new Date(this.model.get('edited') || this.model.get('time'))
|
||||
const date = new Date((this.model.get('edited') || this.model.get('time')) as string)
|
||||
txt += date.toLocaleDateString() + ' ' + date.toLocaleTimeString()
|
||||
txt += '\n'
|
||||
} catch {}
|
||||
|
@ -2,6 +2,9 @@
|
||||
//
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
// FIXME: @stylistic/indent is buggy with strings literrals.
|
||||
/* eslint-disable @stylistic/indent */
|
||||
|
||||
/**
|
||||
* Do some customization on the toolbar:
|
||||
* * change the appearance of the toggle occupants button
|
||||
|
@ -25,7 +25,7 @@ export function getOpenPromise (): any {
|
||||
promise.isResolved = false
|
||||
promise.isPending = false
|
||||
promise.isRejected = true
|
||||
throw (e)
|
||||
throw (e as Error)
|
||||
}
|
||||
)
|
||||
return promise
|
||||
|
@ -22,11 +22,11 @@ export const livechatViewerModePlugin = {
|
||||
console.error('[livechatViewerModePlugin] getDefaultMUCNickname is not initialized.')
|
||||
} else {
|
||||
Object.assign(_converse.exports, {
|
||||
getDefaultMUCNickname: function (this: any): any {
|
||||
getDefaultMUCNickname: function (this: any, ...args: any[]): any {
|
||||
if (!_converse.api.settings.get('livechat_enable_viewer_mode')) {
|
||||
return originalGetDefaultMUCNickname.apply(this, arguments)
|
||||
return originalGetDefaultMUCNickname.apply(this, args)
|
||||
}
|
||||
return originalGetDefaultMUCNickname.apply(this, arguments) ??
|
||||
return originalGetDefaultMUCNickname.apply(this, args) ??
|
||||
getPreviousAnonymousNick() ??
|
||||
randomNick('Anonymous')
|
||||
}
|
||||
@ -72,8 +72,8 @@ export const livechatViewerModePlugin = {
|
||||
// Note: when previousNickname is set, model.get('nick') has not the nick yet...
|
||||
// It will only come after receiving a presence stanza.
|
||||
// So we use previousNickname before trying to read the model.
|
||||
const nick = getPreviousAnonymousNick() ?? (model?.get ? model.get('nick') : '')
|
||||
refreshViewerMode(nick && !/^Anonymous /.test(nick))
|
||||
const nick = getPreviousAnonymousNick() ?? (model?.get ? model.get('nick') as string : '')
|
||||
refreshViewerMode(!!nick && !/^Anonymous /.test(nick))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -21,7 +21,13 @@ export const slowModePlugin = {
|
||||
return
|
||||
}
|
||||
|
||||
const slowModeDuration = parseInt(chatbox?.config?.get('slow_mode_duration'))
|
||||
const slowModeDurationRaw = chatbox?.config?.get('slow_mode_duration') ?? NaN
|
||||
const slowModeDuration =
|
||||
typeof slowModeDurationRaw === 'string'
|
||||
? parseInt(slowModeDurationRaw)
|
||||
: typeof slowModeDurationRaw === 'number'
|
||||
? Math.trunc(slowModeDurationRaw)
|
||||
: NaN
|
||||
if (!(slowModeDuration > 0)) { // undefined, NaN, ... are not considered > 0.
|
||||
return
|
||||
}
|
||||
|
Reference in New Issue
Block a user