unicorn/prefer-event-target
eslint-plugin-unicorn
No autofix
eslint.config.js
import unicorn from "eslint-plugin-unicorn";
export default [
{
plugins: { unicorn },
rules: {
"unicorn/prefer-event-target": "error",
},
},
];import {EventEmitter} from 'node:events';
class Foo extends EventEmitter {}import {EventEmitter} from 'node:events';
const emitter = new EventEmitter();class Foo extends EventTarget {}const target = new EventTarget();Examples from the ESLint documentation.
unicorn/prefer-event-target
eslint-plugin-unicorn
import unicorn from "eslint-plugin-unicorn";
export default [
{
plugins: { unicorn },
rules: {
"unicorn/prefer-event-target": "error",
},
},
];unicorn/prefer-event-target
unicorn plugin · pedantic
{
"rules": {
"unicorn/prefer-event-target": "error"
}
}Biome does not have this rule.
Prefer childNode.remove() over parentNode.removeChild(childNode).
Prefer KeyboardEvent#key over deprecated keyboard event properties.
Prefer Element#append() over Node#appendChild().
Prefer using a logical operator over a ternary.
Prefer default parameters and destructuring defaults over reassignment and fallback expressions.