Rules Hub
Code Ruleset
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
Add explicit access modifiers to class members
Declare public/private/readonly explicitly and consistently on class properties and methods rather than relying on the implicit default.
Bad example
| 1 | export class TaggedUserReadDto { |
| 2 | id: number; |
| 3 | name: string; |
| 4 | } |
Explanation (EN)
Implicit visibility hides the intended class interface when the project consistently declares it.
Objašnjenje (HR)
Good example
| 1 | export class TaggedUserReadDto { |
| 2 | public id: number; |
| 3 | public name: string; |
| 4 | } |
Explanation (EN)
Objašnjenje (HR)
Notes (EN)
For class members in a codebase requiring explicit access modifiers, align visibility with actual callers and distinguish readonly from access control.
Exceptions / Tradeoffs (EN)
Do not mechanically add private or readonly when consumers write or access the member. Follow generated-code conventions separately.