Unused 'x' in function arguments, but 'x' is needed - JSLint error

I'm analyzing my AngularJS code with JSLint.

Many times, I have function that have multiple argumets, eg:

$rootScope.$on('$stateChangeSuccess', function (ev, toState, toParams, fromState, fromParams) {
    // code that uses toState, toParams, fromState, fromParams
    // but does touch use ev
})

and many times I need to specify all arguments, because I use last arguments.

As a result other arguments are not used, but still needed. And JSLint throws errors, eg:

Unused 'ev'.......

Is there a way to fix it?

Sure! You can use a JSLint directive:

/*jslint unparam:true, sloppy:true, white:true, devel:true */
/*global $rootScope*/
$rootScope.$on('$stateChangeSuccess', function (ev, toState, toParams, fromState, fromParams) {
    // I'm putting in this line so that JSLint doesn't complain about an empty block
    // and also so that I can mimic your described situation.
    console.log(toState, toParams, fromState, fromParams);
});

In this case, unparam:true is the one that fixes this specific issue. (devel allows console use and a few other objects. white allows any whitespace, and sloppy allows you to skip "use strict";. The last two are personal preferences.)

If you only want to turn it off for this single function (or some subset of your code), you can turn unparam off and on like this:

/*jslint sloppy:true, white:true, devel:true */
/*global $rootScope*/

/*jslint unparam:true */
$rootScope.$on('$stateChangeSuccess', function (ev, toState, toParams, fromState, fromParams) {
    console.log(toState, toParams, fromState, fromParams);
});
/*jslint unparam:false */

unparam is very useful for exactly these kinds of situations. Event handler function signatures like this one in 3rd party libraries would be very difficult to use without this option.