Why this matters
Context accelerates root-cause analysis and event correlation.
Error logs must include the operation name and relevant identifiers as structured fields, not just a message string.
Context accelerates root-cause analysis and event correlation.
Side-by-side examples engineers can pattern-match during review.
console.error(err);logger.error('payment failed',{op:'charge',userId,orderId,err});console.error(e)logger.error('op failed', { op, id, err })From the same buckets as this rule.
Check if loops use equality operators (== or !=) in termination conditions. These can lead to infinite loops if the condition is never met exactly. Instead, use relational operators like < or > for safer loop termination.