@deepan-kumar/namelint
v1.0.0
Published
Linter for function names. Catches naming issues in Ruby, JavaScript, and Python with git hooks and watch mode.
Downloads
7
Maintainers
Readme
Function Naming Checker
Stop poorly named functions before they reach production.
Automatically catches naming issues in Ruby, JavaScript, and Python:
- ✅ Pre-commit Git Hook - Blocks commits with naming issues
- ✅ Watch Mode - Real-time suggestions as you code
No manual checking required. Just code, and get instant feedback.
🎯 The Problem
Bad function names slip through code review:
# Ruby anti-patterns
def is_admin(user) # ❌ Should use ? suffix
def get_user_email(user) # ❌ Not idiomatic Ruby
def updateUser(user, data) # ❌ camelCase in Ruby
# JavaScript anti-patterns
function admin(user) { } # ❌ Missing is prefix
function doClick() { } # ❌ Generic "do" prefix
async function getData() { } # ❌ Should be fetchData
# Python anti-patterns
def getUserEmail(user): # ❌ Should be snake_case
def admin(user): # ❌ Missing is_ prefixResult: Inconsistent codebases, confused developers, harder maintenance.
✨ The Solution
1. Git Pre-commit Hook ⚡
Automatically checks every commit:
$ git commit -m "Add user validation"
🔍 Checking function naming...
❌ Found 2 naming issues:
1. app/models/user.rb:45
Current: is_admin()
Suggested: admin?()
Reason: Boolean check → use ? suffix (Ruby convention)
2. app/services/auth.js:12
Current: doLogin()
Suggested: handleLogin()
Reason: React handler → use handle prefix
Fix the issues or skip with: git commit --no-verify2. Watch Mode 👀
Real-time suggestions as you code:
$ name-check watch app/
👀 Watch Mode Started
Monitoring: app/
# You save a file...
⚡ Naming Suggestion:
📁 app/services/payment.rb:23
Current: process()
Better: calculate_discount()
Reason: Calculation detected → use calculate verb
Apply this change? (y/n/s): y
✅ Rename in your editor: process → calculate_discount🚀 Quick Start
Install
cd /Users/dkumar/Github/learn/function-naming-mcp
npm install
npm linkSetup Git Hook (One-time)
# In any project:
cd /path/to/your/project
name-check install-hookDone! Now every commit is automatically checked.
Start Watch Mode (Optional)
# In your project:
name-check watch app/ lib/Keep it running in a terminal while you code.
📋 What It Catches
Ruby/Rails (Rubocop-compliant)
| ❌ Bad | ✅ Good | Why |
|--------|---------|-----|
| is_admin() | admin?() | Predicates use ? suffix |
| get_email() | email or @property | No get_ prefix |
| updateUser() | update_user | snake_case, not camelCase |
| save() | save!() | Use ! for dangerous ops |
JavaScript/React
| ❌ Bad | ✅ Good | Why |
|--------|---------|-----|
| admin() | isAdmin() | Booleans use is/has/can |
| doClick() | handleClick() | React handlers use handle |
| getData() | fetchData() | Async functions use fetch/load |
Python (PEP 8)
| ❌ Bad | ✅ Good | Why |
|--------|---------|-----|
| getUserEmail() | get_user_email() | snake_case, not camelCase |
| admin() | is_admin() | Booleans use is_/has_ |
| checkValid() | is_valid() | Predicates use is_ |
💡 Real-World Examples
Before Git Hook
# app/models/user.rb
def is_admin
role == 'admin'
end
def get_full_name
"#{first_name} #{last_name}"
end$ git commit -m "Add user methods"
[main abc1234] Add user methods ✅ # No check!After Git Hook
$ git commit -m "Add user methods"
🔍 Checking function naming...
❌ Found 2 naming issues:
1. app/models/user.rb:12
Current: is_admin
Suggested: admin?
2. app/models/user.rb:16
Current: get_full_name
Suggested: full_name
Fix or skip with: git commit --no-verifyResult: You fix it before it reaches production.
🎯 Use Cases
1. Team Onboarding
Problem: New developers don't know Ruby conventions Solution: Git hook teaches them immediately
2. Legacy Codebase
Problem: Inconsistent naming everywhere Solution: Stop adding more bad names, gradually fix old ones
3. Code Review
Problem: Reviewers waste time on naming issues Solution: Automated checks free up reviewers for logic
4. Multi-language Projects
Problem: Mixing naming conventions across languages Solution: Language-specific checks for each file
🛠️ Commands
# Install git hook (one-time per project)
name-check install-hook
# Start watch mode
name-check watch app/ lib/
# Manual scan
name-check scan app/**/*.rb
# Scan staged files before commit
name-check scan $(git diff --cached --name-only)⚙️ Configuration
Optional .naming-config.json in project root:
{
"enabled": true,
"languages": ["ruby", "javascript", "python"],
"watchDirs": ["app/", "lib/", "src/"],
"severity": "error",
"exclude": ["node_modules/", "vendor/"]
}🤝 Works With
- ✅ Ruby on Rails
- ✅ Sinatra
- ✅ React
- ✅ Node.js
- ✅ Django
- ✅ Flask
- ✅ Any Git repository
📊 Impact
Before:
- Manual code review catches ~60% of naming issues
- Inconsistent names across the codebase
- New developers repeat the same mistakes
After:
- Automated checks catch 100% before commit
- Consistent naming enforced automatically
- New developers learn conventions instantly
📖 Documentation
- INSTALL.md - Detailed setup guide
- EXAMPLES.md - More examples
- CONTRIBUTING.md - Add new languages
🐛 Troubleshooting
"command not found: name-check"
cd /Users/dkumar/Github/learn/function-naming-mcp
npm linkGit hook not triggering
chmod +x .git/hooks/pre-commitWatch mode not working
# Make sure directories exist
name-check watch app/ lib/🎉 Get Started
# 1. Install
npm install && npm link
# 2. Setup git hook in your project
cd /path/to/your/project
name-check install-hook
# 3. Done! Try committing bad codeStart catching naming issues automatically! 🚀
📄 License
MIT © Deepan Kumar
🙏 Credits
Built with Model Context Protocol (MCP)
