1. The "Guardrails" of Development
Professional codebases rely on automation to maintain quality. We don't rely on humans to remember to format code or check for unused variables. We use tools.
The Holy Trinity
- ESLint: Finds bugs and logic errors (static analysis).
- Prettier: Enforces consistent style (formatting).
- Husky: Runs these tools automatically before you commit (git hooks).
Configure Linting & Formatting
As a team lead, I want to enforce a consistent coding style so that code reviews focus on logic, not indentation.
- Install and configure Prettier.
- Configure ESLint to work with Prettier (avoid conflicts).
- Add a rule to sort imports alphabetically (using `eslint-plugin-simple-import-sort` or similar).
- Add a rule to ban `console.log` in production code.
npm install -D prettier eslint-config-prettier eslint-plugin-prettier
.eslintrc.cjs (Example):
module.exports = {
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:react-hooks/recommended',
'prettier' // Must be last
],
rules: {
'no-console': 'warn',
'react/react-in-jsx-scope': 'off'
}
}
Automate Quality Checks (Husky)
As a developer, I want to prevent "broken" code from entering the repository.
- Install Husky and lint-staged.
- Configure a `pre-commit` hook.
- The hook must run `tsc` (type check) and `lint` only on changed files.
npx husky-init && npm install
npm install -D lint-staged
package.json:
"lint-staged": {
"*.{ts,tsx}": [
"eslint --fix",
"prettier --write"
]
}
Component Documentation (Storybook)
As a UI designer, I want to view and test components in isolation to ensure they handle all edge cases.
- Install Storybook (or Ladle for speed).
- Create a Story for the `UserCard` component.
- Create variants: "Active User", "Inactive User", "Long Name".
import type { Meta, StoryObj } from '@storybook/react';
import UserCard from './UserCard';
const meta: Meta<typeof UserCard> = {
component: UserCard,
};
export default meta;
type Story = StoryObj<typeof UserCard>;
export const Default: Story = {
args: {
name: 'John Doe',
role: 'Developer',
isActive: true,
},
};
export const Inactive: Story = {
args: {
name: 'Jane Smith',
role: 'Manager',
isActive: false,
},
};
Agile Workflow & Code Reviews
As a Senior Developer, I need to participate in Agile ceremonies and conduct code reviews to ensure high-quality deliverables.
- Agile Participation: Simulate a Sprint Planning session. Break down a large feature (e.g., "User Dashboard") into small, estimable tasks (Jira tickets).
- Code Review Simulation: Review a "Pull Request" (provided in the Bug Hunt section below). Identify:
- Performance issues (unnecessary re-renders).
- Security flaws (XSS vulnerabilities).
- Code style violations.
- Logic errors.
- Refactoring: Take a legacy class-based component and refactor it to a functional component with Hooks, improving readability and performance.
2. Agile & Collaboration
Senior developers don't just write code; they drive the process. You are expected to participate in Agile ceremonies.
📅 The Agile Cycle
- Sprint Planning: Estimating effort (Story Points) for tickets like the ones above.
- Daily Stand-ups: "Yesterday I set up Storybook. Today I'm writing stories for the Button component. No blockers."
- Retrospectives: Discussing what went well and what didn't. "We need to improve our code review turnaround time."
3. Code Reviews & Best Practices
You will be expected to conduct code reviews. This is where you ensure scalability and maintainability.
🔍 Code Review Checklist
- Functionality: Does it meet the acceptance criteria?
- Scalability: Will this component break if we add 100 items? (See Module 9)
- Readability: Are variables named clearly? Is the logic complex?
- Testing: Are there unit tests? (See Module 7)
🐛 Bug Hunt: The "Works on My Machine"
Scenario: You push code that works locally, but the CI/CD pipeline fails.
Common Causes:
- You didn't run `tsc` locally, and there's a type error in a file you didn't open.
- Case sensitivity issues (Mac/Windows are case-insensitive, Linux is case-sensitive). e.g., importing `./Button` when the file is `./button.tsx`.
- Missing environment variables in the CI environment.
The Fix: Always run the full `build` command locally before pushing if you aren't sure.