Indeed, for readability I would have it like
$.extend({
hook: function(h) {
return (!h || h==='*') ? $('[data-hook]') : $('[data-hook~="'+h+'"]');
}
});
but the matter is subjective and I prefer it like this, I find it quicker than reading a few lines because it takes longer to physically read
also, this plugin could just be put in a js file and included in a document when you want it