Skip to content

ntnyq/no-member-accessibility

  • 🔧 The --fix option on the command line can automatically fix some of the problems reported by this rule.

disallow usage of typescript member accessibility.

📖 Rule Details

This rule reports usage of TypeScript member accessibility.

Good

ts
class Test {
  x: number

  constructor(x: number) {
    this.x = x
  }

  get internalValue() {
    return this.x
  }

  set internalValue(value: number) {
    this.x = value
  }

  square(): number {
    return this.x * this.x
  }

  half(): number {
    return this.x / 2
  }
}

Bad

ts
class Test {
  private x: number

  public constructor(x: number) {
    this.x = x
  }

  protected get internalValue() {
    return this.x
  }

  protected set internalValue(value: number) {
    this.x = value
  }

  public square(): number {
    return this.x * this.x
  }

  private half(): number {
    return this.x / 2
  }
}

🔧 Options

Nothing.

🚀 Version

This rule was introduced in eslint-plugin-ntnyq v0.0.1

🔍 Implementation