Overview Version History Q & A Rating & Review
React Crash Guard
Detect potential runtime crashes in React/TypeScript/JavaScript code before they happen in production.
Philosophy
All crashes are critical. Every crash affects users. This extension doesn't prioritize by severity—it finds every potential crash so you can decide what to fix.
Features
Null/Undefined Detection
Static Analysis - Analyzes your code without running it
Framework Aware - Works with React class components, handles this keyword properly
SSR/CSR Support - Configure rendering mode to detect window/document issues in SSR
Smart Detection - Identifies dangerous patterns like unguarded .find(), optional chaining gaps, ref access
Exception Detection
JSON.parse() - Flags unhandled calls that throw on invalid JSON
new URL() - Detects URL constructor without try-catch
new RegExp() - Catches dynamic regex that can throw on invalid patterns
atob()/btoa() - Base64 functions that throw on invalid input
decodeURI()/decodeURIComponent() - URI functions that throw on malformed input
Async/Await - Optional detection of unhandled promise rejections
Quick Fixes
Optional chaining (?.)
Nullish coalescing (??)
Type guards and null checks
Try-catch wrappers for throwing functions
Installation
Open VS Code
Go to Extensions (Ctrl+Shift+X)
Search for "React Crash Guard"
Click Install
Usage
Open a TypeScript/JavaScript/React project
The extension analyzes files automatically on open/save
View issues in the Problems panel
Use Quick Fix (Ctrl+.) to apply suggested fixes
Commands
Command
Description
React Crash Guard: Select Project/Folder to Analyze
Choose which folder to analyze
React Crash Guard: Analyze Workspace for Crash Issues
Re-analyze the entire workspace
React Crash Guard: Analyze Current File for Crash Issues
Analyze only the active file
React Crash Guard: Show Safety Report
View detailed report in webview
React Crash Guard: Generate Report File
Export report as JSON/Markdown
React Crash Guard: Clear All Diagnostics
Clear all reported issues
Configuration
General Settings
Setting
Default
Description
reactCrashGuard.enabled
true
Enable/disable the extension
reactCrashGuard.analyzeOnSave
true
Analyze files on save
reactCrashGuard.analyzeOnOpen
true
Analyze files when opened
reactCrashGuard.treatThisAsSafe
true
Treat this as safe in class methods
reactCrashGuard.excludePatterns
[...]
Glob patterns to exclude
Rendering Mode
Setting
Default
Description
reactCrashGuard.renderingMode
csr
csr, ssr, or universal
reactCrashGuard.csrSafeSelectors
[]
CSS selectors guaranteed to exist (e.g., #root)
CSR (Client-Side Rendering) : window/document are safe
SSR (Server-Side Rendering) : window/document are flagged as unsafe
Universal : window/document flagged unless guarded with typeof check
Exception Detection
Setting
Default
Description
reactCrashGuard.detectExceptions
true
Master toggle for exception detection
reactCrashGuard.detectJsonParse
true
Flag JSON.parse() without try-catch
reactCrashGuard.detectUrlConstructor
true
Flag new URL() without try-catch
reactCrashGuard.detectRegexConstructor
true
Flag new RegExp() with variables
reactCrashGuard.detectBase64
true
Flag atob()/btoa() without try-catch
reactCrashGuard.detectUriDecode
true
Flag decodeURI()/decodeURIComponent()
reactCrashGuard.detectAwaitWithoutTry
false
Flag await without try-catch (noisy)
reactCrashGuard.detectPromiseWithoutCatch
false
Flag Promise chains without .catch()
reactCrashGuard.customThrowingFunctions
[]
Your own functions that throw
Advanced
Setting
Default
Description
reactCrashGuard.assertionFunctions
["assert", ...]
Functions that assert non-null
reactCrashGuard.trustedGlobals
["console", ...]
Globals that are never null
reactCrashGuard.ignoreThirdPartyImports
true
Skip analysis on node_modules imports
Detected Patterns
Null/Undefined Risks
Property access on nullable values (obj.prop)
Method calls on nullable values (obj.method())
Array access without bounds checking (arr[i])
Destructuring nullable objects (const { x } = obj)
Spreading nullable values ([...arr], {...obj})
Dangerous method results (.find(), .pop(), querySelector())
Browser globals in SSR (window, document)
React ref access (ref.current.something)
Exception Risks
JSON.parse() with untrusted input
new URL() with dynamic strings
new RegExp() with user input
atob()/btoa() with unvalidated data
decodeURI()/decodeURIComponent() with external data
// @crash-guard-ignore - Ignore this line
// @crash-guard-ignore-next-line - Ignore next line
// @crash-guard-ignore-file - Ignore entire file (place at top)
// Legacy suppression (still supported):
// @null-safe-ignore
// @null-safe-ignore-next-line
// @null-safe-ignore-file
Example
// ❌ Flagged: .find() can return undefined
const user = users.find(u => u.id === id);
console.log(user.name); // Crash if not found!
// ✅ Safe: Check before access
const user = users.find(u => u.id === id);
if (user) {
console.log(user.name);
}
// ❌ Flagged: JSON.parse throws on invalid JSON
const data = JSON.parse(userInput);
// ✅ Safe: Wrap in try-catch
try {
const data = JSON.parse(userInput);
} catch (e) {
// Handle invalid JSON
}
License
MIT
Author
Samuel Sunny Wilson
Links