You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
W-20161235: Add getter komaci rules to offline analysis tool (#326)
* feat: add getter komaci rules to offline analysis tool of mobile-web-mcp
* test: add tests for getter komaci rules for offline analysis tool of `mobile-web-mcp` server
* fix: change based on feedback
* fix: change based on feedback. Make instructions more AI friendly
* Update packages/mcp-provider-mobile-web/src/tools/offline-analysis/ruleConfig.ts
Co-authored-by: Kevin Hawkins <[email protected]>
* fix: update graph-analyzer with node 20 engine
---------
Co-authored-by: Kevin Hawkins <[email protected]>
// ********** getter related violations **********
78
+
constgetterViolation: CodeAnalysisBaseIssueType={
79
+
type: 'Violations in Getter',
80
+
description: 'A getter method does more than just returning a value',
81
+
intentAnalysis:
82
+
'The developer attempted to modify component state, prepare data for consumption, or reference functions within a getter function.',
83
+
suggestedAction: dedent`
84
+
# Compliant getter implementations
85
+
86
+
Getters that:
87
+
- Directly access and return property values
88
+
- Return a literal value
89
+
- Compute and return values derived from existing properties
90
+
91
+
# Non-compliant getter implementations
92
+
93
+
## Violation: getters that call functions
94
+
95
+
Getters that call functions cannot be primed for offline use cases.
96
+
97
+
### Remediation
98
+
99
+
Reorganize any getter implementation code that calls a function, to move such calls out of the getter. Avoid invoking any function calls within getters.
100
+
101
+
## Violation: getters with side effects
102
+
103
+
Getters that assign values to member variables or modify state create unpredictable side effects and are not suitable for offline scenarios.
104
+
105
+
### Remediation
106
+
107
+
Never assign values to member variables within a getter. LWC getters should only retrieve data without modifying any state. If you need to compute and cache a value, perform the computation and assignment in a lifecycle hook or method, then have the getter simply return the cached value.
108
+
109
+
## Violation: getters that do more than just return a value
110
+
111
+
Getters that perform complex operations beyond returning a value cannot be primed for offline use cases.
112
+
113
+
### Remediation
114
+
115
+
Review the getters and make sure that they're composed to only return a value. Move any complex logic, data processing, or multiple operations into separate methods or lifecycle hooks, and have the getter simply return the result.
0 commit comments