# prefer-event-target

Rule `unicorn/prefer-event-target`. Prefer `EventTarget` over `EventEmitter`.

- Source: unicorn
- Technologies: JavaScript
- Kind: suspicious
- Needs type information: no
- Autofix: no
- Reach: 12M weekly downloads of presets that enable it
- Trend: +40.1% last quarter
- Rank: #798 by reach, #994 by growth

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| ESLint | `unicorn/prefer-event-target` | no | no | package `eslint-plugin-unicorn` | [docs](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v80.0.0/docs/rules/prefer-event-target.md) |
| Oxlint | `unicorn/prefer-event-target` | no | no | plugin `unicorn`, category pedantic | [docs](https://oxc.rs/docs/guide/usage/linter/rules/unicorn/prefer-event-target.html) |

## Code examples

### Incorrect: the rule reports this

```js
import {EventEmitter} from 'node:events';

class Foo extends EventEmitter {}
```

```js
import {EventEmitter} from 'node:events';

const emitter = new EventEmitter();
```

### Correct: the rule accepts this

```js
class Foo extends EventTarget {}
```

```js
const target = new EventTarget();
```

Examples from the ESLint documentation.

## Enable it

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

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

export default [
  {
    plugins: { unicorn },
    rules: {
      "unicorn/prefer-event-target": "error",
    },
  },
];
```

### Oxlint: `.oxlintrc.json`

```json
{
  "rules": {
    "unicorn/prefer-event-target": "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% |
| [Unicorn unopinionated](https://lintradar.dev/presets/unicorn-unopinionated.md) | ESLint | `eslint-plugin-unicorn` | 236 | 9.5M | +30.3% |
| [Ultracite for Oxlint](https://lintradar.dev/presets/ultracite-oxlint.md) | Oxlint | `ultracite` | 475 | 2.1M | +151.7% |
| [XO](https://lintradar.dev/presets/xo.md) | ESLint | `eslint-config-xo` | 618 | 413K | −5.0% |

## Related rules

- [unicorn/prefer-dom-node-remove](https://lintradar.dev/rules/unicorn/prefer-dom-node-remove.md): Prefer `childNode.remove()` over `parentNode.removeChild(childNode)`.
- [unicorn/prefer-keyboard-event-key](https://lintradar.dev/rules/unicorn/prefer-keyboard-event-key.md): Prefer `KeyboardEvent#key` over deprecated keyboard event properties.
- [unicorn/prefer-dom-node-append](https://lintradar.dev/rules/unicorn/prefer-dom-node-append.md): Prefer `Element#append()` over `Node#appendChild()`.
- [unicorn/prefer-logical-operator-over-ternary](https://lintradar.dev/rules/unicorn/prefer-logical-operator-over-ternary.md): Prefer using a logical operator over a ternary.
- [unicorn/prefer-default-parameters](https://lintradar.dev/rules/unicorn/prefer-default-parameters.md): Prefer default parameters and destructuring defaults over reassignment and fallback expressions.
- [unicorn/prefer-modern-dom-apis](https://lintradar.dev/rules/unicorn/prefer-modern-dom-apis.md): Prefer modern DOM APIs.

---

Web page: https://lintradar.dev/rules/unicorn/prefer-event-target. Data from npm and the linters' documentation, collected Dec 4, 2026. Site guide for agents: https://lintradar.dev/llms.txt
