JSPM

vibe-check-code

1.0.2
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 12
  • Score
    100M100P100Q65062F
  • License MIT

Code quality analyzer for React applications with gamified scoring

Package Exports

  • vibe-check-code
  • vibe-check-code/dist/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (vibe-check-code) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

๐ŸŽฏ Vibe Check

Code quality analyzer for React applications with gamified scoring

Analyze your React codebase and get a 0-100 score with actionable feedback on state management, component quality, and performance.

โœจ Features

  • ๐ŸŽฎ 0-100 scoring system - Gamified code quality measurement
  • ๐Ÿ“‹ Table-based output - Clean, scannable results like Istanbul coverage
  • ๐Ÿšจ Critical file identification - See which files need refactoring most
  • ๐ŸŽฏ Actionable insights - Every issue includes guidance on what to improve
  • ๐Ÿ“š Educational feedback - Learn React best practices through detailed analysis
  • โšก Fast analysis - TypeScript/JavaScript React file analysis

๐Ÿš€ Quick Start

# Install as dev dependency in your project (recommended)
npm install --save-dev vibe-check-code

# Or install globally
npm install -g vibe-check-code

# Add to your package.json scripts
{
  "scripts": {
    "vibe-check": "vibe-check ./src",
    "vibe-check:score": "vibe-check ./src --score-only",
    "vibe-check:json": "vibe-check ./src --format json"
  }
}

# Run analysis
npm run vibe-check

# Or run directly
npx vibe-check ./src

๐Ÿ“Š Example Output

๐ŸŽฏ Vibe Check Results
Analyzed 45 files in 234ms

๐Ÿ“Š Overall Score: 73/100 (Good vibes! ๐Ÿ˜Š)

๐Ÿ”ด Issues Found (3)
โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
File                    โ”‚ Line     โ”‚ Category           โ”‚ Message
โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
Dashboard.tsx           โ”‚ 15:1     โ”‚ ๐Ÿ—๏ธ Component Quality โ”‚ Large component detected (300 lines)
UserProfile.tsx         โ”‚ 23:5     โ”‚ ๐ŸŽฏ State Management  โ”‚ State usage detected in component with props
ExpensiveList.tsx       โ”‚ 45:12    โ”‚ โšก Performance       โ”‚ Complex component - consider optimizations

๐Ÿšจ Files That Need Refactoring (2)

1. ๐Ÿ”ฅ Dashboard.tsx
   Score: 23/100 | 2 errors | 1 warning | 5 suggestions
   ๐Ÿ”ฅ CRITICAL: Immediate attention required!

๐Ÿ“ˆ Score Breakdown:
  ๐ŸŽฏ State Management: 85/100 [โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–‘โ–‘] Looking good!
  ๐Ÿ—๏ธ Component Quality: 67/100 [โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–‘โ–‘โ–‘โ–‘] Room for improvement  
  โšก Performance: 78/100 [โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–‘โ–‘โ–‘] Looking good!

๐Ÿ“‹ Rules

๐ŸŽฏ State Management

  • Prop drilling detection - Tracks props passed through 3+ components without usage
  • Context overuse analysis - Identifies excessive Context Provider nesting (3+ levels)
  • State chaos detection - Flags components with 5+ useState/useReducer hooks
  • Magic values identification - Finds repeated string/number literals that should be constants
  • Messy structure analysis - Detects files with 3+ component definitions

๐Ÿ—๏ธ Component Quality

  • Large components - Flags components over 150 lines (configurable)
  • Unused props - Detects props that are defined but never used
  • High complexity - Identifies components with too many decision points
  • Complex JSX - Flags JSX structures with too many elements
  • Many hooks - Suggests extracting logic when components have too many hooks

โšก Performance

  • Missing React.memo - Suggests memo for complex components with props
  • Missing useMemo - Identifies expensive operations without memoization
  • Missing useCallback - Finds callback props that should be optimized

โš™๏ธ Configuration

Create .vibecheck.json in your project root:

{
  "rules": {
    "prop-drilling-depth": 3,
    "max-component-lines": 150,
    "require-memo": true
  },
  "ignore": [
    "**/*.test.tsx",
    "**/*.test.ts",
    "**/*.stories.tsx",
    "**/node_modules/**"
  ],
  "severity": {
    "large-component": "error",
    "unused-props": "warning",
    "high-complexity": "warning",
    "complex-jsx": "warning",
    "many-hooks": "warning",
    "prop-drilling": "error",
    "context-overuse": "warning",
    "state-chaos": "warning",
    "magic-values": "warning",
    "messy-structure": "warning",
    "missing-memo": "warning",
    "missing-usememo": "warning",
    "missing-usecallback": "warning"
  }
}

Project Setup

# Initialize config in your React project
npx vibe-check init

# Add to package.json scripts
{
  "scripts": {
    "lint": "eslint src/",
    "type-check": "tsc --noEmit",
    "vibe-check": "vibe-check src/",
    "quality": "npm run lint && npm run type-check && npm run vibe-check"
  }
}

๐Ÿ› ๏ธ CLI Commands

# Via npm scripts (recommended)
npm run vibe-check              # Run your configured analysis
npm run vibe-check:score        # Just show the score
npm run vibe-check:json         # JSON output for CI/CD

# Direct usage
npx vibe-check [path]           # Analyze directory
npx vibe-check --format json    # JSON output for CI/CD
npx vibe-check --score-only     # Just show the score
npx vibe-check --verbose        # Show detailed analysis information
npx vibe-check init             # Create config file
npx vibe-check list-rules       # Show all available rules

๐Ÿ“Š Scoring

  • 90-100: Excellent vibes! ๐Ÿš€
  • 80-89: Great vibes! ๐ŸŒŸ
  • 70-79: Good vibes! ๐Ÿ˜Š
  • 60-69: Decent vibes ๐Ÿ‘
  • 50-59: Mixed vibes ๐Ÿ˜
  • 0-49: Needs attention ๐Ÿ˜ฑ

Penalty System:

  • Errors: -15 points
  • Warnings: -8 points
  • Suggestions: -2 points

๐Ÿ’ก Why Use Vibe Check?

  • Learn React best practices through detailed code analysis
  • Identify improvement opportunities with clear guidance on what to change
  • Prioritize refactoring efforts with critical file identification
  • Track code quality progress with quantified scoring
  • Understand codebase health across team and projects
  • Educational tool for developers to learn better React patterns
  • Table-based output makes it easy to scan through many issues
  • Modular rule system focuses on the most impactful React improvements
  • Integrate with existing workflows via npm scripts and CI/CD pipelines

๐Ÿค Contributing

We welcome contributions! Here's how you can help improve Vibe Check:

๐Ÿ› Report Issues

Found a bug or have a feature request?

  1. Check existing GitHub Issues
  2. Create a new issue with:
    • Clear description of the problem
    • Steps to reproduce (for bugs)
    • Expected vs actual behavior
    • Sample React code that demonstrates the issue

๐Ÿ’ก Suggest New Rules

Have ideas for detecting React anti-patterns?

  1. Open an issue with the rule-suggestion label
  2. Include:
    • Rule name and description
    • Detection method - how to identify the pattern
    • Suggestion - what developers should do instead
    • Code examples showing good vs bad patterns

๐Ÿ”ง Development Setup

# Clone the repository
git clone https://github.com/your-username/vibe-check.git
cd vibe-check

# Install dependencies
npm install

# Build the project
npm run build

# Link for local testing
npm link

# Test your changes on a project
cd /path/to/your/react/project
npm install --save-dev vibe-check-code
npm run vibe-check

๐Ÿ“ Adding New Rules

Vibe Check has a modular architecture that makes adding rules straightforward:

State Management Rules

Add to src/rules/state-management/:

// src/rules/state-management/my-new-rule.ts
import traverse, { NodePath } from '@babel/traverse';
import { RuleContext, Issue } from '../../types';

export function detectMyNewRule(context: RuleContext): Issue[] {
  const issues: Issue[] = [];
  
  traverse(context.ast, {
    // Your AST traversal logic here
    CallExpression(path: NodePath) {
      // Example: detect specific patterns
      if (/* your condition */) {
        issues.push({
          rule: 'my-new-rule',
          category: 'state-management',
          severity: 'warning',
          message: 'Description of the issue',
          line: path.node.loc?.start.line || 0,
          column: path.node.loc?.start.column || 0,
          suggestion: 'How to fix this issue'
        });
      }
    }
  });
  
  return issues;
}

Then export it in src/rules/state-management/index.ts:

import { detectMyNewRule } from './my-new-rule';

export function analyzeStateManagement(context: RuleContext): RuleResult {
  // ... existing rules
  const myNewRuleIssues = detectMyNewRule(context);
  issues.push(...myNewRuleIssues);
  // ...
}

Component Quality & Performance Rules

Follow the same pattern in their respective folders.

๐Ÿงช Testing Your Changes

# Build and test locally
npm run build

# Test on a real React project
vibe-check /path/to/your/react/project

# Test specific scenarios
mkdir test-cases
echo 'your test React code' > test-cases/example.tsx
vibe-check test-cases/

๐Ÿ“‹ Pull Request Guidelines

  1. Fork the repository and create a feature branch
  2. Write clear commit messages describing your changes
  3. Update documentation if adding new rules or changing behavior
  4. Test thoroughly on real React codebases
  5. Keep changes focused - one feature/fix per PR

๐Ÿ“š Documentation Improvements

Help make Vibe Check more accessible:

  • Improve rule descriptions and examples
  • Add more configuration examples
  • Create guides for common use cases
  • Fix typos or unclear explanations

๐Ÿ’ฌ Community

  • Discussions - Share ideas and ask questions in GitHub Discussions
  • Issues - Report bugs and request features
  • Pull Requests - Contribute code improvements

๐Ÿ“Š Rule Quality Standards

When contributing new rules, ensure they:

  • Minimize false positives - avoid flagging valid React patterns
  • Provide clear guidance - suggestions should be actionable
  • Handle edge cases - robust error handling and graceful failures
  • Follow naming conventions - use kebab-case for rule names
  • Include good examples - demonstrate the pattern being detected

Made with โค๏ธ for the React community

Keep those vibes high! โœจ