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

#29 Don't flag constructors when this is not present #36

Open mitchell-merry opened 1 month ago

mitchell-merry commented 1 month ago

Description (What)

Fixes #29.

Constructors like this:

class Obj {
  constructor(private readonly foo: number) {}
};

don't have this, so they get incorrectly flagged by the plugin. We should be sure to exclude all constructors from this rule.

Justification (Why)

Because constructors cannot be arrow functions.

How Can This Be Tested?

See tests, you can revert the fix to demonstrate that this change works.

mitchell-merry commented 1 month ago

Looks like the node version needs to be bumped? https://github.com/JamieMason/eslint-plugin-prefer-arrow-functions/blob/main/.nvmrc I thought this was fixed... 😄