Skip to content

thedaviddias/Front-End-Checklist / skills/console-cleanup

console-cleanup

Verified

Use when reviewing scripts, client components, bundles, or runtime behavior related to Remove console statements in production. Inspect both source code and the browser execution path so fixes target the real bottleneck or bug.

FileKindSize
SKILL.mdskill md1.8 KB
references/rule.mdmarkdown3.1 KB

references/rule.md

View on GitHub
# Remove console statements in production

> Remove or disable console.log, console.debug, and other console statements before deploying to production.

**Priority:** medium · **Difficulty:** beginner · **Time:** 10 min

---
Console statements left in production code can leak sensitive information, impact performance, and create a poor user experience.

## Code Example

#

## Common Console Methods to Remove

```javascript
// ❌ Remove before production
console.log('User data:', userData)
console.debug('API response:', response)
console.info('Feature flag enabled')
console.table(results)
console.time('operation')
console.timeEnd('operation')
console.trace('Call stack')
console.group('Group')
console.groupEnd()

// ✅ Keep for legitimate purposes
console.error('Critical error:', error)  // May keep for error tracking
console.warn('Deprecation notice')        // May keep for developer warnings
```

## Why It Matters

Console statements leak sensitive information, impact performance, and create unprofessional user experiences when visible in production.

## Best Practices

### Conditional Logging

```javascript
// ✅ Good: Environment-aware logging
const isDev = process.env.NODE_ENV === 'development'

function log(...args) {
  if (isDev) {
    console.log(...args)
  }
}

// Usage
log('Debug info:', data)
```

### Using a Logging Service

```javascript
// ✅ Good: Structured logging service

// Development: logs to console
// Production: logs to service (Sentry, LogRocket, etc.)
logger.info('User logged in', { userId: user.id })
logger.error('API failed', { endpoint, error })
```

## Build Tool Configuration

### Linter Configuration

  
    ```javascript
    // .eslintrc.js
    module.exports = {
      rules: {
        'no-console': process.env.NODE_ENV === 'production'
          ? 'error'
          : 'warn'
      }
    }
    ```
  
  
    ```json
    // biome.json
    {
      "linter": {
        "rules": {
          "suspicious": {
            "noConsoleLog": "warn"
          }
        }
      }
    }
    ```
  

### Webpack (Terser)

```javascript
// webpack.config.js
module.exports = {
  optimization: {
    minimizer: [
      new TerserPlugin({
        terserOptions: {
          compress: {
            drop_console: true
          }
        }
      })
    ]
  }
}
```

### Vite

```javascript
// vite.config.js

  build: {
    terserOptions: {
      compress: {
        drop_console: true,
        drop_debugger: true
      }
    }
  }
}
```

## Standards

- Use MDN: JavaScript Guide as the standard for how this JavaScript pattern should behave in production, not just in a small local example.
- Use web.dev: Learn JavaScript as the standard for how this JavaScript pattern should behave in production, not just in a small local example.

## Verification

### Automated Checks

- Verify the behavior in the browser after the code change, not only in static analysis.
- Inspect DevTools Network or Performance panels when the rule affects loading or execution order.
- Test the primary user flow and one edge case triggered by the changed script path.

### Manual Checks

- Confirm the code still behaves correctly when the feature is delayed, lazy-loaded, or fails.
brainstormingobra/superpowersYou MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation).Stars: 322kUpdated Claude CodeCodexVerifiedInstall
brand-guidelinesanthropics/skillsApplies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand colors or style guidelines, visual formatting, or company design standards apply.Stars: 198kUpdated Claude CodeCodexVerifiedInstall
frontend-designanthropics/skillsGuidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making choices that don't read as templated defaults.Stars: 198kUpdated Claude CodeCodexVerifiedInstall
mcp-builderanthropics/skillsGuide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK).Stars: 198kUpdated Claude CodeCodexVerifiedInstall