Script Valley
Writing Clean Code: Naming, Functions & Structure
Clean Code in Real Projects/Assessment

Practice & Assessment

Test your understanding of Clean Code in Real Projects

Multiple Choice Questions

6
1

What is the correct role of a linter in enforcing clean code?

2

In a TypeScript function signature, what is the clean code advantage of using named interfaces over 'any' for parameters?

3

What is the 'boy scout rule' applied to a codebase?

4

When arguing for refactoring time in a deadline-driven team, what type of argument is most effective?

5

What should a team's CONTRIBUTING.md clean code section cover?

6

What is the correct TypeScript approach when input type is genuinely unknown?

Coding Challenges

1
1

Set Up ESLint and Husky for a Clean Code Pipeline

You are given a bare Node.js project with ten JavaScript files that currently have no linting. Input: the provided bare-project/ directory. Output: the same project with ESLint configured to enforce max-lines-per-function at 20, max-params at 3, complexity at 5, and no-magic-numbers; Prettier configured for consistent formatting; Husky pre-commit hook running lint-staged; and a lint script in package.json. Fix all existing lint errors in the ten files to make lint pass. Document each ESLint rule added and why in a LINT_SETUP.md file. Estimated time: 30 minutes.

Medium

Mini Project

1

Production-Ready Clean Codebase: Task Management API

Build a small task management REST API (create, read, update, delete tasks with user assignment and due dates) from scratch applying every principle from this course. Requirements: all variables and functions must have intention-revealing names following language conventions; no function exceeds 20 lines; all functions use parameter objects when parameters exceed 2; business logic is separated from Express route handlers into pure functions; feature-based folder structure (tasks/, users/, shared/) with barrel exports; all magic values are named constants; public functions have JSDoc comments; a README.md with quick start, environment variables, and API usage; ESLint and Prettier configured and passing; a CONTRIBUTING.md with the team naming and function standards you used; and full test coverage of all business logic functions. The project must run end-to-end with real HTTP requests.

Hard