admin管理员组文章数量:1188233
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!
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!
Share Improve this question asked Jul 16, 2020 at 15:24 quickshiftinquickshiftin 69.6k11 gold badges71 silver badges97 bronze badges 01 Answer
Reset to default 32The 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" } ] */
本文标签: javascripteslint nounusedvars varIgnorePattern not workingStack Overflow
版权声明:本文标题:javascript - eslint no-unused-vars varIgnorePattern not working - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1738344319a2077773.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论