Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

eslint no-unused-vars varIgnorePattern not working

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!

like image 605
quickshiftin Avatar asked Jul 16 '20 15:07

quickshiftin


1 Answers

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" } ] */
like image 192
Sebastian Simon Avatar answered Nov 06 '22 20:11

Sebastian Simon