Patterns: Anti-Patterns
Known anti-patterns to flag during review. Fix when encountered in touched files; do not open new files just to clean these up unless directed. Load via the
patterns-reviewcontext group.
-
Mixed class/functional components without rationale.
src/components/is split 10 class / 10 functional with no clear rule. Class components are concentrated in middleware-rendered decorators (AdaptiveCardDecorator,BackButtonDecorator,BotActivityAvatarDecorator,CarouselDecorator,CSATPopupDecorator,EndLiveChatButton,LiveChatMessageActivityDecorator,LocaleDropdown,RatingFormPopupDecorator,BotActivityStatusWithReactions); functional components are concentrated in icons and popup-message rendering. The forward rule is "match the surrounding file" — seecomponents.md. There is no migration task for this. -
Inline HTML strings in widget classes.
BubbleWidget,EmbedWidget,PreChatManager, and a few helpers build DOM viaouterHTML/innerHTMLtemplate-literal strings (seewidgets.mdfor the full inventory and rules). Sites:src/widgets/bubbleWidget.tsx:119,269,465,481,545,src/widgets/embedWidget.tsx:111,129,src/preChatSteps/preChatStepsManager.ts:114,171,src/components/popUpBubbleWidget.ts:32,src/components/BackButtonDecorator.tsx:64, plus DOM-mutation sites insrc/widgets/coreWidget.ts(:1379,:1390,:850,:478). -
react-dom/serveruse in browser widget for icon serialization.src/widgets/bubbleWidget.tsx:2,232andsrc/components/popUpBubbleWidget.ts:5,29importrenderToStaticMarkupfromreact-dom/serverpurely to serialize a React<CloseIcon>to an HTML string forinnerHTMLinjection. This pulls SSR code into a browser bundle as a workaround for the inline-HTML pattern (anti-pattern 2). The two issues go away together when the surrounding template is converted tocreateRoot+ JSX. -
@ts-ignoreinstead of@ts-expect-error. 12 occurrences of@ts-ignoreand zero@ts-expect-erroracross the codebase.@ts-ignorerots silently when the underlying type issue is fixed;@ts-expect-errorerrors at compile time and forces removal. Examples:src/defaultBotProperties.ts:117,123,236,523,529,630,src/misc/WebChatConfig.ts:148,152,src/index.ts:51,src/widgets/bubbleWidget.tsx:329,src/widgets/embedWidget.tsx:187. New code uses@ts-expect-errorpertypescript.md. Not in the migration task. -
Hardcoded pixel SCSS values. Component SCSS files contain pixel literals that could be design tokens. Sample sites:
src/styles/coreWidget.scss:17,127,219,src/styles/bubbleWidget.scss:4,5,50,src/styles/csatPopup.scss:100,183,188. The cost of extracting each one to a new--tokenis higher than the readability gain at this scale; tolerate them. Perstyling.md, do not introduce new ones for spacing/typography that already have a token. -
Dead
consoleWebChatConfigurations.ts.src/interfaces/consoleWebChatConfigurations.tsdeclaresConsoleWebChatConfigurations(line 5),MenuButton(line 31),AutoPopOut(line 37),UserPromptBubble(line 44).ConsoleWebChatConfigurations,AutoPopOut, andUserPromptBubblehave zero usages anywhere in the codebase.MenuButtonis the only live export, used atsrc/misc/WebChatConfig.ts:308. The file is mostly dead code mis-housed under a misleading name; a self-comment at line 4 even acknowledges it. Cleanup: relocateMenuButtontobotProperties.tsand delete the file. Not in the migration task. -
Duplicate Csat / RatingForm singleton boilerplate.
CsatManager(src/csat/csatManager.tsx) andRatingFormManager(src/ratingForm/ratingFormManager.tsx) duplicate the entire registry/factory/dismiss pattern verbatim — theinstancesfield,getInstance,getInstanceById,removeInstance,removeAllInstances,remove, and thedismissPopupselector all match line-for-line aside from class name and domain object. Both even share the same DOM mount class (webchat__csat__container), meaning only one popup can be visible at a time. The right time to extractBasePopupManager<TConfig, TPopupComponent>is when adding a third popup manager; seemanagers.mdfor the proposed shape. Not in the migration task. -
Magic-number inline styles in TSX.
src/components/CustomCSATPopupMessage.tsx:259andsrc/components/RatingForm/CustomRatingFormPopupMessage.tsx:395both containstyle={{ marginBottom: "16px" }}. This is the entire inventory — extending it is discouraged; existing sites are not being migrated. Perstyling.md, runtime-dynamic inline styles are fine, but static magic numbers should be SCSS classes. -
Mixed
import Reactstyles. 14 files useimport * as React from "react", 14 useimport React from "react". The default form is the codified direction (seetypescript.md). Tracked for incremental rename in the migration task below.
Migration items 9 and the related I-prefix renames are inventoried in the hbf-webchat pattern migration task. Items 1–8 are flagged for review awareness only and have no scheduled cleanup.