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

member-ordering

Enforce a consistent order of class members.

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

Requires class members in the order public static fields → protected static fields → private static fields → static blocks → public instance fields → protected instance fields → private instance fields → constructor → public static methods → protected static methods → private static methods → public instance methods → protected instance methods → private instance methods.

Configuration

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

"tai-kun/member-ordering": "error",

Examples

Invalid

class Service {
  constructor() {}

  value = 1;

  static create() {
    return new Service();
  }

  run() {}
}

Valid

class Service {
  static instances = 0;

  protected static cache = new Map();

  private static registry = new Set();

  value = 1;

  protected options = {};

  #internal = 0;

  constructor() {}

  static create() {
    return new Service();
  }

  protected static load() {}

  run() {}

  protected stop() {}

  #cleanup() {}
}

Notes

  • This rule reports only; it does not auto-fix.
  • Index signatures are ignored.
  • Within fields and methods, require public → protected → private. Missing modifiers are treated as public.
  • # private fields and methods are treated as private.
  • Constructors form a single group regardless of accessibility.
  • Getters and setters are treated as methods.

Was this page helpful?