- Use TypeScript for all source files.
- Prefer ES6+ features (e.g.,
const,let, arrow functions). - Use Angular’s official style guide as a baseline: https://angular.io/guide/styleguide
- Indentation: 2 spaces, no tabs.
- Line length: 120 characters max.
- Use single quotes for strings (
'example'), except in JSON. - End files with a newline.
- Use semicolons at the end of statements.
- Classes, interfaces:
PascalCase(e.g.,UserService) - Variables, functions, properties:
camelCase(e.g.,userName) - Constants:
UPPER_CASEif exported, otherwisecamelCase - File names:
kebab-case(e.g.,user-profile.component.ts)
- Use ES6 import/export syntax.
- Group imports: Angular first, then third-party, then local.
- Avoid relative imports with long paths; use
tsconfigpaths if possible.
- One component/service per file.
- Use Angular CLI to generate components, services, etc.
- Use
@Injectable()for services. - Use
@Input()and@Output()for component communication.
- Write meaningful comments, but avoid obvious ones.
- Use
//for single-line and/* ... */for block comments.
- All components, services, and utilities should have corresponding
.spec.tsfiles. - Use
describe,it,beforeEach, andafterEachfor test structure. - Test names should clearly state the expected behavior.
- Write clear, descriptive commit messages.
- Keep pull requests focused and small.
- Reference related issues in PRs.