# class-reference-in-static-methods

Rule `unicorn/class-reference-in-static-methods`. Enforce consistent class references in static methods.

- Source: unicorn
- Technologies: JavaScript
- Kind: style
- Needs type information: no
- Autofix: yes, in at least one linter
- Reach: 9.9M weekly downloads of presets that enable it
- Trend: +28.3% last quarter
- Rank: #1030 by reach, #1285 by growth

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| ESLint | `unicorn/class-reference-in-static-methods` | no | suggestion | package `eslint-plugin-unicorn` | [docs](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v80.0.0/docs/rules/class-reference-in-static-methods.md) |

## Code examples

### Incorrect: the rule reports this

```js
class Foo extends Bar {
  static baz() {
    Foo.qux();
    Bar.qux();
  }
}
```

```js
class Foo extends Bar {
  static baz() {
    this.qux();
    super.qux();
  }
}
```

### Correct: the rule accepts this

```js
class Foo extends Bar {
  static baz() {
    this.qux();
    super.qux();
  }
}
```

```js
class Foo extends Bar {
  static baz() {
    Foo.qux();
    Bar.qux();
  }
}
```

Examples from the ESLint documentation.

## Enable it

### ESLint: `eslint.config.js`

```js
import unicorn from "eslint-plugin-unicorn";

export default [
  {
    plugins: { unicorn },
    rules: {
      "unicorn/class-reference-in-static-methods": "error",
    },
  },
];
```

## Presets that enable it

| Preset | Linter | Package | Rules | Weekly downloads | Trend |
| --- | --- | --- | --- | --- | --- |
| [Unicorn recommended](https://lintradar.dev/presets/unicorn-recommended.md) | ESLint | `eslint-plugin-unicorn` | 340 | 9.5M | +30.3% |
| [XO](https://lintradar.dev/presets/xo.md) | ESLint | `eslint-config-xo` | 618 | 413K | −5.0% |

## Related rules

- [unicorn/prefer-set-methods](https://lintradar.dev/rules/unicorn/prefer-set-methods.md): Prefer `Set` methods for Set operations.
- [unicorn/consistent-class-member-order](https://lintradar.dev/rules/unicorn/consistent-class-member-order.md): Enforce consistent class member order.
- [unicorn/prefer-iterator-zip](https://lintradar.dev/rules/unicorn/prefer-iterator-zip.md): Prefer `Iterator.zip()` over parallel-array indexing.
- [unicorn/consistent-conditional-object-spread](https://lintradar.dev/rules/unicorn/consistent-conditional-object-spread.md): Enforce consistent conditional object spread style.
- [unicorn/prefer-else-if](https://lintradar.dev/rules/unicorn/prefer-else-if.md): Prefer `else if` over adjacent `if` statements with related conditions.
- [unicorn/logical-assignment-operators](https://lintradar.dev/rules/unicorn/logical-assignment-operators.md): Require or disallow logical assignment operator shorthand

---

Web page: https://lintradar.dev/rules/unicorn/class-reference-in-static-methods. Data from npm and the linters' documentation, collected Dec 4, 2026. Site guide for agents: https://lintradar.dev/llms.txt
