Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Warn for components not using onPush

Oliver Günther030aefb03098
diff --git a/Dangerfile b/Dangerfile
index 58647c8b6cc..ac48bd20bc3 100644
--- a/Dangerfile
+++ b/Dangerfile
@@ -1,3 +1,22 @@
# Fail if jasmine specs contain fdescribe or fit
fail("jasmine fdescribe left in tests") if `grep --include '*.spec.ts' -rP 'fdescribe|fit' frontend/src/`.length > 1
+# Search for modified components not being made OnPush
+git.modified_files
+ .select { |path| path.include?('frontend') && path.end_with?('.ts') }
+ .each do |path|
+ lines = File.readlines(path)
+
+ # Ignore non component files
+ component_line = lines.grep(/@Component/)[0]
+ next unless component_line
+
+ # Check for missing onPush
+ unless lines.grep(/changeDetection:\s+ChangeDetectionStrategy.OnPush/).length > 0
+ warn(
+ "Please use `ChangeDetectionStrategy.OnPush` for this component",
+ file: path,
+ line: lines.index(component_line) || 0
+ )
+ end
+end