Personal Angular Best Practices

This page summarizes the projects mentioned and recommended in the original post on /r/Angular2

Our great sponsors
  • SurveyJS - Open-Source JSON Form Builder to Create Dynamic Forms Right in Your App
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • WorkOS - The modern identity platform for B2B SaaS
  • angular-eslint

    :sparkles: Monorepo for all the tooling related to using ESLint with Angular

  • I don't think it's crazy, but these things improved my code quality a lot: * Use Prettier, an opinionated code formatter. It formats your code, no configuration, no fights with your colleagues. * Use eslint and SonarLint. They help you find bugs before you even commit your code. * Try to achieve a very high code coverage. Not every line needs to be covered, but I personally feel better if I've got 90+% coverage. It's not that hard once you include it in your coding-DNA. * Setup your IDE to properly debug your code. Don't do console.log(), use debugger; statements or real conditional breakpoints. Nothing sucks more than not being able to find out what your code really does. * Learn the ES6 and later features. Many developers tend to code in old ways (as they are used to), but JavaScript can do so much more these days. You'll save a lot of time and effort applying these new features. Start with Arrow Functions, followed by Rest and Spread operator, Property Shorthand and * Destructuring . Also note that there are some awesome new datastructures like Map and Set. * Learn TypeScript and keep yourself up to date. There are so many anti-patterns (never ever use any) that degregate your fancy, strictly typed highlevel code to buggy ES-code. It also helps a lot to reduce DRY and boilerplate. * Learn rxjs and use it on a daily base. Angular itself is really reactive as most Angular services return Observables that can be further processed with rxjs. Once your mind made the switch, you won't really use regular Events and/or loops anymore. But be aware of how to properly test your rxjs pipelines. * If you are integrating a remote API, I have very good experiences with OpenAPI and it's code generator for Angular. You will get ready-to-use interfaces and services just from an OpenAPI specification (which you get as a gift for many of the modern backend frameworks). Saves a lot of time and boilerplate code and removes the need to test and debug API-layer code. Your build will break as soon as the API introduces a breaking change, which is exactly what you want (it's too late if your app breaks on production)

  • storybook

    Storybook is a frontend workshop for building UI components and pages in isolation. Made for UI development, testing, and documentation.

  • In your daily work, plan some time for refactoring. Scroll and look through your code and try to improve it. Don't like the naming of a component? Module structure seems unlogical? Missing some test coverage? Dig into and refactor that stuff. Always think "If I was a new developer working on that project, would be everything crystal clear for me?". Adding README files (on module or component level as well) or using component library like Storybook is also very useful.

  • SurveyJS

    Open-Source JSON Form Builder to Create Dynamic Forms Right in Your App. With SurveyJS form UI libraries, you can build and style forms in a fully-integrated drag & drop form builder, render them in your JS app, and store form submission data in any backend, inc. PHP, ASP.NET Core, and Node.js.

    SurveyJS logo
  • prettier

    Prettier is an opinionated code formatter.

  • I don't think it's crazy, but these things improved my code quality a lot: * Use Prettier, an opinionated code formatter. It formats your code, no configuration, no fights with your colleagues. * Use eslint and SonarLint. They help you find bugs before you even commit your code. * Try to achieve a very high code coverage. Not every line needs to be covered, but I personally feel better if I've got 90+% coverage. It's not that hard once you include it in your coding-DNA. * Setup your IDE to properly debug your code. Don't do console.log(), use debugger; statements or real conditional breakpoints. Nothing sucks more than not being able to find out what your code really does. * Learn the ES6 and later features. Many developers tend to code in old ways (as they are used to), but JavaScript can do so much more these days. You'll save a lot of time and effort applying these new features. Start with Arrow Functions, followed by Rest and Spread operator, Property Shorthand and * Destructuring . Also note that there are some awesome new datastructures like Map and Set. * Learn TypeScript and keep yourself up to date. There are so many anti-patterns (never ever use any) that degregate your fancy, strictly typed highlevel code to buggy ES-code. It also helps a lot to reduce DRY and boilerplate. * Learn rxjs and use it on a daily base. Angular itself is really reactive as most Angular services return Observables that can be further processed with rxjs. Once your mind made the switch, you won't really use regular Events and/or loops anymore. But be aware of how to properly test your rxjs pipelines. * If you are integrating a remote API, I have very good experiences with OpenAPI and it's code generator for Angular. You will get ready-to-use interfaces and services just from an OpenAPI specification (which you get as a gift for many of the modern backend frameworks). Saves a lot of time and boilerplate code and removes the need to test and debug API-layer code. Your build will break as soon as the API introduces a breaking change, which is exactly what you want (it's too late if your app breaks on production)

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts