diff --git a/.gemini/styleguide.md b/.gemini/styleguide.md index 51258faee..9be45b31e 100644 --- a/.gemini/styleguide.md +++ b/.gemini/styleguide.md @@ -32,7 +32,7 @@ import { EquicordDevs } from "@utils/constants"; export default definePlugin({ name: "PluginName", // PascalCase, matches directory name - description: "Does something.", // Capital first, period at end + description: "Does something", // Capital first authors: [EquicordDevs.Name], // EquicordDevs for new, Devs for upstream }); ``` @@ -76,8 +76,7 @@ Flag these and suggest the fix: | `value \|\| defaultValue` | `value ?? defaultValue` | `\|\|` falsifies `0`, `""`, `false` | | `` `${classA} ${classB}` `` | `classes(classA, classB)` | Handles null/false gracefully | | `"vc-plugin-class"` hardcoded | `cl("class")` via `classNameFactory` | Consistent, typo-proof | -| `console.log/warn/error` | Remove it | No logging in plugin code | -| `new Logger(...)` / `logger.log(...)` | Remove it | No logging in plugin code | +| `console.log/warn` | Remove it | No logging in plugin code | | `cdn.discordapp.com/avatars/...` | `IconUtils.getUserAvatarURL(user)` | Handles animated, sizing, CDN | | `cdn.discordapp.com/icons/...` | `IconUtils.getGuildIconURL(...)` | Same | | `cdn.discordapp.com/banners/...` | `IconUtils.getUserBannerURL(...)` | Same | @@ -246,7 +245,7 @@ Vencord.Plugins.plugins["OtherPlugin"].someFunction(); ## Text and Descriptions -- Plugin and setting descriptions: capital first letter, end with period. +- Plugin and setting descriptions: capital first letter. - Error messages and toasts: natural human text, no dashes or robotic formatting. ```typescript @@ -317,8 +316,7 @@ stop() {} - **No overengineering.** No premature abstractions, no "just in case" handling, no features not requested. Three similar lines beats a one-use helper. If code can be half the size and do the same thing, it should be. - **No bloat.** Flag unnecessary wrapper functions, redundant type annotations, excessive error handling for things that can't fail, useless try/catch around synchronous code, or 50 lines doing what 10 could do. Code should be lean. - **No unused imports.** Every import must be referenced. -- **No logging in plugin code.** No `console.log/warn/error`, no `Logger`. Remove all logging statements. -- **No empty catch blocks.** Handle every error (show toast, return fallback, rethrow, etc.). +- **No logging in plugin code besides for errors.** No `console.log/warn`. --- @@ -378,6 +376,6 @@ If a PR reimplements any of these, flag it. They already exist: ## Review Severity 1. **CRITICAL** — `any` types, hardcoded CDN/API URLs, direct DOM manipulation, security issues, massive overengineering/bloat, suspected AI slop (note it, but still review everything) -2. **HIGH** — Missing useEffect cleanup, forbidden React APIs, hardcoded class names, logging statements (console or Logger), missing definePluginSettings, unnecessary abstractions +2. **HIGH** — Missing useEffect cleanup, forbidden React APIs, hardcoded class names, console logging statements, missing definePluginSettings, unnecessary abstractions 3. **MEDIUM** — Anti-patterns (`||` instead of `??`), utility reimplementations, commented-out code, bad description format, excessive comments 4. **LOW** — Style preferences, minor performance wins, organization diff --git a/src/equicordplugins/_api/audioPlayer.ts b/src/equicordplugins/_api/audioPlayer.ts index e79227b39..19d76d043 100644 --- a/src/equicordplugins/_api/audioPlayer.ts +++ b/src/equicordplugins/_api/audioPlayer.ts @@ -72,7 +72,7 @@ export default definePlugin({ // regardless of if the "discodo" effect is enabled or not. This is due to the volume setter // internally calling the ensureAudio function which is where the internal sounds module is loaded // by default. To account for this, the module is force loaded in the first patch in the above group. - find: "UPDATE_OPEN_ON_STARTUP", + find: '"UPDATE_OPEN_ON_STARTUP"', group: true, replacement: [ { diff --git a/src/equicordplugins/_api/headerBar.ts b/src/equicordplugins/_api/headerBar.ts index 8f7edc595..ff05d2ee6 100644 --- a/src/equicordplugins/_api/headerBar.ts +++ b/src/equicordplugins/_api/headerBar.ts @@ -16,7 +16,7 @@ export default definePlugin({ { find: '?"BACK_FORWARD_NAVIGATION":', replacement: { - match: /(?<="HELP".{0,150}className:\i\}\))(?=\])/, + match: /(?<="HELP"===.{0,150}className:\i\.\i\}\))(?=\])/, replace: ",...Vencord.Api.HeaderBar._addHeaderBarButtons()" } }, diff --git a/src/equicordplugins/clipsEnhancements.discordDesktop/index.tsx b/src/equicordplugins/clipsEnhancements.discordDesktop/index.tsx index 634f76c77..df4e4c777 100644 --- a/src/equicordplugins/clipsEnhancements.discordDesktop/index.tsx +++ b/src/equicordplugins/clipsEnhancements.discordDesktop/index.tsx @@ -104,13 +104,6 @@ export default definePlugin({ match: /defaultConfig:\{enableClips:!\d,ignorePlatformRestriction:!\d,showClipsHeaderEntrypoint:!\d,enableScreenshotKeybind:!\d,enableVoiceOnlyClips:!\d,enableAdvancedSignals:!\d\}/, replace: "defaultConfig:{enableClips:!0,ignorePlatformRestriction:$self.settings.store.ignorePlatformRestriction,showClipsHeaderEntrypoint:!0,enableScreenshotKeybind:$self.settings.store.enableScreenshotKeybind,enableVoiceOnlyClips:$self.settings.store.enableVoiceOnlyClips,enableAdvancedSignals:$self.settings.store.enableAdvancedSignals}" } - }, - { - find: "2023-10_viewer_clipping", - replacement: { - match: /defaultConfig:\{enableViewerClipping:!\d,ignoreSenderPreference:!\d\}/, - replace: "defaultConfig:{enableViewerClipping:!0,ignoreSenderPreference:!0}" - } } ], diff --git a/src/equicordplugins/ignoreCalls/index.tsx b/src/equicordplugins/ignoreCalls/index.tsx index e3baddd28..8d04fcde7 100644 --- a/src/equicordplugins/ignoreCalls/index.tsx +++ b/src/equicordplugins/ignoreCalls/index.tsx @@ -20,14 +20,14 @@ import { FluxDispatcher, Menu, React, Tooltip, UserStore } from "@webpack/common interface CallUpdate { ringing: string[]; - ongoingRings: Record; + ongoingRings: string[]; messageId: string; region: string; } const args: CallUpdate = { ringing: [], - ongoingRings: {}, + ongoingRings: [], messageId: "", region: "", }; @@ -35,6 +35,8 @@ const args: CallUpdate = { const ignoredChannelIds = new Set(); const cl = classNameFactory("vc-ignore-calls-"); const Deafen = findComponentByCodeLazy("0-1.02-.1H3.05a9"); +const filterOngoingRings = (currentUserId: string): CallUpdate["ongoingRings"] => + args.ongoingRings.filter((id: string) => id !== currentUserId); const ContextMenuPatch: NavContextMenuPatchCallback = (children, { channel }: { channel: Channel; }) => { if (!channel || (!channel.isDM() && !channel.isGroupDM())) return; @@ -110,7 +112,7 @@ export default definePlugin({ flux: { async CALL_UPDATE({ ringing, ongoingRings, messageId, region }) { args.ringing = ringing || []; - args.ongoingRings = ongoingRings || {}; + args.ongoingRings = Array.isArray(ongoingRings) ? ongoingRings : []; args.messageId = messageId; args.region = region; } @@ -123,7 +125,7 @@ export default definePlugin({ type: "CALL_UPDATE", channelId: channel.id, ringing: args.ringing.filter((id: string) => id !== currentUserId), - ongoingRings: args.ongoingRings, + ongoingRings: filterOngoingRings(currentUserId), messageId: args.messageId, region: args.region }); @@ -144,7 +146,7 @@ export default definePlugin({ type: "CALL_UPDATE", channelId: channel.id, ringing: args.ringing.filter((id: string) => id !== currentUserId), - ongoingRings: args.ongoingRings, + ongoingRings: filterOngoingRings(currentUserId), messageId: args.messageId, region: args.region }); diff --git a/src/equicordplugins/messageLoggerEnhanced/components/LogsModal.tsx b/src/equicordplugins/messageLoggerEnhanced/components/LogsModal.tsx index 7123bd38f..e6f741313 100644 --- a/src/equicordplugins/messageLoggerEnhanced/components/LogsModal.tsx +++ b/src/equicordplugins/messageLoggerEnhanced/components/LogsModal.tsx @@ -230,7 +230,7 @@ function LogsContent({ visibleMessages, canLoadMore, sortNewest, tab, reset, han ); } -const LogsContentMemo = LazyComponent(() => React.memo(LogsContent)); +const LogsContentMemo = LazyComponent(() => LogsContent); function NoResults({ tab }: { tab: LogTabs; }) { const generateSuggestedTabs = (tab: LogTabs) => { diff --git a/src/equicordplugins/questify/index.tsx b/src/equicordplugins/questify/index.tsx index 0ec744e04..421930cc5 100644 --- a/src/equicordplugins/questify/index.tsx +++ b/src/equicordplugins/questify/index.tsx @@ -1230,7 +1230,7 @@ export default definePlugin({ }, { // Hides Quests tab in the DMs tab list. - find: "QUEST_HOME_V2):", + find: ".QUEST_HOME):", replacement: [ { match: /(?<="family-center"\):null,)/, diff --git a/src/equicordplugins/viewRawVariant/index.tsx b/src/equicordplugins/viewRawVariant/index.tsx index 78051ccce..844e99493 100644 --- a/src/equicordplugins/viewRawVariant/index.tsx +++ b/src/equicordplugins/viewRawVariant/index.tsx @@ -119,7 +119,7 @@ function makeContextCallback( children.push( action(value)} icon={CopyIcon} />, diff --git a/src/plugins/showMeYourName/index.tsx b/src/plugins/showMeYourName/index.tsx index a03c212c7..089ff1f4f 100644 --- a/src/plugins/showMeYourName/index.tsx +++ b/src/plugins/showMeYourName/index.tsx @@ -21,7 +21,7 @@ import { t } from "@utils/translation"; import definePlugin, { OptionType } from "@utils/types"; import { GuildMember, Message, User } from "@vencord/discord-types"; import { findByCodeLazy, findStoreLazy } from "@webpack"; -import { ChannelStore, GuildMemberStore, GuildRoleStore, GuildStore, Menu, MessageStore, RelationshipStore, StreamerModeStore, TextInput, useEffect, useState } from "@webpack/common"; +import { ChannelStore, GuildMemberStore, GuildStore, Menu, MessageStore, RelationshipStore, StreamerModeStore, TextInput, useEffect, useState } from "@webpack/common"; import { JSX } from "react"; const SMYNC = classNameFactory(); @@ -481,9 +481,7 @@ function renderUsername( const ircColorsEnabled = isPluginEnabled(ircColors.name); - const authorTopRole = (author as GuildMember)?.guildId && (author as any)?.highestRoleId; - const authorTopRoleColor = authorTopRole && GuildRoleStore.getRole((author as GuildMember).guildId, authorTopRole)?.colorStrings; - const authorColorStrings = colorStrings || (author as any)?.colorStrings || authorTopRoleColor || null; + const authorColorStrings = colorStrings || (author as any)?.colorStrings || null; const authorDisplayNameStyles = (!inGuild && !ircColorsEnabled && (author as any)?.displayNameStyles) || null; const effectType = authorDisplayNameStyles ? getEffectType(authorDisplayNameStyles.effectId) : null; const effectCSSVars = authorDisplayNameStyles ? computeEffectCSSVars(authorDisplayNameStyles) : {}; @@ -493,9 +491,9 @@ function renderUsername( const shouldAnimateEffect = shouldShowEffect && !AccessibilityStore.useReducedMotion; const canUseGradient = ((author as GuildMember)?.guildId ? (GuildStore.getGuild((author as GuildMember).guildId) ?? {}).premiumFeatures?.features.includes("ENHANCED_ROLE_COLORS") : !inGuild); - const useTopStyle = isMention || isReactionsPopout || channel?.isDM() || channel?.isGroupDM(); - const topStyle = author ? resolveColor(authorColorStrings, authorDisplayNameStyles, "Role", canUseGradient, inGuild, ircColorsEnabled, isHovering) : null; - const hasGradient = !!topStyle?.gradient && Object.keys(topStyle.gradient).length > 0; + const useTopRoleStyle = isMention || isReactionsPopout || channel?.isDM() || channel?.isGroupDM(); + const topRoleStyle = author ? resolveColor(authorColorStrings, authorDisplayNameStyles, "Role", canUseGradient, inGuild, ircColorsEnabled, isHovering) : null; + const hasGradient = !!topRoleStyle?.gradient && Object.keys(topRoleStyle.gradient).length > 0; const textMutedValue = getComputedStyle(document.documentElement)?.getPropertyValue("--text-muted")?.trim() || "#72767d"; const options = splitTemplate(includedNames); @@ -650,7 +648,7 @@ function renderUsername( // Only mentions and reactions popouts should patch in the gradient glow or else a double glow will appear on messages. const hoveringClass = (isHovering ? " smyn-gradient-hovered" : ""); - const gradientClasses = useTopStyle + const gradientClasses = useTopRoleStyle ? "smyn-gradient smyn-gradient-inherit-bg" + hoveringClass : "smyn-gradient smyn-gradient-unset-bg" + hoveringClass; @@ -682,7 +680,7 @@ function renderUsername( @@ -691,7 +689,7 @@ function renderUsername( {first.wrapped}