no-console rule prevents usage of native console methods (console.log(), console.error(), etc.) in UI extensions.
Rule details
UI extensions should use the SDK’s structuredlogger utility instead of native console.* methods. This helps streamline UI extension debugging, as you won’t need to sort through other framework logs and network activity to find extension-specific logs.
The SDK logger integrates with HubSpot’s logging infrastructure, providing proper log levels, formatting, and the ability to filter and search across installs. Using console.* methods bypasses these benefits.
Console method alternatives
Use the following UI extension alternatives instead of browser console methods:| Console API | SDK Logger Alternative | Purpose |
|---|---|---|
console.log() | logger.debug() | Debug-level logging |
console.info() | logger.info() | Informational logging |
console.warn() | logger.warn() | Warning-level logging |
console.debug() | logger.debug() | Debug-level logging |
console.error() | logger.error() | Error-level logging |
actions.addAlert() or the <Alert> component instead of console output.
See the next section for an example of each alternative.
Examples
Basic logging
Instead of usingconsole.* methods for logging:
logger:
Error handling
Instead of usingconsole.error():
logger.error() for debugging and actions.addAlert() for user-facing errors:
<Alert> component for inline error messages: