mitt icon indicating copy to clipboard operation
mitt copied to clipboard

Add `this: void` to all methods

Open FloEdelmann opened this issue 1 year ago • 0 comments

What is the purpose of this pull request? (put an "X" next to an item)

  • [ ] Documentation update
  • [ ] Bug fix
  • [ ] Feature
  • [ ] Code style update (formatting)
  • [x] Refactoring (no functional changes)
  • [ ] CI related changes
  • [ ] Other, please explain:

What changes did you make? (Give an overview)

When destructuring an instantiated emitter, the typescript-eslint rule unbound-method reports these cases:

const { emit, on, off } = mitt()
//      ^^^^  ^^  ^^^
// Avoid referencing unbound methods which may cause unintentional scoping of `this`.
// If your function does not access `this`, you can annotate it with `this: void`, or consider using an arrow function instead.

Since this is not accessed inside mitt, this PR adds the this: void annotation to the emit, on and off methods.

Is there anything you'd like reviewers to focus on?

No.

Does this PR introduce a breaking change? (What changes might other developers need to make in their application due to this PR?)

No.

FloEdelmann avatar Aug 14 '24 08:08 FloEdelmann