Skip to content
Back to skills

Js Early Exit

ASecurity

Imported skill js_early_exit from vercel

  • 3 stars
  • 0 votes
  • 0 copies
  • 4 views
  • Added September 11, 2026
developmentjavascripttypescriptjavareact

Security analysis

A100/100

Scanned September 11, 2026

npx -y skills add bitwikiorg/skills.md --skill js_early_exit --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Js Early Exit?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Js Early Exit
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/bitwikiorg-js-early-exit/badge)](https://www.skillsdirectory.com/skills/bitwikiorg-js-early-exit)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
description: Imported skill js_early_exit from vercel
name: js_early_exit
signature: 925ce5ce87f3347186ca62212f29cc6baa2b8c85a96d2720ad07c3d0abf781c0
source: /a0/tmp/skills_research/vercel/skills/react-best-practices/rules/js-early-exit.md
---

---
title: Early Return from Functions
impact: LOW-MEDIUM
impactDescription: avoids unnecessary computation
tags: javascript, functions, optimization, early-return
---

## Early Return from Functions

Return early when result is determined to skip unnecessary processing.

**Incorrect (processes all items even after finding answer):**

```typescript
function validateUsers(users: User[]) {
  let hasError = false
  let errorMessage = ''
  
  for (const user of users) {
    if (!user.email) {
      hasError = true
      errorMessage = 'Email required'
    }
    if (!user.name) {
      hasError = true
      errorMessage = 'Name required'
    }
    // Continues checking all users even after error found
  }
  
  return hasError ? { valid: false, error: errorMessage } : { valid: true }
}
```

**Correct (returns immediately on first error):**

```typescript
function validateUsers(users: User[]) {
  for (const user of users) {
    if (!user.email) {
      return { valid: false, error: 'Email required' }
    }
    if (!user.name) {
      return { valid: false, error: 'Name required' }
    }
  }

  return { valid: true }
}
```

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.