Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider removing _ prefix for param names in overridable public methods #2855

Closed
mattjennings opened this issue Dec 26, 2023 · 1 comment · Fixed by #2859
Closed

Consider removing _ prefix for param names in overridable public methods #2855

mattjennings opened this issue Dec 26, 2023 · 1 comment · Fixed by #2859
Labels
bug This issue describes undesirable, incorrect, or unexpected behavior

Comments

@mattjennings
Copy link
Contributor

Context

When utilizing an IDE's autocomplete for overriding methods (Actor's onPreUpdate for example), it will autocomplete the method using param names from the definition of the super class:

CleanShot 2023-12-26 at 12 20 43@2x

Since the params are named with _ prefix in the super method, I get them in my autocomplete too. I then go and remove them manually, kind of ruining the benefits of the autocomplete.

Proposal

I presume this _ is to dodge the no-unused-vars eslint rule. Perhaps there's a better way to do this so that it doesn't affect the public API.

Suggestions:

  1. Disable the no-unused-vars rule for the line of the overridable methods
class Actor {
   onPreUpdate(engine, delta) { // eslint-disable-line no-unused-vars 
   }

    // or

   /**
    * Not sure if this affects the JS doc for the method
    **/
   // eslint-disable-next-line no-unused-vars 
   onPreUpdate(engine, delta) {}
}
  1. Customize the no-unused-vars rule to ignore based on some other pattern... perhaps hardcoding engine, delta, as those seem to be the most common... but this isn't very scalable
@eonarheim
Copy link
Member

@mattjennings I agree, this is very goofy looking. And you are 100% right, eslint is the reason. I'd be down to do disable by line on overrides for sure.

@eonarheim eonarheim added the bug This issue describes undesirable, incorrect, or unexpected behavior label Dec 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue describes undesirable, incorrect, or unexpected behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants