JamieMason / eslint-plugin-prefer-arrow-functions

Auto-fix plain Functions into Arrow Functions, in all cases where conversion would result in the same behaviour
https://www.npmjs.com/package/eslint-plugin-prefer-arrow-functions
MIT License
43 stars 11 forks source link

fix: adds support for assertion functions #25

Closed renato-bohler closed 4 months ago

renato-bohler commented 5 months ago

Description (What)

This PR adds support for assertion functions. Assertion functions are not available as arrow functions (see https://github.com/microsoft/TypeScript/issues/34523).

Fixes #22

Justification (Why)

Because we're not supposed to be converting assertion functions to arrow functions.

How Can This Be Tested?

  1. Checkout this branch
  2. Install dependencies
  3. Run yarn test
  4. The new entry in alwaysValid (function foo(val: any): asserts val is string {}) should pass on the test
JamieMason commented 5 months ago

Thanks, assertion functions did not exist when I wrote this. Will pick this up when I can 👍

renato-bohler commented 5 months ago

Hey, thanks for the quick response. Love the plugin by the way!

renato-bohler commented 5 months ago

I validated this change against a fairly big codebase, and everything worked as expected.