Angular Best Practices

The following points are best practices for Angular Developers: 

1. Consistent Folder Structure, Modular Architecture, Component Structure within micro apps :

2. Use Angular CLI for creating new component/module/interface etcs

4. Follow Single Responsibility Principle

5. Meaningful Naming Conventions

6. Use of Dependency Injection

7. Avoid Direct DOM Manipulations/ Avoid Directives for Presentational Logic

8. Use Reactive Forms

9. Handle Errors Gracefully

10. Use TrackBy with NgFor

11. Minimize Use of any Type

12. Lazy Loading Modules

13. Leverage Angular’s HttpClient

14. Optimize Angular Performance 

15. Use Features of ES6

16. Prevent Memory Leaks in Angular Observable (using takeUntill(), take(1), Async pipe)

17. Avoid Logic in template file

18. Use Environment Variables

19. Use Lint Rules (no-any, no-console, no-magic-numbers)

20. Files should be limited to 400 lines of code.
Create short functions with no more than 75 lines of code.
Declare it with ‘const’ if the variables’ values aren’t changing.
Property and method names should always be written in Camelcase and meaningful.

21. Use State Management

22. Documentation in Code

23. Use Interfaces

24. Use Route Guards on the Navigation

25. Code Review on the Gitlab branch with adding comments

27. Sonar lint in every developer vs-code

26. Code coverage report



Comments