From bb992e29a6c746795aaf5330d9815d5be42e60cd Mon Sep 17 00:00:00 2001 From: John Livingston Date: Tue, 8 Oct 2024 17:23:10 +0200 Subject: [PATCH] Fix linting according to new rules, and disable buggy rules. --- client/common/admin/firewall/elements/admin-firewall.ts | 4 ++-- .../configuration/elements/channel-configuration.ts | 4 ++-- eslint.config.mjs | 8 ++++++++ server/lib/external-auth/oidc.ts | 1 + server/lib/federation/storage.ts | 1 + server/lib/routers/webchat.ts | 1 + 6 files changed, 15 insertions(+), 4 deletions(-) diff --git a/client/common/admin/firewall/elements/admin-firewall.ts b/client/common/admin/firewall/elements/admin-firewall.ts index 067193f9..7ef0db68 100644 --- a/client/common/admin/firewall/elements/admin-firewall.ts +++ b/client/common/admin/firewall/elements/admin-firewall.ts @@ -103,7 +103,7 @@ export class AdminFirewallElement extends LivechatElement { public readonly getInputValidationClass = (propertyName: string): Record => { const validationErrorTypes: ValidationErrorType[] | undefined = - this.validationError?.properties[`${propertyName}`] + this.validationError?.properties[propertyName] return validationErrorTypes ? (validationErrorTypes.length ? { 'is-invalid': true } : { 'is-valid': true }) : {} } @@ -111,7 +111,7 @@ export class AdminFirewallElement extends LivechatElement { propertyName: string): TemplateResult | typeof nothing => { const errorMessages: TemplateResult[] = [] const validationErrorTypes: ValidationErrorType[] | undefined = - this.validationError?.properties[`${propertyName}`] ?? undefined + this.validationError?.properties[propertyName] ?? undefined // FIXME: this code is duplicated in dymamic table form if (validationErrorTypes && validationErrorTypes.length !== 0) { diff --git a/client/common/configuration/elements/channel-configuration.ts b/client/common/configuration/elements/channel-configuration.ts index 01c5f812..c15038fd 100644 --- a/client/common/configuration/elements/channel-configuration.ts +++ b/client/common/configuration/elements/channel-configuration.ts @@ -115,7 +115,7 @@ export class ChannelConfigurationElement extends LivechatElement { public readonly getInputValidationClass = (propertyName: string): Record => { const validationErrorTypes: ValidationErrorType[] | undefined = - this.validationError?.properties[`${propertyName}`] + this.validationError?.properties[propertyName] return validationErrorTypes ? (validationErrorTypes.length ? { 'is-invalid': true } : { 'is-valid': true }) : {} } @@ -123,7 +123,7 @@ export class ChannelConfigurationElement extends LivechatElement { propertyName: string): TemplateResult | typeof nothing => { const errorMessages: TemplateResult[] = [] const validationErrorTypes: ValidationErrorType[] | undefined = - this.validationError?.properties[`${propertyName}`] ?? undefined + this.validationError?.properties[propertyName] ?? undefined // FIXME: this code is duplicated in dymamic table form if (validationErrorTypes && validationErrorTypes.length !== 0) { diff --git a/eslint.config.mjs b/eslint.config.mjs index 7793adaf..636b1aae 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -71,6 +71,14 @@ export default tseslint.config( '@typescript-eslint/class-methods-use-this': 'off', '@typescript-eslint/non-nullable-type-assertion-style': 'off', '@typescript-eslint/no-magic-numbers': 'off', + + '@typescript-eslint/no-unsafe-member-access': 'off', // FIXME: comes with eslint-config-love 84 update, and should be used. + '@typescript-eslint/no-unsafe-return': 'off', // FIXME: comes with eslint-config-love 84 update, and should be used. + '@typescript-eslint/no-unsafe-assignment': 'off', // FIXME: comes with eslint-config-love 84 update, and should be used. + '@typescript-eslint/no-unsafe-call': 'off', // FIXME: comes with eslint-config-love 84 update, and should be used. + + '@typescript-eslint/no-unnecessary-condition': 'off', // FIXME: comes with eslint-config-love 84 update, but seems buggy (false positive). + 'max-len': [ 'error', { diff --git a/server/lib/external-auth/oidc.ts b/server/lib/external-auth/oidc.ts index 257e27d9..62b16d55 100644 --- a/server/lib/external-auth/oidc.ts +++ b/server/lib/external-auth/oidc.ts @@ -757,6 +757,7 @@ class ExternalAuthOIDC { * @throws Error * @returns the singleton */ + // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents public static singleton (singletonType: ExternalAuthOIDCType | string): ExternalAuthOIDC { if (!singletons) { throw new Error('ExternalAuthOIDC singletons are not initialized yet') diff --git a/server/lib/federation/storage.ts b/server/lib/federation/storage.ts index ab111ad6..9703409a 100644 --- a/server/lib/federation/storage.ts +++ b/server/lib/federation/storage.ts @@ -307,6 +307,7 @@ async function _store (options: RegisterServerOptions, filePath: string, content } } +// eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents async function _get (options: RegisterServerOptions, filePath: string): Promise { const logger = options.peertubeHelpers.logger try { diff --git a/server/lib/routers/webchat.ts b/server/lib/routers/webchat.ts index c5c8bd60..f822449b 100644 --- a/server/lib/routers/webchat.ts +++ b/server/lib/routers/webchat.ts @@ -142,6 +142,7 @@ async function initWebchatRouter (options: RegisterServerOptionsV5): Promise