excaliburjs / Excalibur

🎮 Your friendly TypeScript 2D game engine for the web 🗡️
https://excaliburjs.com
BSD 2-Clause "Simplified" License
1.81k stars 188 forks source link

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

Closed mattjennings closed 10 months ago

mattjennings commented 10 months ago

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 commented 10 months ago

@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.