why do i get this eslint warning?

Putting a method on a prototype is usually a good design decision if the method has something to do with the instance it’s attached to. If you never reference this, the instance, inside the method, then it’s a bit odd to have such a method on the prototype, since it doesn’t directly relate to the instance. That’s what the linter is warning you about.

Either ignore the linting rule, or consider making it a static method instead:

static getProviders(authUser) {

and

const providers = ProfilePageBase.getProviders(authUser);

You could also make it a standalone function instead.

Also, better than switch, consider something like:

static getProviders(authUser) {
  if (authUser === 'google.com') return authUser.providerData[0].email;
  if (authUser === 'facebook' || authUser === 'twitter') return authUser.providerData[0].providerId;
  return 'non';
}

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top