r/Angular2 • • Feb 25 '20

Article How to architect clean & maintainable Angular app in less than 10 minutes! ⏱️😅

https://medium.com/@tomastrajan/how-to-build-epic-angular-app-with-clean-architecture-91640ed1656
80 Upvotes

13 comments sorted by

6

u/klaxxa Feb 25 '20

Thats some very nice architecture guidelines. Thanks!

0

u/tomastrajan Feb 25 '20

Happy that you like it 😉

4

u/korbraan Feb 25 '20

Great article! I have some questions:

  • you say not to forget that a feature sub routes can be lazy loaded too if the feature gets too big. You would do so by creating a sub-feature module in the feature module?

  • If yes is it common to create a sub-shared module for a feature containing multiple sub-modules?

I ask because the global shared module can itself become a big ball of mud pretty quickly.

2

u/tomastrajan Feb 25 '20

Hi Korbraan! Yes, basically exactly how you described it, its always a tradeoff as described in article, as it grows bigger, sub shared can be an answer 😉

2

u/korbraan Feb 25 '20

Nice! Thank you for your answer 😊

3

u/valendinosaurus Feb 25 '20

hello fellow swiss Angular dev :) "in less than 10 mins" <-> "15min read"... just kidding!

two questions: why are you using tslint instead of eslint? Isn't it recommended to switch? why do you state && is not going to work on windows? I have a number of npm scripts which i concatenate with && in a further npm script, and it works well!

but anyway, great article!!!

2

u/tomastrajan Feb 25 '20

Hi! I was joking about the minutes on twitter that its with the tradeoffs and tips 😉

So Angular CLI currently comes by default with Tslint which seems good enough, they probably provide migration script with ng update in the future if they move to eslint. Anyway most of the important things are nowadays checked by TS compiler itself or automated by prettier 😉 There are still many good ones like comp / directive prefix...

As for && I have seen that a lot in enterprise on win machines in the past, maybe npm got better who knows 😬😂 Does not hurt, more like a tip if you encounter problem.

Anyway thx for the feedback, cheers ! 🔥✌️

3

u/blove_js Feb 25 '20

A quick note regarding eslint and tslint. Currently, tslint is supported by the CLI and there is no reason to switch to eslint at this time.. Also, codelyzer currently only supports tslint. You can migrate from codelyzer to the angular-eslint project: https://github.com/angular-eslint/angular-eslint

While the authors of tslint have indicated that they are moving away from the project, tslint is still the standard for Angular (up to v9) projects. Further, if you attempt to migrate from tslint to eslint, there are currently several rules that do not have an equivalent:

component-class-suffix does not yet have an ESLint equivalent.
directive-class-suffix does not yet have an ESLint equivalent.
import-blacklist does not yet have an ESLint equivalent.
no-input-rename does not yet have an ESLint equivalent.
no-output-on-prefix does not yet have an ESLint equivalent.
no-output-rename does not yet have an ESLint equivalent.
no-redundant-jsdoc does not yet have an ESLint equivalent.
use-host-property-decorator does not yet have an ESLint equivalent.
use-input-property-decorator does not yet have an ESLint equivalent.
use-life-cycle-interface does not yet have an ESLint equivalent.
use-output-property-decorator does not yet have an ESLint equivalent.
use-pipe-transform-interface does not yet have an ESLint equivalent.
whitespace does not yet have an ESLint equivalent.
This is something that the Angular team is aware of, and will continue to monitor. If and when necessary, we should see a migration in a future release, which will (hopefully) be mostly automated through the `ng update` command and schematics.

Hope that helps!

1

u/newton_half_ear Feb 25 '20

Im prety sure tslint is deprecated and eslint is the recommandation. Op I think you meant tsconfig file.

Also me and my team prefer using eslint strict rules + Beautify for the HTML.

1

u/KrisDing Feb 27 '20

I think this setup is also a good starting point for a monorepo? If no can you tell me why not, if yes could you please expand a little on that?

2

u/tomastrajan Feb 27 '20

Hi! Yeah I think this should work for monorepo too, there will be some differences though...

Some (many) core services and local (so notn3rd party comp libs) shared components will be implemented in monorepo libraries instead of in the project so that they can be shared accross multiple projects in monorepo.

Cheers.

3

u/uplink42 Feb 25 '20

This is a pretty nice guide. I would also suggest adding how to install hmr as it's also a boost in productivity from early on.

2

u/realbattousaix Feb 27 '20

Nice article, thanks for share it!