I am using slick.js jquery plugin inside requireJS. Thus in order to make the plugin available I have to require
it, which is introducing an
'slick' is defined but never used no-unused-vars
error from eslint. Here is the code
define(['jquery', 'slick'], function($, slick) {
'use strict';
$.widget("mage.promobanner", {
_addSlider: function(self) {
setTimeout(function(){
$(self.element).slick(self.options);
}, 2000);
}
});
return $.mage.promobanner;
});
I have tried creating an exception for this variable per the varsIgnorePattern
documentation
/*eslint no-unused-vars: ["error", { "varsIgnorePattern": "slick" }]*/
however the error persists. Is there something wrong with the ignore pattern I have created? Seems like a no-brainer regex: exact match!
The correct exception uses argsIgnorePattern
, not varsIgnorePattern
.
varsIgnorePattern
The
varsIgnorePattern
option specifies exceptions not to check for usage: variables whose names match a regexp pattern.
argsIgnorePattern
The
argsIgnorePattern
option specifies exceptions not to check for usage: arguments whose names match a regexp pattern.
So use:
/* eslint no-unused-vars: [ "error", { "argsIgnorePattern": "slick" } ] */
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With