---
title: member-ordering
description: 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 [#configuration]

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

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

## Examples [#examples]

### Invalid [#invalid]

```ts
class Service {
  constructor() {}

  value = 1;

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

  run() {}
}
```

### Valid [#valid]

```ts
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 [#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.

## Related rules [#related-rules]

- [`blank-line`](/vp-lint-plugins/en/rules/blank-line)
