Skip to content

Add rule "Component change detection strategy should be OnPush" (GCI536) - #406

Open
hindsellouk wants to merge 5 commits into
green-code-initiative:mainfrom
hindsellouk:patch-1
Open

Add rule "Component change detection strategy should be OnPush" (GCI536)#406
hindsellouk wants to merge 5 commits into
green-code-initiative:mainfrom
hindsellouk:patch-1

Conversation

@hindsellouk

Copy link
Copy Markdown

No description provided.

@MP-Aubay

Copy link
Copy Markdown
Contributor

Hi @hindsellouk , could you :

  • Update the PR title like this "GCI120 [Team X][2025] - Angular rule"
  • Update CHANGELOG.md
  • Update RULES.md

@MP-Aubay

Copy link
Copy Markdown
Contributor

@hindsellouk I think this rule is to generic, Angular doc said that "It could be usefull" and "It may be effective on performance".

So this rule is situational and it's difficult to determine if it should be used (with static analysis)

@utarwyn utarwyn left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello! Thank you for the first Angular rule proposal 🥳

I also think we lack precise measurements of the effectiveness and relevance of using OnPush rather than the default detection system. Can you provide us with precise documentation and why not run some benchmarks ourselves?

It will also be very useful to reference them in the rule documentation. In the meantime, I propose not to merge the PR.

@github-actions

Copy link
Copy Markdown
Contributor

This PR has been automatically marked as stale because it has no activity for 60 days.
Please add a comment if you want to keep the issue open. Thank you for your contributions!

@utarwyn utarwyn changed the title Create GCI120 angular rule Add rule "Component change detection strategy should be OnPush" (GCI536) May 18, 2026
@utarwyn

utarwyn commented May 18, 2026

Copy link
Copy Markdown
Member

Just few thoughts about the rule, to be discussed further I think:

  • OnPush only works correctly when input objects are treated as immutable. Codebases that mutate objects directly (very common in Angular) will have silent view update bugs after enabling it — the rule creates a correctness risk, not just a refactoring task.
  • High noise on legacy codebases. Every @Component without OnPush raises a violation. A large existing Angular app could generate hundreds of issues, most of which require more than the claimed 5-minute fix.
  • Angular's current recommendation (v17+) is signals-based reactivity, which provides even finer-grained change detection than OnPush without requiring manual immutability discipline. The OnPush pattern is increasingly a mid-tier solution.
  • Some UI libraries interact poorly with OnPush if they manipulate the DOM imperatively outside Angular's zone.

@github-actions

Copy link
Copy Markdown
Contributor

This PR has been automatically marked as stale because it has no activity for 60 days.
Please add a comment if you want to keep the issue open. Thank you for your contributions!

@github-actions github-actions Bot added the stale label Jul 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

⁉️ help wanted Extra attention is needed stale

Projects

Development

Successfully merging this pull request may close these issues.

4 participants