npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, πŸ‘‹, I’m Ryan HefnerΒ  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you πŸ™

Β© 2026 – Pkg Stats / Ryan Hefner

smart-renamer

v1.2.0

Published

πŸš€ Intelligent file and code naming suggestions based on project-specific naming conventions. Interactive CLI tool with AST-based code analysis for variables, functions, components, and more.

Readme

Renamer

πŸš€ Intelligent file and code naming suggestions based on project-specific naming conventions.

A TypeScript/Bun CLI tool that automatically detects, suggests, and validates naming patterns for both files and code. Analyzes variables, functions, components, constants, and more!

✨ Features

File Operations

  • 🎯 Smart Convention Detection: Automatically detects naming patterns from existing files
  • πŸ”„ Interactive Renaming: Ask yes/no for each file individually
  • 🚫 Smart Exclusions: Automatically skips config files, images, and declaration files
  • πŸ‘€ File Watcher: Monitor for new files and suggest names in real-time

Code Operations ⭐ NEW

  • πŸ’» Code Analysis: Analyze variables, functions, components, constants in your codebase
  • βš›οΈ React Component Detection: Automatically identifies React components
  • πŸ” AST-Based Parsing: Deep code analysis using Babel parser
  • βœ… Code Validation: Validate naming conventions with detailed suggestions

General

  • βš™οΈ Flexible Configuration: Store both file and code naming preferences
  • πŸ–₯️ CLI Interface: Comprehensive command-line tool
  • πŸ“Š Project Analysis: Analyze naming consistency across files and code
  • 🎨 Visual Feedback: Clear violation reports with suggestions

🎨 Supported Naming Conventions

File/Folder Conventions

  • camelCase: fileName.ts
  • snake_case: file_name.ts
  • kebab-case: file-name.ts
  • PascalCase: FileName.ts
  • UPPER_SNAKE_CASE: FILE_NAME.ts

Code Conventions

  • Variables: camelCase (totalPrice, userName)
  • Functions: camelCase (calculateShipping, processPayment)
  • Components: PascalCase (UserCard, ProductList)
  • Constants: UPPER_SNAKE_CASE (MAX_RETRY_COUNT, API_URL)
  • Classes: PascalCase (PaymentProcessor, UserManager)
  • Interfaces: PascalCase (UserProfile, ApiResponse)
  • Types: PascalCase (PaymentStatus, OrderType)
  • Enums: PascalCase (OrderStatus, UserRole)

πŸ“¦ Installation

npm install -g smart-renamer
# or
bun install -g smart-renamer

πŸš€ Quick Start

# Initialize in your project (now includes code conventions!)
cd your-project
renamer init

# Analyze everything - files AND code patterns
renamer analyze

# Rename files interactively
renamer rename

# Validate code naming conventions
renamer validate-code --fix

πŸ“‹ Commands

🎯 Core Commands

renamer analyze ⭐ Enhanced

Analyze both file and code naming patterns:

# Analyze everything (files + code)
renamer analyze

# Analyze only code naming patterns  
renamer analyze --code-only

# Analyze only file naming patterns
renamer analyze --files-only

# Analyze specific file patterns
renamer analyze --patterns="src/**/*.ts,tests/*.ts"

Example Output:

πŸ“Š Project Analysis

πŸ“ File Naming Analysis
════════════════════════════════════════
πŸ“ Total files: 45
🎯 Most common convention: kebab-case
πŸ“ˆ File consistency: 87.3%

πŸ’» Code Naming Analysis  
════════════════════════════════════════
πŸ’» Total identifiers: 342
πŸ“ˆ Code consistency: 94.2%
🎯 Violations found: 8

πŸ“‹ Code convention breakdown:
   Variables (245 total):
   βœ… camelCase            231 (94.3%)
      snake_case            14 (5.7%)
   
   Functions (58 total):
   βœ… camelCase             58 (100.0%)
   
   Components (23 total):
   βœ… PascalCase            23 (100.0%)

🎯 Recommendations
════════════════════════════════════════
πŸ’» Code naming could be improved:
   β€’ Run `renamer validate-code --fix` to see code suggestions

renamer init

Initialize with both file and code conventions:

renamer init
# Now asks about code conventions too!
# - Variables: camelCase, snake_case, etc.
# - Functions: camelCase, snake_case, etc.  
# - Components: PascalCase (recommended)
# - Constants: UPPER_SNAKE_CASE, etc.

πŸ“ File Operations

renamer rename

Interactive file renaming:

# Interactive mode - asks yes/no for each file
renamer rename

# Preview what would be renamed
renamer rename --dry-run

# Rename all files without asking
renamer rename --force

# Keep specific files unchanged
renamer rename --keep "file1.js,file2.ts"

renamer validate

Validate file names:

# Check all files
renamer validate

# Show suggested fixes
renamer validate --fix

πŸ’» Code Operations ⭐ NEW

renamer validate-code

Validate code naming conventions:

# Check code conventions
renamer validate-code

# Show detailed suggestions for violations
renamer validate-code --fix

# Check specific file patterns
renamer validate-code --patterns="src/**/*.ts"

Example Output:

πŸ” Validating code conventions...

❌ Found 3 naming violations:

πŸ“ src/components/user-card.tsx:
   Line 15: variable "user_name" should be "userName"
   πŸ’‘ Alternatives: PascalCase: UserName, kebab-case: user-name

πŸ“ src/utils/payment.ts:
   Line 8: function "process_payment" should be "processPayment"
   πŸ’‘ Alternatives: PascalCase: ProcessPayment

πŸ“Š Total: 3 violations in 2 files

renamer analyze-code

Detailed code analysis:

renamer analyze-code

πŸ”§ Other Commands

renamer set-convention <convention>

renamer set-convention kebab-case

renamer suggest <filename>

renamer suggest "MyFileName.ts"

renamer watch

renamer watch

βš™οΈ Configuration

Create a naming.config file in your project root:

[naming]
convention=kebab-case
files=*.ts,*.js
folders=kebab-case
exceptions=index,main,app

[code]
variables=camelCase
functions=camelCase
components=PascalCase
constants=UPPER_SNAKE_CASE
classes=PascalCase
interfaces=PascalCase
types=PascalCase
enums=PascalCase

Configuration Options

File Settings

  • convention: Primary file naming convention
  • files: File patterns to apply the convention to
  • folders: Naming convention for directories
  • exceptions: Files that don't need to follow the convention

Code Settings ⭐ NEW

  • variables: Variable naming convention
  • functions: Function naming convention
  • components: React component naming convention
  • constants: Constant naming convention
  • classes: Class naming convention
  • interfaces: Interface naming convention
  • types: Type alias naming convention
  • enums: Enum naming convention

🚫 Smart Exclusions

The tool automatically skips these file types:

Automatically Excluded:

  • Config files: Any file containing "config" (next.config.mjs, webpack.config.js)
  • Image files: .jpg, .png, .svg, .gif, etc.
  • Markdown files: .md, .markdown
  • Declaration files (all languages):
    • TypeScript: .d.ts, .d.mts, .d.cts (like next-env.d.ts, types.d.ts)
    • C/C++: .h, .hpp, .hxx (header files)
    • Python: .pyi (stub files)
    • And more: .hi, .rbi, .rei, .mli, .sig, .fsi, .spec, .def
  • System files: package.json, tsconfig.json, .gitignore, etc.
  • Lock files: package-lock.json, yarn.lock, bun.lockb

πŸ“– Usage Examples

Typical Workflow

# 1. Initialize in your project (includes code conventions)
cd my-react-app
renamer init

# 2. Set up both file and code conventions
# Choose kebab-case for files, camelCase for variables, PascalCase for components

# 3. Analyze everything 
renamer analyze
# Shows both file and code naming patterns

# 4. Fix file naming
renamer rename

# 5. Fix code naming  
renamer validate-code --fix
# Shows exactly which variables/functions need renaming

# 6. Set up file watching for new files
renamer watch

Code Analysis Example

$ renamer validate-code --fix

πŸ” Validating code conventions...

πŸ“ Variables: camelCase
πŸ”§ Functions: camelCase  
βš›οΈ  Components: PascalCase
πŸ“Š Constants: UPPER_SNAKE_CASE

❌ Found 5 naming violations:

πŸ“ src/components/user-profile.tsx:
   Line 12: variable "user_data" should be "userData"
   Line 25: function "render_avatar" should be "renderAvatar"  
   πŸ’‘ Alternatives: PascalCase: RenderAvatar

πŸ“ src/utils/api-client.ts:
   Line 8: constant "api_url" should be "API_URL"
   Line 15: function "make_request" should be "makeRequest"

πŸ“‹ Violation Summary:
   variable: 2 violations
   function: 2 violations  
   constant: 1 violations

πŸ“Š Total: 5 violations in 2 files

πŸ’‘ Use --fix to see suggested alternatives

🎯 Why Use Renamer?

  • Consistency: Maintain consistent naming across files AND code
  • Team Standards: Enforce team naming conventions for everything
  • Code Quality: Improve codebase readability and maintainability
  • React Support: Smart detection of React components
  • Refactoring: Easily migrate from one naming style to another
  • CI/CD Integration: Use in pipelines to ensure naming standards

πŸ› οΈ Tech Stack

  • Runtime: Bun
  • Language: TypeScript
  • AST Parser: Babel Parser (for code analysis)
  • CLI: Commander.js
  • File Watching: Chokidar
  • Interactive Prompts: Inquirer.js

πŸ“‹ Package Update Instructions

To update your published package with the new code-level functionality:

1. Update Version

# Already done - version is now 1.1.0
npm version patch  # or minor/major

2. Build and Test

bun run build
bun test
bun run check  # Test the new analyze command

3. Publish to NPM

# Login if needed
npm login

# Publish the updated package
npm publish

4. Verify Installation

# Test global installation
npm install -g smart-renamer@latest

# Test the new features
renamer --version  # Should show 1.1.0
renamer analyze --help  # Should show new options

5. Update Documentation

The README is now updated with:

  • βœ… Code-level analysis features
  • βœ… Enhanced renamer analyze command
  • βœ… New configuration options
  • βœ… Code validation examples
  • βœ… Complete usage workflows

Your package now offers comprehensive naming convention management for both files and code! πŸš€

🀝 Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.


Made with ❀️ for developers who care about consistent naming conventions in files AND code.