r/Angular2•
tonjohn

Angular Universal SSR ESLint rules?

Help Request

Along the lines of Angular ESLint, are there any packages that provide ESLint rules around writing SSR friendly code?

I'm currently adding Angular Universal support to a major Angular project and would like to ensure the team is writing SSR friendly code through tooling.

Example rules based on Angular Universal's gotchas:

  • no usage of window
  • use ViewportScroller instead of window.scrollTo
  • no usage of isPlatform*, use DI instead

Posted May 3, 2023, 4:48 PM UTC

11
tsenguunee1•

No usage of window is misleading. You just have to make sure it's being used on the client by wrapping it with an is platform if statement.

Same goes for local storage.

1