Skip to content
tai-kun's Vite+ Lint Plugins
Esc
↑↓navigate↵open⌘Jpreview
On this page

explicit-member-accessibility

Require accessibility modifiers for class members except `#` private members.

  • Rule ID: tai-kun/explicit-member-accessibility
  • Auto-fix: No

Requires one of public / protected / private for class members except # private members. Applies to all fields, methods, and accessors, including constructors.

Configuration

Add the rule to lint.rules in vite.config.ts to enable it.

"tai-kun/explicit-member-accessibility": "error",

Examples

Invalid

class Service {
  value = 1;

  constructor() {}

  run() {}
}

Valid

class Service {
  public value = 1;

  #internal = 0;

  public constructor() {}

  public run() {}

  protected stop() {}

  private reset() {}
}

Notes

  • This rule reports only; it does not auto-fix.
  • # private fields and methods are ignored (they cannot have a modifier).
  • static blocks and index signatures are ignored.
  • Plain constructor parameters are ignored. Parameter properties with only readonly are reported (write public readonly instead).
  • Getters, setters, and accessor properties are checked.

Was this page helpful?