clean-codejs-functions
Installation
SKILL.md
Clean Code JavaScript – Function Patterns
Table of Contents
- Single Responsibility
- Function Size
- Parameters
- Side Effects
Single Responsibility
// ❌ Bad
function handleUser(user) {
saveUser(user);
sendEmail(user);
}
// ✅ Good
function saveUser(user) {}
function notifyUser(user) {}
Function Size
Keep functions small (ideally < 20 lines).
Parameters
// ❌ Bad
function createUser(name, age, city, zip) {}
// ✅ Good
function createUser({ name, age, address }) {}
Side Effects
// ❌ Bad
let total = 0;
function add(value) {
total += value;
}
// ✅ Good
function add(total, value) {
return total + value;
}
Related skills
More from damianwrooby/javascript-clean-code-skills
clean-codejs-modules
Module and file-structure patterns for clean JavaScript architecture.
82clean-codejs-objects
Object and class design patterns following Clean Code JavaScript.
72clean-codejs-naming
Naming patterns and conventions based on Clean Code JavaScript principles.
8clean-codejs-comments
Commenting patterns that improve readability and maintainability.
6