From a80e32fe7581bab8fd960a40905e85498d54206a Mon Sep 17 00:00:00 2001 From: Jarek Radosz Date: Tue, 28 Nov 2023 10:37:23 +0100 Subject: [PATCH] DEV: Fix `no-extra-boolean-cast` lint (#24582) --- app/assets/javascripts/discourse-markdown-it/src/engine.js | 3 +-- .../discourse/app/controllers/full-page-search.js | 2 +- app/assets/javascripts/discourse/app/services/store.js | 2 +- app/assets/javascripts/pretty-text/addon/emoji.js | 6 +++--- .../javascripts/lib/discourse-markdown/chat-transcript.js | 2 +- 5 files changed, 7 insertions(+), 8 deletions(-) diff --git a/app/assets/javascripts/discourse-markdown-it/src/engine.js b/app/assets/javascripts/discourse-markdown-it/src/engine.js index 4d5697c1fa3..75f0e3b7f91 100644 --- a/app/assets/javascripts/discourse-markdown-it/src/engine.js +++ b/app/assets/javascripts/discourse-markdown-it/src/engine.js @@ -56,8 +56,7 @@ export default function makeEngine( allowLister.allowListFeature(feature, info); }); - options.sanitizer = options.discourse.sanitizer = !!options.discourse - .sanitize + options.sanitizer = options.discourse.sanitizer = options.discourse.sanitize ? (a) => sanitize(a, allowLister) : (a) => a; } diff --git a/app/assets/javascripts/discourse/app/controllers/full-page-search.js b/app/assets/javascripts/discourse/app/controllers/full-page-search.js index 5ea48679760..2204b6629bb 100644 --- a/app/assets/javascripts/discourse/app/controllers/full-page-search.js +++ b/app/assets/javascripts/discourse/app/controllers/full-page-search.js @@ -389,7 +389,7 @@ export default Controller.extend({ Promise.resolve(categoryTagSearch) .then(async (results) => { const categories = results.filter((c) => Boolean(c.model)); - const tags = results.filter((c) => !Boolean(c.model)); + const tags = results.filter((c) => !c.model); const model = (await translateResults({ categories, tags })) || {}; this.set("model", model); }) diff --git a/app/assets/javascripts/discourse/app/services/store.js b/app/assets/javascripts/discourse/app/services/store.js index e0f06d8ac49..45a63029a3a 100644 --- a/app/assets/javascripts/discourse/app/services/store.js +++ b/app/assets/javascripts/discourse/app/services/store.js @@ -206,7 +206,7 @@ export default class StoreService extends Service { createRecord(type, attrs) { attrs = attrs || {}; const adapter = this.adapterFor(type); - return !!attrs[adapter.primaryKey] + return attrs[adapter.primaryKey] ? this._hydrate(type, attrs) : this._build(type, attrs); } diff --git a/app/assets/javascripts/pretty-text/addon/emoji.js b/app/assets/javascripts/pretty-text/addon/emoji.js index 8211a7f6b72..dba70c2df35 100644 --- a/app/assets/javascripts/pretty-text/addon/emoji.js +++ b/app/assets/javascripts/pretty-text/addon/emoji.js @@ -122,11 +122,11 @@ export function performEmojiEscape(string, opts) { const replacementFunction = (m, index) => { if (isReplaceableInlineEmoji(string, index, opts.inlineEmoji)) { - if (!!allTranslations[m]) { + if (allTranslations[m]) { return opts.emojiShortcuts ? `:${allTranslations[m]}:` : m; - } else if (!!replacements[m]) { + } else if (replacements[m]) { return `:${replacements[m]}:`; - } else if (!!replacements[m[0]]) { + } else if (replacements[m[0]]) { return `:${replacements[m[0]]}:`; } } diff --git a/plugins/chat/assets/javascripts/lib/discourse-markdown/chat-transcript.js b/plugins/chat/assets/javascripts/lib/discourse-markdown/chat-transcript.js index 7a4c90aeed7..81607fcf2ad 100644 --- a/plugins/chat/assets/javascripts/lib/discourse-markdown/chat-transcript.js +++ b/plugins/chat/assets/javascripts/lib/discourse-markdown/chat-transcript.js @@ -105,7 +105,7 @@ const chatTranscriptRule = { let wrapperClasses = ["chat-transcript"]; - if (!!tagInfo.attrs.chained) { + if (tagInfo.attrs.chained) { wrapperClasses.push("chat-transcript-chained"); }