Search code examples
javascriptparametersjslint

Best practice for unused function parameters


I have been wondering what the best method is to deal with the following.

someCallback: function(param1,param2,paramThatIActuallyNeed) {
     doSomethingWith(paramThatIActuallyNeed)
}

So in this example, param1 and param2 are unused, however I need to place them there in order to access that third parameter. This makes JSLint sad and I'm wondering what the practice is to avoid this? This tends to happen when using libraries with many callback results.


Solution

  • That is what unparam is for:

    /*jslint unparam: true */
    

    This is another good reason to prefer jshint, which does not engage in such stupidity.

    I would definitely advise against using arguments just to appease jslint.