Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add @typescript-eslint/explicit-member-accessibility #197

Open
wants to merge 1 commit into
base: trunk
Choose a base branch
from

Conversation

chriszarate
Copy link
Member

Add @typescript-eslint/explicit-member-accessibility rule to enforce the use of accessibility keywords like public, private, or protected. These keywords are critical to preventing the unintended exposure of private implementation details.

https://typescript-eslint.io/rules/explicit-member-accessibility/

// Good
class MyClass {
  private secretKey = 'foo';

  constructor( private anotherSecretKey: string ) {}

  private updateDBRecord() {}

  public createResource() {
    // do some validation
    this.updateDBRecord();
  }
}

// Bad
class MyClass {
  secretKey = 'foo';

  constructor( anotherSecretKey: string ) {
    this.anotherSecretKey = anotherSecretKey;
  }

  updateDBRecord() {}

  createResource() {
    // do some validation
    this.updateDBRecord();
  }
}

@chriszarate chriszarate requested a review from a team March 5, 2024 19:16
Copy link
Member

@sanmai sanmai left a comment

Choose a reason for hiding this comment

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

I can't think of the downsides of this approach.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants