Back to all reviewers

Private variable naming convention

kubeflow/kubeflow
Based on 2 comments
TypeScript

Use the 'prv' prefix for private class members and ensure they're explicitly declared with the 'private' access modifier. This maintains consistency with established team conventions and improves code readability by clearly indicating variable scope.

Naming Conventions TypeScript

Reviewer Prompt

Use the ‘prv’ prefix for private class members and ensure they’re explicitly declared with the ‘private’ access modifier. This maintains consistency with established team conventions and improves code readability by clearly indicating variable scope.

export class MyComponent {
  // Correct: prefix matches access modifier
  private prvUserData: UserData;
  
  // Incorrect: prefix doesn't match access modifier
  public prvConfig: Config;
  
  // Incorrect: no prefix but is private
  private userData: UserData;
}

When refactoring existing code, update variable declarations to follow this pattern consistently. For observable patterns, public-facing properties should have clean names without implementation details while their corresponding subjects should use the ‘prv’ prefix:

export class MyService {
  // Private subjects
  private prvDataSubject = new ReplaySubject<Data>(1);
  
  // Public observable (clean naming)
  data = this.prvDataSubject.asObservable();
}
2
Comments Analyzed
TypeScript
Primary Language
Naming Conventions
Category

Source Discussions