gyandeeps / gruntify-eslint

Grunt plugin for Eslint
MIT License
14 stars 8 forks source link

Question about "callback" option #10

Closed pkosenko closed 9 years ago

pkosenko commented 9 years ago

This is may be a question of documentation or a problem with the code. I can't tell you which.

I notice that "gruntify-eslint" has the following three options defined in the code:

    var options = this.options({
        "silent": false,
        "format": "stylish",
        "callback": "false"
    });

I know that "format" is defined in eslint "options.js". I see that "silent" is defined as shorthand for ["--loglevel", "silent"] in grunt's "nopt.js" file.

"callback" I would presume is an option added for running eslint with grunt, but I cannot find where it is defined in the grunt or eslint code to see what it is supposed to be doing. "callback" is NOT in "options.js" or "nopt.js". So WHERE is it being defined?

Of course, if it does not in fact exist, setting it will have no effect in any case, since it will never be called.

But I see that it is actually referenced in the "gruntify-eslint" code. And this looks like it is being used by someone who knows what it is in fact doing, although since it is set to "false" it isn't engaging anything:

    if(options.callback && options.callback.constructor === Function){
        return options.callback(response);
    }

Can someone clarify this for me?

Is it something added and required by a FORMATTER? What happens when you run "response" through the callback() function? Which is NOT happening in "gruntify-eslint".

pkosenko commented 9 years ago

Maybe I am being DENSE and that the "callback" option is supposed to be defined in the gruntfile.js file itself, in case you want to do something to the response. And here it is just defined, but it can be overridden.

gyandeeps commented 9 years ago

Exactly. This function is not provided by eslint. This is a function which can be defined inside your gruntfile and that way you can handle the results of eslint in your custom way. Thats why description says that this option is not passed to eslint.

If you dont pass in any function then I simply set the key to false. My fault as I accidentally put quotes around false.

pkosenko commented 9 years ago

Thanks . . . that sheds light on the matter. It is something you want to mention in your documentation, then.

gyandeeps commented 9 years ago

Feel free to send a PR for improvements. thanks

gyandeeps commented 9 years ago

Closing because of no response. @pkosenko Feel free to send a PR.