public/assets/js/core/selectize/selectize.js

Summary

Maintainability
F
2 wks
Test Coverage

File selectize.js has 2379 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/**
 * sifter.js
 * Copyright (c) 2013 Brian Reavis & contributors
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
Severity: Major
Found in public/assets/js/core/selectize/selectize.js - About 6 days to fix

    Method 'setup' has too many statements (79). Maximum allowed is 30.
    Open

            setup: function() {

    enforce a maximum number of statements allowed in function blocks (max-statements)

    The max-statements rule allows you to specify the maximum number of statements allowed in a function.

    function foo() {
      var bar = 1; // one statement
      var baz = 2; // two statements
      var qux = 3; // three statements
    }

    Rule Details

    This rule enforces a maximum number of statements allowed in function blocks.

    Options

    This rule has a number or object option:

    • "max" (default 10) enforces a maximum number of statements allows in function blocks

    Deprecated: The object property maximum is deprecated; please use the object property max instead.

    This rule has an object option:

    • "ignoreTopLevelFunctions": true ignores top-level functions

    max

    Examples of incorrect code for this rule with the default { "max": 10 } option:

    /*eslint max-statements: ["error", 10]*/
    /*eslint-env es6*/
    
    function foo() {
      var foo1 = 1;
      var foo2 = 2;
      var foo3 = 3;
      var foo4 = 4;
      var foo5 = 5;
      var foo6 = 6;
      var foo7 = 7;
      var foo8 = 8;
      var foo9 = 9;
      var foo10 = 10;
    
      var foo11 = 11; // Too many.
    }
    
    let foo = () => {
      var foo1 = 1;
      var foo2 = 2;
      var foo3 = 3;
      var foo4 = 4;
      var foo5 = 5;
      var foo6 = 6;
      var foo7 = 7;
      var foo8 = 8;
      var foo9 = 9;
      var foo10 = 10;
    
      var foo11 = 11; // Too many.
    };

    Examples of correct code for this rule with the default { "max": 10 } option:

    /*eslint max-statements: ["error", 10]*/
    /*eslint-env es6*/
    
    function foo() {
      var foo1 = 1;
      var foo2 = 2;
      var foo3 = 3;
      var foo4 = 4;
      var foo5 = 5;
      var foo6 = 6;
      var foo7 = 7;
      var foo8 = 8;
      var foo9 = 9;
      var foo10 = 10;
      return function () {
    
        // The number of statements in the inner function does not count toward the
        // statement maximum.
    
        return 42;
      };
    }
    
    let foo = () => {
      var foo1 = 1;
      var foo2 = 2;
      var foo3 = 3;
      var foo4 = 4;
      var foo5 = 5;
      var foo6 = 6;
      var foo7 = 7;
      var foo8 = 8;
      var foo9 = 9;
      var foo10 = 10;
      return function () {
    
        // The number of statements in the inner function does not count toward the
        // statement maximum.
    
        return 42;
      };
    }

    ignoreTopLevelFunctions

    Examples of additional correct code for this rule with the { "max": 10 }, { "ignoreTopLevelFunctions": true } options:

    /*eslint max-statements: ["error", 10, { "ignoreTopLevelFunctions": true }]*/
    
    function foo() {
      var foo1 = 1;
      var foo2 = 2;
      var foo3 = 3;
      var foo4 = 4;
      var foo5 = 5;
      var foo6 = 6;
      var foo7 = 7;
      var foo8 = 8;
      var foo9 = 9;
      var foo10 = 10;
      var foo11 = 11;
    }

    Related Rules

    • [complexity](complexity.md)
    • [max-depth](max-depth.md)
    • [max-len](max-len.md)
    • [max-nested-callbacks](max-nested-callbacks.md)
    • [max-params](max-params.md) Source: http://eslint.org/docs/rules/

    Method 'refreshOptions' has too many statements (66). Maximum allowed is 30.
    Open

            refreshOptions: function(triggerDropdown) {

    enforce a maximum number of statements allowed in function blocks (max-statements)

    The max-statements rule allows you to specify the maximum number of statements allowed in a function.

    function foo() {
      var bar = 1; // one statement
      var baz = 2; // two statements
      var qux = 3; // three statements
    }

    Rule Details

    This rule enforces a maximum number of statements allowed in function blocks.

    Options

    This rule has a number or object option:

    • "max" (default 10) enforces a maximum number of statements allows in function blocks

    Deprecated: The object property maximum is deprecated; please use the object property max instead.

    This rule has an object option:

    • "ignoreTopLevelFunctions": true ignores top-level functions

    max

    Examples of incorrect code for this rule with the default { "max": 10 } option:

    /*eslint max-statements: ["error", 10]*/
    /*eslint-env es6*/
    
    function foo() {
      var foo1 = 1;
      var foo2 = 2;
      var foo3 = 3;
      var foo4 = 4;
      var foo5 = 5;
      var foo6 = 6;
      var foo7 = 7;
      var foo8 = 8;
      var foo9 = 9;
      var foo10 = 10;
    
      var foo11 = 11; // Too many.
    }
    
    let foo = () => {
      var foo1 = 1;
      var foo2 = 2;
      var foo3 = 3;
      var foo4 = 4;
      var foo5 = 5;
      var foo6 = 6;
      var foo7 = 7;
      var foo8 = 8;
      var foo9 = 9;
      var foo10 = 10;
    
      var foo11 = 11; // Too many.
    };

    Examples of correct code for this rule with the default { "max": 10 } option:

    /*eslint max-statements: ["error", 10]*/
    /*eslint-env es6*/
    
    function foo() {
      var foo1 = 1;
      var foo2 = 2;
      var foo3 = 3;
      var foo4 = 4;
      var foo5 = 5;
      var foo6 = 6;
      var foo7 = 7;
      var foo8 = 8;
      var foo9 = 9;
      var foo10 = 10;
      return function () {
    
        // The number of statements in the inner function does not count toward the
        // statement maximum.
    
        return 42;
      };
    }
    
    let foo = () => {
      var foo1 = 1;
      var foo2 = 2;
      var foo3 = 3;
      var foo4 = 4;
      var foo5 = 5;
      var foo6 = 6;
      var foo7 = 7;
      var foo8 = 8;
      var foo9 = 9;
      var foo10 = 10;
      return function () {
    
        // The number of statements in the inner function does not count toward the
        // statement maximum.
    
        return 42;
      };
    }

    ignoreTopLevelFunctions

    Examples of additional correct code for this rule with the { "max": 10 }, { "ignoreTopLevelFunctions": true } options:

    /*eslint max-statements: ["error", 10, { "ignoreTopLevelFunctions": true }]*/
    
    function foo() {
      var foo1 = 1;
      var foo2 = 2;
      var foo3 = 3;
      var foo4 = 4;
      var foo5 = 5;
      var foo6 = 6;
      var foo7 = 7;
      var foo8 = 8;
      var foo9 = 9;
      var foo10 = 10;
      var foo11 = 11;
    }

    Related Rules

    • [complexity](complexity.md)
    • [max-depth](max-depth.md)
    • [max-len](max-len.md)
    • [max-nested-callbacks](max-nested-callbacks.md)
    • [max-params](max-params.md) Source: http://eslint.org/docs/rules/

    Function setup has 134 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            setup: function() {
                var self      = this;
                var settings  = self.settings;
                var eventNS   = self.eventNS;
                var $window   = $(window);
    Severity: Major
    Found in public/assets/js/core/selectize/selectize.js - About 5 hrs to fix

      Method 'onKeyDown' has a complexity of 33.
      Open

              onKeyDown: function(e) {

      Limit Cyclomatic Complexity (complexity)

      Cyclomatic complexity measures the number of linearly independent paths through a program's source code. This rule allows setting a cyclomatic complexity threshold.

      function a(x) {
          if (true) {
              return x; // 1st path
          } else if (false) {
              return x+1; // 2nd path
          } else {
              return 4; // 3rd path
          }
      }

      Rule Details

      This rule is aimed at reducing code complexity by capping the amount of cyclomatic complexity allowed in a program. As such, it will warn when the cyclomatic complexity crosses the configured threshold (default is 20).

      Examples of incorrect code for a maximum of 2:

      /*eslint complexity: ["error", 2]*/
      
      function a(x) {
          if (true) {
              return x;
          } else if (false) {
              return x+1;
          } else {
              return 4; // 3rd path
          }
      }

      Examples of correct code for a maximum of 2:

      /*eslint complexity: ["error", 2]*/
      
      function a(x) {
          if (true) {
              return x;
          } else {
              return 4;
          }
      }

      Options

      Optionally, you may specify a max object property:

      "complexity": ["error", 2]

      is equivalent to

      "complexity": ["error", { "max": 2 }]

      Deprecated: the object property maximum is deprecated. Please use the property max instead.

      When Not To Use It

      If you can't determine an appropriate complexity limit for your code, then it's best to disable this rule.

      Further Reading

      Related Rules

      • [max-depth](max-depth.md)
      • [max-len](max-len.md)
      • [max-nested-callbacks](max-nested-callbacks.md)
      • [max-params](max-params.md)
      • [max-statements](max-statements.md) Source: http://eslint.org/docs/rules/

      Function selectize has 115 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          $.fn.selectize = function(settings_user) {
              var defaults             = $.fn.selectize.defaults;
              var settings             = $.extend({}, defaults, settings_user);
              var attr_data            = settings.dataAttr;
              var field_label          = settings.labelField;
      Severity: Major
      Found in public/assets/js/core/selectize/selectize.js - About 4 hrs to fix

        Function has too many statements (55). Maximum allowed is 30.
        Open

        }(this, function($, Sifter, MicroPlugin) {

        enforce a maximum number of statements allowed in function blocks (max-statements)

        The max-statements rule allows you to specify the maximum number of statements allowed in a function.

        function foo() {
          var bar = 1; // one statement
          var baz = 2; // two statements
          var qux = 3; // three statements
        }

        Rule Details

        This rule enforces a maximum number of statements allowed in function blocks.

        Options

        This rule has a number or object option:

        • "max" (default 10) enforces a maximum number of statements allows in function blocks

        Deprecated: The object property maximum is deprecated; please use the object property max instead.

        This rule has an object option:

        • "ignoreTopLevelFunctions": true ignores top-level functions

        max

        Examples of incorrect code for this rule with the default { "max": 10 } option:

        /*eslint max-statements: ["error", 10]*/
        /*eslint-env es6*/
        
        function foo() {
          var foo1 = 1;
          var foo2 = 2;
          var foo3 = 3;
          var foo4 = 4;
          var foo5 = 5;
          var foo6 = 6;
          var foo7 = 7;
          var foo8 = 8;
          var foo9 = 9;
          var foo10 = 10;
        
          var foo11 = 11; // Too many.
        }
        
        let foo = () => {
          var foo1 = 1;
          var foo2 = 2;
          var foo3 = 3;
          var foo4 = 4;
          var foo5 = 5;
          var foo6 = 6;
          var foo7 = 7;
          var foo8 = 8;
          var foo9 = 9;
          var foo10 = 10;
        
          var foo11 = 11; // Too many.
        };

        Examples of correct code for this rule with the default { "max": 10 } option:

        /*eslint max-statements: ["error", 10]*/
        /*eslint-env es6*/
        
        function foo() {
          var foo1 = 1;
          var foo2 = 2;
          var foo3 = 3;
          var foo4 = 4;
          var foo5 = 5;
          var foo6 = 6;
          var foo7 = 7;
          var foo8 = 8;
          var foo9 = 9;
          var foo10 = 10;
          return function () {
        
            // The number of statements in the inner function does not count toward the
            // statement maximum.
        
            return 42;
          };
        }
        
        let foo = () => {
          var foo1 = 1;
          var foo2 = 2;
          var foo3 = 3;
          var foo4 = 4;
          var foo5 = 5;
          var foo6 = 6;
          var foo7 = 7;
          var foo8 = 8;
          var foo9 = 9;
          var foo10 = 10;
          return function () {
        
            // The number of statements in the inner function does not count toward the
            // statement maximum.
        
            return 42;
          };
        }

        ignoreTopLevelFunctions

        Examples of additional correct code for this rule with the { "max": 10 }, { "ignoreTopLevelFunctions": true } options:

        /*eslint max-statements: ["error", 10, { "ignoreTopLevelFunctions": true }]*/
        
        function foo() {
          var foo1 = 1;
          var foo2 = 2;
          var foo3 = 3;
          var foo4 = 4;
          var foo5 = 5;
          var foo6 = 6;
          var foo7 = 7;
          var foo8 = 8;
          var foo9 = 9;
          var foo10 = 10;
          var foo11 = 11;
        }

        Related Rules

        • [complexity](complexity.md)
        • [max-depth](max-depth.md)
        • [max-len](max-len.md)
        • [max-nested-callbacks](max-nested-callbacks.md)
        • [max-params](max-params.md) Source: http://eslint.org/docs/rules/

        Method 'refreshOptions' has a complexity of 28.
        Open

                refreshOptions: function(triggerDropdown) {

        Limit Cyclomatic Complexity (complexity)

        Cyclomatic complexity measures the number of linearly independent paths through a program's source code. This rule allows setting a cyclomatic complexity threshold.

        function a(x) {
            if (true) {
                return x; // 1st path
            } else if (false) {
                return x+1; // 2nd path
            } else {
                return 4; // 3rd path
            }
        }

        Rule Details

        This rule is aimed at reducing code complexity by capping the amount of cyclomatic complexity allowed in a program. As such, it will warn when the cyclomatic complexity crosses the configured threshold (default is 20).

        Examples of incorrect code for a maximum of 2:

        /*eslint complexity: ["error", 2]*/
        
        function a(x) {
            if (true) {
                return x;
            } else if (false) {
                return x+1;
            } else {
                return 4; // 3rd path
            }
        }

        Examples of correct code for a maximum of 2:

        /*eslint complexity: ["error", 2]*/
        
        function a(x) {
            if (true) {
                return x;
            } else {
                return 4;
            }
        }

        Options

        Optionally, you may specify a max object property:

        "complexity": ["error", 2]

        is equivalent to

        "complexity": ["error", { "max": 2 }]

        Deprecated: the object property maximum is deprecated. Please use the property max instead.

        When Not To Use It

        If you can't determine an appropriate complexity limit for your code, then it's best to disable this rule.

        Further Reading

        Related Rules

        • [max-depth](max-depth.md)
        • [max-len](max-len.md)
        • [max-nested-callbacks](max-nested-callbacks.md)
        • [max-params](max-params.md)
        • [max-statements](max-statements.md) Source: http://eslint.org/docs/rules/

        Function refreshOptions has 94 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                refreshOptions: function(triggerDropdown) {
                    var i, j, k, n, groups, groups_order, option, option_html, optgroup, optgroups, html, html_children, has_create_option;
                    var $active, $active_before, $create;
            
                    if (typeof triggerDropdown === 'undefined') {
        Severity: Major
        Found in public/assets/js/core/selectize/selectize.js - About 3 hrs to fix

          Function has a complexity of 20.
          Open

                  var update = function(e, options) {

          Limit Cyclomatic Complexity (complexity)

          Cyclomatic complexity measures the number of linearly independent paths through a program's source code. This rule allows setting a cyclomatic complexity threshold.

          function a(x) {
              if (true) {
                  return x; // 1st path
              } else if (false) {
                  return x+1; // 2nd path
              } else {
                  return 4; // 3rd path
              }
          }

          Rule Details

          This rule is aimed at reducing code complexity by capping the amount of cyclomatic complexity allowed in a program. As such, it will warn when the cyclomatic complexity crosses the configured threshold (default is 20).

          Examples of incorrect code for a maximum of 2:

          /*eslint complexity: ["error", 2]*/
          
          function a(x) {
              if (true) {
                  return x;
              } else if (false) {
                  return x+1;
              } else {
                  return 4; // 3rd path
              }
          }

          Examples of correct code for a maximum of 2:

          /*eslint complexity: ["error", 2]*/
          
          function a(x) {
              if (true) {
                  return x;
              } else {
                  return 4;
              }
          }

          Options

          Optionally, you may specify a max object property:

          "complexity": ["error", 2]

          is equivalent to

          "complexity": ["error", { "max": 2 }]

          Deprecated: the object property maximum is deprecated. Please use the property max instead.

          When Not To Use It

          If you can't determine an appropriate complexity limit for your code, then it's best to disable this rule.

          Further Reading

          Related Rules

          • [max-depth](max-depth.md)
          • [max-len](max-len.md)
          • [max-nested-callbacks](max-nested-callbacks.md)
          • [max-params](max-params.md)
          • [max-statements](max-statements.md) Source: http://eslint.org/docs/rules/

          Method 'deleteSelection' has a complexity of 18.
          Open

                  deleteSelection: function(e) {

          Limit Cyclomatic Complexity (complexity)

          Cyclomatic complexity measures the number of linearly independent paths through a program's source code. This rule allows setting a cyclomatic complexity threshold.

          function a(x) {
              if (true) {
                  return x; // 1st path
              } else if (false) {
                  return x+1; // 2nd path
              } else {
                  return 4; // 3rd path
              }
          }

          Rule Details

          This rule is aimed at reducing code complexity by capping the amount of cyclomatic complexity allowed in a program. As such, it will warn when the cyclomatic complexity crosses the configured threshold (default is 20).

          Examples of incorrect code for a maximum of 2:

          /*eslint complexity: ["error", 2]*/
          
          function a(x) {
              if (true) {
                  return x;
              } else if (false) {
                  return x+1;
              } else {
                  return 4; // 3rd path
              }
          }

          Examples of correct code for a maximum of 2:

          /*eslint complexity: ["error", 2]*/
          
          function a(x) {
              if (true) {
                  return x;
              } else {
                  return 4;
              }
          }

          Options

          Optionally, you may specify a max object property:

          "complexity": ["error", 2]

          is equivalent to

          "complexity": ["error", { "max": 2 }]

          Deprecated: the object property maximum is deprecated. Please use the property max instead.

          When Not To Use It

          If you can't determine an appropriate complexity limit for your code, then it's best to disable this rule.

          Further Reading

          Related Rules

          • [max-depth](max-depth.md)
          • [max-len](max-len.md)
          • [max-nested-callbacks](max-nested-callbacks.md)
          • [max-params](max-params.md)
          • [max-statements](max-statements.md) Source: http://eslint.org/docs/rules/

          Function onKeyDown has 76 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                  onKeyDown: function(e) {
                      var isInput = e.target === this.$control_input[0];
                      var self = this;
              
                      if (self.isLocked) {
          Severity: Major
          Found in public/assets/js/core/selectize/selectize.js - About 3 hrs to fix

            Function has a complexity of 16.
            Open

                Sifter.prototype.getSortFunction = function(search, options) {

            Limit Cyclomatic Complexity (complexity)

            Cyclomatic complexity measures the number of linearly independent paths through a program's source code. This rule allows setting a cyclomatic complexity threshold.

            function a(x) {
                if (true) {
                    return x; // 1st path
                } else if (false) {
                    return x+1; // 2nd path
                } else {
                    return 4; // 3rd path
                }
            }

            Rule Details

            This rule is aimed at reducing code complexity by capping the amount of cyclomatic complexity allowed in a program. As such, it will warn when the cyclomatic complexity crosses the configured threshold (default is 20).

            Examples of incorrect code for a maximum of 2:

            /*eslint complexity: ["error", 2]*/
            
            function a(x) {
                if (true) {
                    return x;
                } else if (false) {
                    return x+1;
                } else {
                    return 4; // 3rd path
                }
            }

            Examples of correct code for a maximum of 2:

            /*eslint complexity: ["error", 2]*/
            
            function a(x) {
                if (true) {
                    return x;
                } else {
                    return 4;
                }
            }

            Options

            Optionally, you may specify a max object property:

            "complexity": ["error", 2]

            is equivalent to

            "complexity": ["error", { "max": 2 }]

            Deprecated: the object property maximum is deprecated. Please use the property max instead.

            When Not To Use It

            If you can't determine an appropriate complexity limit for your code, then it's best to disable this rule.

            Further Reading

            Related Rules

            • [max-depth](max-depth.md)
            • [max-len](max-len.md)
            • [max-nested-callbacks](max-nested-callbacks.md)
            • [max-params](max-params.md)
            • [max-statements](max-statements.md) Source: http://eslint.org/docs/rules/

            Method 'setup' has a complexity of 16.
            Open

                    setup: function() {

            Limit Cyclomatic Complexity (complexity)

            Cyclomatic complexity measures the number of linearly independent paths through a program's source code. This rule allows setting a cyclomatic complexity threshold.

            function a(x) {
                if (true) {
                    return x; // 1st path
                } else if (false) {
                    return x+1; // 2nd path
                } else {
                    return 4; // 3rd path
                }
            }

            Rule Details

            This rule is aimed at reducing code complexity by capping the amount of cyclomatic complexity allowed in a program. As such, it will warn when the cyclomatic complexity crosses the configured threshold (default is 20).

            Examples of incorrect code for a maximum of 2:

            /*eslint complexity: ["error", 2]*/
            
            function a(x) {
                if (true) {
                    return x;
                } else if (false) {
                    return x+1;
                } else {
                    return 4; // 3rd path
                }
            }

            Examples of correct code for a maximum of 2:

            /*eslint complexity: ["error", 2]*/
            
            function a(x) {
                if (true) {
                    return x;
                } else {
                    return 4;
                }
            }

            Options

            Optionally, you may specify a max object property:

            "complexity": ["error", 2]

            is equivalent to

            "complexity": ["error", { "max": 2 }]

            Deprecated: the object property maximum is deprecated. Please use the property max instead.

            When Not To Use It

            If you can't determine an appropriate complexity limit for your code, then it's best to disable this rule.

            Further Reading

            Related Rules

            • [max-depth](max-depth.md)
            • [max-len](max-len.md)
            • [max-nested-callbacks](max-nested-callbacks.md)
            • [max-params](max-params.md)
            • [max-statements](max-statements.md) Source: http://eslint.org/docs/rules/

            Function Selectize has 65 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                var Selectize = function($input, settings) {
                    var key, i, n, dir, input, self = this;
                    input = $input[0];
                    input.selectize = self;
                
            Severity: Major
            Found in public/assets/js/core/selectize/selectize.js - About 2 hrs to fix

              Function getSortFunction has 65 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  Sifter.prototype.getSortFunction = function(search, options) {
                      var i, n, self, field, fields, fields_count, multiplier, multipliers, get_field, implicit_score, sort;
              
                      self   = this;
                      search = self.prepareSearch(search, options);
              Severity: Major
              Found in public/assets/js/core/selectize/selectize.js - About 2 hrs to fix

                Method 'render' has a complexity of 14.
                Open

                        render: function(templateName, data) {

                Limit Cyclomatic Complexity (complexity)

                Cyclomatic complexity measures the number of linearly independent paths through a program's source code. This rule allows setting a cyclomatic complexity threshold.

                function a(x) {
                    if (true) {
                        return x; // 1st path
                    } else if (false) {
                        return x+1; // 2nd path
                    } else {
                        return 4; // 3rd path
                    }
                }

                Rule Details

                This rule is aimed at reducing code complexity by capping the amount of cyclomatic complexity allowed in a program. As such, it will warn when the cyclomatic complexity crosses the configured threshold (default is 20).

                Examples of incorrect code for a maximum of 2:

                /*eslint complexity: ["error", 2]*/
                
                function a(x) {
                    if (true) {
                        return x;
                    } else if (false) {
                        return x+1;
                    } else {
                        return 4; // 3rd path
                    }
                }

                Examples of correct code for a maximum of 2:

                /*eslint complexity: ["error", 2]*/
                
                function a(x) {
                    if (true) {
                        return x;
                    } else {
                        return 4;
                    }
                }

                Options

                Optionally, you may specify a max object property:

                "complexity": ["error", 2]

                is equivalent to

                "complexity": ["error", { "max": 2 }]

                Deprecated: the object property maximum is deprecated. Please use the property max instead.

                When Not To Use It

                If you can't determine an appropriate complexity limit for your code, then it's best to disable this rule.

                Further Reading

                Related Rules

                • [max-depth](max-depth.md)
                • [max-len](max-len.md)
                • [max-nested-callbacks](max-nested-callbacks.md)
                • [max-params](max-params.md)
                • [max-statements](max-statements.md) Source: http://eslint.org/docs/rules/

                Function has a complexity of 14.
                Open

                    var Selectize = function($input, settings) {

                Limit Cyclomatic Complexity (complexity)

                Cyclomatic complexity measures the number of linearly independent paths through a program's source code. This rule allows setting a cyclomatic complexity threshold.

                function a(x) {
                    if (true) {
                        return x; // 1st path
                    } else if (false) {
                        return x+1; // 2nd path
                    } else {
                        return 4; // 3rd path
                    }
                }

                Rule Details

                This rule is aimed at reducing code complexity by capping the amount of cyclomatic complexity allowed in a program. As such, it will warn when the cyclomatic complexity crosses the configured threshold (default is 20).

                Examples of incorrect code for a maximum of 2:

                /*eslint complexity: ["error", 2]*/
                
                function a(x) {
                    if (true) {
                        return x;
                    } else if (false) {
                        return x+1;
                    } else {
                        return 4; // 3rd path
                    }
                }

                Examples of correct code for a maximum of 2:

                /*eslint complexity: ["error", 2]*/
                
                function a(x) {
                    if (true) {
                        return x;
                    } else {
                        return 4;
                    }
                }

                Options

                Optionally, you may specify a max object property:

                "complexity": ["error", 2]

                is equivalent to

                "complexity": ["error", { "max": 2 }]

                Deprecated: the object property maximum is deprecated. Please use the property max instead.

                When Not To Use It

                If you can't determine an appropriate complexity limit for your code, then it's best to disable this rule.

                Further Reading

                Related Rules

                • [max-depth](max-depth.md)
                • [max-len](max-len.md)
                • [max-nested-callbacks](max-nested-callbacks.md)
                • [max-params](max-params.md)
                • [max-statements](max-statements.md) Source: http://eslint.org/docs/rules/

                Function has a complexity of 13.
                Open

                            debounce_events(this, events, function() {

                Limit Cyclomatic Complexity (complexity)

                Cyclomatic complexity measures the number of linearly independent paths through a program's source code. This rule allows setting a cyclomatic complexity threshold.

                function a(x) {
                    if (true) {
                        return x; // 1st path
                    } else if (false) {
                        return x+1; // 2nd path
                    } else {
                        return 4; // 3rd path
                    }
                }

                Rule Details

                This rule is aimed at reducing code complexity by capping the amount of cyclomatic complexity allowed in a program. As such, it will warn when the cyclomatic complexity crosses the configured threshold (default is 20).

                Examples of incorrect code for a maximum of 2:

                /*eslint complexity: ["error", 2]*/
                
                function a(x) {
                    if (true) {
                        return x;
                    } else if (false) {
                        return x+1;
                    } else {
                        return 4; // 3rd path
                    }
                }

                Examples of correct code for a maximum of 2:

                /*eslint complexity: ["error", 2]*/
                
                function a(x) {
                    if (true) {
                        return x;
                    } else {
                        return 4;
                    }
                }

                Options

                Optionally, you may specify a max object property:

                "complexity": ["error", 2]

                is equivalent to

                "complexity": ["error", { "max": 2 }]

                Deprecated: the object property maximum is deprecated. Please use the property max instead.

                When Not To Use It

                If you can't determine an appropriate complexity limit for your code, then it's best to disable this rule.

                Further Reading

                Related Rules

                • [max-depth](max-depth.md)
                • [max-len](max-len.md)
                • [max-nested-callbacks](max-nested-callbacks.md)
                • [max-params](max-params.md)
                • [max-statements](max-statements.md) Source: http://eslint.org/docs/rules/

                Method 'setActiveItem' has too many statements (37). Maximum allowed is 30.
                Open

                        setActiveItem: function($item, e) {

                enforce a maximum number of statements allowed in function blocks (max-statements)

                The max-statements rule allows you to specify the maximum number of statements allowed in a function.

                function foo() {
                  var bar = 1; // one statement
                  var baz = 2; // two statements
                  var qux = 3; // three statements
                }

                Rule Details

                This rule enforces a maximum number of statements allowed in function blocks.

                Options

                This rule has a number or object option:

                • "max" (default 10) enforces a maximum number of statements allows in function blocks

                Deprecated: The object property maximum is deprecated; please use the object property max instead.

                This rule has an object option:

                • "ignoreTopLevelFunctions": true ignores top-level functions

                max

                Examples of incorrect code for this rule with the default { "max": 10 } option:

                /*eslint max-statements: ["error", 10]*/
                /*eslint-env es6*/
                
                function foo() {
                  var foo1 = 1;
                  var foo2 = 2;
                  var foo3 = 3;
                  var foo4 = 4;
                  var foo5 = 5;
                  var foo6 = 6;
                  var foo7 = 7;
                  var foo8 = 8;
                  var foo9 = 9;
                  var foo10 = 10;
                
                  var foo11 = 11; // Too many.
                }
                
                let foo = () => {
                  var foo1 = 1;
                  var foo2 = 2;
                  var foo3 = 3;
                  var foo4 = 4;
                  var foo5 = 5;
                  var foo6 = 6;
                  var foo7 = 7;
                  var foo8 = 8;
                  var foo9 = 9;
                  var foo10 = 10;
                
                  var foo11 = 11; // Too many.
                };

                Examples of correct code for this rule with the default { "max": 10 } option:

                /*eslint max-statements: ["error", 10]*/
                /*eslint-env es6*/
                
                function foo() {
                  var foo1 = 1;
                  var foo2 = 2;
                  var foo3 = 3;
                  var foo4 = 4;
                  var foo5 = 5;
                  var foo6 = 6;
                  var foo7 = 7;
                  var foo8 = 8;
                  var foo9 = 9;
                  var foo10 = 10;
                  return function () {
                
                    // The number of statements in the inner function does not count toward the
                    // statement maximum.
                
                    return 42;
                  };
                }
                
                let foo = () => {
                  var foo1 = 1;
                  var foo2 = 2;
                  var foo3 = 3;
                  var foo4 = 4;
                  var foo5 = 5;
                  var foo6 = 6;
                  var foo7 = 7;
                  var foo8 = 8;
                  var foo9 = 9;
                  var foo10 = 10;
                  return function () {
                
                    // The number of statements in the inner function does not count toward the
                    // statement maximum.
                
                    return 42;
                  };
                }

                ignoreTopLevelFunctions

                Examples of additional correct code for this rule with the { "max": 10 }, { "ignoreTopLevelFunctions": true } options:

                /*eslint max-statements: ["error", 10, { "ignoreTopLevelFunctions": true }]*/
                
                function foo() {
                  var foo1 = 1;
                  var foo2 = 2;
                  var foo3 = 3;
                  var foo4 = 4;
                  var foo5 = 5;
                  var foo6 = 6;
                  var foo7 = 7;
                  var foo8 = 8;
                  var foo9 = 9;
                  var foo10 = 10;
                  var foo11 = 11;
                }

                Related Rules

                • [complexity](complexity.md)
                • [max-depth](max-depth.md)
                • [max-len](max-len.md)
                • [max-nested-callbacks](max-nested-callbacks.md)
                • [max-params](max-params.md) Source: http://eslint.org/docs/rules/

                Function init_select has 62 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                        var init_select = function($input, settings_element) {
                            var i, n, tagName, $children, order = 0;
                            var options = settings_element.options;
                            var optionsMap = {};
                    
                Severity: Major
                Found in public/assets/js/core/selectize/selectize.js - About 2 hrs to fix

                  Function mixin has 60 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      MicroPlugin.mixin = function(Interface) {
                          Interface.plugins = {};
                  
                          /**
                           * Initializes the listed plugins (with options).
                  Severity: Major
                  Found in public/assets/js/core/selectize/selectize.js - About 2 hrs to fix

                    Method 'updateOption' has a complexity of 12.
                    Open

                            updateOption: function(value, data) {

                    Limit Cyclomatic Complexity (complexity)

                    Cyclomatic complexity measures the number of linearly independent paths through a program's source code. This rule allows setting a cyclomatic complexity threshold.

                    function a(x) {
                        if (true) {
                            return x; // 1st path
                        } else if (false) {
                            return x+1; // 2nd path
                        } else {
                            return 4; // 3rd path
                        }
                    }

                    Rule Details

                    This rule is aimed at reducing code complexity by capping the amount of cyclomatic complexity allowed in a program. As such, it will warn when the cyclomatic complexity crosses the configured threshold (default is 20).

                    Examples of incorrect code for a maximum of 2:

                    /*eslint complexity: ["error", 2]*/
                    
                    function a(x) {
                        if (true) {
                            return x;
                        } else if (false) {
                            return x+1;
                        } else {
                            return 4; // 3rd path
                        }
                    }

                    Examples of correct code for a maximum of 2:

                    /*eslint complexity: ["error", 2]*/
                    
                    function a(x) {
                        if (true) {
                            return x;
                        } else {
                            return 4;
                        }
                    }

                    Options

                    Optionally, you may specify a max object property:

                    "complexity": ["error", 2]

                    is equivalent to

                    "complexity": ["error", { "max": 2 }]

                    Deprecated: the object property maximum is deprecated. Please use the property max instead.

                    When Not To Use It

                    If you can't determine an appropriate complexity limit for your code, then it's best to disable this rule.

                    Further Reading

                    Related Rules

                    • [max-depth](max-depth.md)
                    • [max-len](max-len.md)
                    • [max-nested-callbacks](max-nested-callbacks.md)
                    • [max-params](max-params.md)
                    • [max-statements](max-statements.md) Source: http://eslint.org/docs/rules/

                    Method 'setActiveItem' has a complexity of 12.
                    Open

                            setActiveItem: function($item, e) {

                    Limit Cyclomatic Complexity (complexity)

                    Cyclomatic complexity measures the number of linearly independent paths through a program's source code. This rule allows setting a cyclomatic complexity threshold.

                    function a(x) {
                        if (true) {
                            return x; // 1st path
                        } else if (false) {
                            return x+1; // 2nd path
                        } else {
                            return 4; // 3rd path
                        }
                    }

                    Rule Details

                    This rule is aimed at reducing code complexity by capping the amount of cyclomatic complexity allowed in a program. As such, it will warn when the cyclomatic complexity crosses the configured threshold (default is 20).

                    Examples of incorrect code for a maximum of 2:

                    /*eslint complexity: ["error", 2]*/
                    
                    function a(x) {
                        if (true) {
                            return x;
                        } else if (false) {
                            return x+1;
                        } else {
                            return 4; // 3rd path
                        }
                    }

                    Examples of correct code for a maximum of 2:

                    /*eslint complexity: ["error", 2]*/
                    
                    function a(x) {
                        if (true) {
                            return x;
                        } else {
                            return 4;
                        }
                    }

                    Options

                    Optionally, you may specify a max object property:

                    "complexity": ["error", 2]

                    is equivalent to

                    "complexity": ["error", { "max": 2 }]

                    Deprecated: the object property maximum is deprecated. Please use the property max instead.

                    When Not To Use It

                    If you can't determine an appropriate complexity limit for your code, then it's best to disable this rule.

                    Further Reading

                    Related Rules

                    • [max-depth](max-depth.md)
                    • [max-len](max-len.md)
                    • [max-nested-callbacks](max-nested-callbacks.md)
                    • [max-params](max-params.md)
                    • [max-statements](max-statements.md) Source: http://eslint.org/docs/rules/

                    Function getScoreFunction has 59 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        Sifter.prototype.getScoreFunction = function(search, options) {
                            var self, fields, tokens, token_count;
                    
                            self        = this;
                            search      = self.prepareSearch(search, options);
                    Severity: Major
                    Found in public/assets/js/core/selectize/selectize.js - About 2 hrs to fix

                      Function has a complexity of 11.
                      Open

                                  var addOption = function($option, group) {

                      Limit Cyclomatic Complexity (complexity)

                      Cyclomatic complexity measures the number of linearly independent paths through a program's source code. This rule allows setting a cyclomatic complexity threshold.

                      function a(x) {
                          if (true) {
                              return x; // 1st path
                          } else if (false) {
                              return x+1; // 2nd path
                          } else {
                              return 4; // 3rd path
                          }
                      }

                      Rule Details

                      This rule is aimed at reducing code complexity by capping the amount of cyclomatic complexity allowed in a program. As such, it will warn when the cyclomatic complexity crosses the configured threshold (default is 20).

                      Examples of incorrect code for a maximum of 2:

                      /*eslint complexity: ["error", 2]*/
                      
                      function a(x) {
                          if (true) {
                              return x;
                          } else if (false) {
                              return x+1;
                          } else {
                              return 4; // 3rd path
                          }
                      }

                      Examples of correct code for a maximum of 2:

                      /*eslint complexity: ["error", 2]*/
                      
                      function a(x) {
                          if (true) {
                              return x;
                          } else {
                              return 4;
                          }
                      }

                      Options

                      Optionally, you may specify a max object property:

                      "complexity": ["error", 2]

                      is equivalent to

                      "complexity": ["error", { "max": 2 }]

                      Deprecated: the object property maximum is deprecated. Please use the property max instead.

                      When Not To Use It

                      If you can't determine an appropriate complexity limit for your code, then it's best to disable this rule.

                      Further Reading

                      Related Rules

                      • [max-depth](max-depth.md)
                      • [max-len](max-len.md)
                      • [max-nested-callbacks](max-nested-callbacks.md)
                      • [max-params](max-params.md)
                      • [max-statements](max-statements.md) Source: http://eslint.org/docs/rules/

                      Method 'deleteSelection' has too many statements (34). Maximum allowed is 30.
                      Open

                              deleteSelection: function(e) {

                      enforce a maximum number of statements allowed in function blocks (max-statements)

                      The max-statements rule allows you to specify the maximum number of statements allowed in a function.

                      function foo() {
                        var bar = 1; // one statement
                        var baz = 2; // two statements
                        var qux = 3; // three statements
                      }

                      Rule Details

                      This rule enforces a maximum number of statements allowed in function blocks.

                      Options

                      This rule has a number or object option:

                      • "max" (default 10) enforces a maximum number of statements allows in function blocks

                      Deprecated: The object property maximum is deprecated; please use the object property max instead.

                      This rule has an object option:

                      • "ignoreTopLevelFunctions": true ignores top-level functions

                      max

                      Examples of incorrect code for this rule with the default { "max": 10 } option:

                      /*eslint max-statements: ["error", 10]*/
                      /*eslint-env es6*/
                      
                      function foo() {
                        var foo1 = 1;
                        var foo2 = 2;
                        var foo3 = 3;
                        var foo4 = 4;
                        var foo5 = 5;
                        var foo6 = 6;
                        var foo7 = 7;
                        var foo8 = 8;
                        var foo9 = 9;
                        var foo10 = 10;
                      
                        var foo11 = 11; // Too many.
                      }
                      
                      let foo = () => {
                        var foo1 = 1;
                        var foo2 = 2;
                        var foo3 = 3;
                        var foo4 = 4;
                        var foo5 = 5;
                        var foo6 = 6;
                        var foo7 = 7;
                        var foo8 = 8;
                        var foo9 = 9;
                        var foo10 = 10;
                      
                        var foo11 = 11; // Too many.
                      };

                      Examples of correct code for this rule with the default { "max": 10 } option:

                      /*eslint max-statements: ["error", 10]*/
                      /*eslint-env es6*/
                      
                      function foo() {
                        var foo1 = 1;
                        var foo2 = 2;
                        var foo3 = 3;
                        var foo4 = 4;
                        var foo5 = 5;
                        var foo6 = 6;
                        var foo7 = 7;
                        var foo8 = 8;
                        var foo9 = 9;
                        var foo10 = 10;
                        return function () {
                      
                          // The number of statements in the inner function does not count toward the
                          // statement maximum.
                      
                          return 42;
                        };
                      }
                      
                      let foo = () => {
                        var foo1 = 1;
                        var foo2 = 2;
                        var foo3 = 3;
                        var foo4 = 4;
                        var foo5 = 5;
                        var foo6 = 6;
                        var foo7 = 7;
                        var foo8 = 8;
                        var foo9 = 9;
                        var foo10 = 10;
                        return function () {
                      
                          // The number of statements in the inner function does not count toward the
                          // statement maximum.
                      
                          return 42;
                        };
                      }

                      ignoreTopLevelFunctions

                      Examples of additional correct code for this rule with the { "max": 10 }, { "ignoreTopLevelFunctions": true } options:

                      /*eslint max-statements: ["error", 10, { "ignoreTopLevelFunctions": true }]*/
                      
                      function foo() {
                        var foo1 = 1;
                        var foo2 = 2;
                        var foo3 = 3;
                        var foo4 = 4;
                        var foo5 = 5;
                        var foo6 = 6;
                        var foo7 = 7;
                        var foo8 = 8;
                        var foo9 = 9;
                        var foo10 = 10;
                        var foo11 = 11;
                      }

                      Related Rules

                      • [complexity](complexity.md)
                      • [max-depth](max-depth.md)
                      • [max-len](max-len.md)
                      • [max-nested-callbacks](max-nested-callbacks.md)
                      • [max-params](max-params.md) Source: http://eslint.org/docs/rules/

                      Method 'setActiveOption' has a complexity of 10.
                      Open

                              setActiveOption: function($option, scroll, animate) {

                      Limit Cyclomatic Complexity (complexity)

                      Cyclomatic complexity measures the number of linearly independent paths through a program's source code. This rule allows setting a cyclomatic complexity threshold.

                      function a(x) {
                          if (true) {
                              return x; // 1st path
                          } else if (false) {
                              return x+1; // 2nd path
                          } else {
                              return 4; // 3rd path
                          }
                      }

                      Rule Details

                      This rule is aimed at reducing code complexity by capping the amount of cyclomatic complexity allowed in a program. As such, it will warn when the cyclomatic complexity crosses the configured threshold (default is 20).

                      Examples of incorrect code for a maximum of 2:

                      /*eslint complexity: ["error", 2]*/
                      
                      function a(x) {
                          if (true) {
                              return x;
                          } else if (false) {
                              return x+1;
                          } else {
                              return 4; // 3rd path
                          }
                      }

                      Examples of correct code for a maximum of 2:

                      /*eslint complexity: ["error", 2]*/
                      
                      function a(x) {
                          if (true) {
                              return x;
                          } else {
                              return 4;
                          }
                      }

                      Options

                      Optionally, you may specify a max object property:

                      "complexity": ["error", 2]

                      is equivalent to

                      "complexity": ["error", { "max": 2 }]

                      Deprecated: the object property maximum is deprecated. Please use the property max instead.

                      When Not To Use It

                      If you can't determine an appropriate complexity limit for your code, then it's best to disable this rule.

                      Further Reading

                      Related Rules

                      • [max-depth](max-depth.md)
                      • [max-len](max-len.md)
                      • [max-nested-callbacks](max-nested-callbacks.md)
                      • [max-params](max-params.md)
                      • [max-statements](max-statements.md) Source: http://eslint.org/docs/rules/

                      Method 'advanceSelection' has a complexity of 9.
                      Open

                              advanceSelection: function(direction, e) {

                      Limit Cyclomatic Complexity (complexity)

                      Cyclomatic complexity measures the number of linearly independent paths through a program's source code. This rule allows setting a cyclomatic complexity threshold.

                      function a(x) {
                          if (true) {
                              return x; // 1st path
                          } else if (false) {
                              return x+1; // 2nd path
                          } else {
                              return 4; // 3rd path
                          }
                      }

                      Rule Details

                      This rule is aimed at reducing code complexity by capping the amount of cyclomatic complexity allowed in a program. As such, it will warn when the cyclomatic complexity crosses the configured threshold (default is 20).

                      Examples of incorrect code for a maximum of 2:

                      /*eslint complexity: ["error", 2]*/
                      
                      function a(x) {
                          if (true) {
                              return x;
                          } else if (false) {
                              return x+1;
                          } else {
                              return 4; // 3rd path
                          }
                      }

                      Examples of correct code for a maximum of 2:

                      /*eslint complexity: ["error", 2]*/
                      
                      function a(x) {
                          if (true) {
                              return x;
                          } else {
                              return 4;
                          }
                      }

                      Options

                      Optionally, you may specify a max object property:

                      "complexity": ["error", 2]

                      is equivalent to

                      "complexity": ["error", { "max": 2 }]

                      Deprecated: the object property maximum is deprecated. Please use the property max instead.

                      When Not To Use It

                      If you can't determine an appropriate complexity limit for your code, then it's best to disable this rule.

                      Further Reading

                      Related Rules

                      • [max-depth](max-depth.md)
                      • [max-len](max-len.md)
                      • [max-nested-callbacks](max-nested-callbacks.md)
                      • [max-params](max-params.md)
                      • [max-statements](max-statements.md) Source: http://eslint.org/docs/rules/

                      Function setActiveItem has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                              setActiveItem: function($item, e) {
                                  var self = this;
                                  var eventName;
                                  var i, idx, begin, end, item, swap;
                                  var $last;
                      Severity: Minor
                      Found in public/assets/js/core/selectize/selectize.js - About 1 hr to fix

                        Function has too many statements (32). Maximum allowed is 30.
                        Open

                            Sifter.prototype.getSortFunction = function(search, options) {

                        enforce a maximum number of statements allowed in function blocks (max-statements)

                        The max-statements rule allows you to specify the maximum number of statements allowed in a function.

                        function foo() {
                          var bar = 1; // one statement
                          var baz = 2; // two statements
                          var qux = 3; // three statements
                        }

                        Rule Details

                        This rule enforces a maximum number of statements allowed in function blocks.

                        Options

                        This rule has a number or object option:

                        • "max" (default 10) enforces a maximum number of statements allows in function blocks

                        Deprecated: The object property maximum is deprecated; please use the object property max instead.

                        This rule has an object option:

                        • "ignoreTopLevelFunctions": true ignores top-level functions

                        max

                        Examples of incorrect code for this rule with the default { "max": 10 } option:

                        /*eslint max-statements: ["error", 10]*/
                        /*eslint-env es6*/
                        
                        function foo() {
                          var foo1 = 1;
                          var foo2 = 2;
                          var foo3 = 3;
                          var foo4 = 4;
                          var foo5 = 5;
                          var foo6 = 6;
                          var foo7 = 7;
                          var foo8 = 8;
                          var foo9 = 9;
                          var foo10 = 10;
                        
                          var foo11 = 11; // Too many.
                        }
                        
                        let foo = () => {
                          var foo1 = 1;
                          var foo2 = 2;
                          var foo3 = 3;
                          var foo4 = 4;
                          var foo5 = 5;
                          var foo6 = 6;
                          var foo7 = 7;
                          var foo8 = 8;
                          var foo9 = 9;
                          var foo10 = 10;
                        
                          var foo11 = 11; // Too many.
                        };

                        Examples of correct code for this rule with the default { "max": 10 } option:

                        /*eslint max-statements: ["error", 10]*/
                        /*eslint-env es6*/
                        
                        function foo() {
                          var foo1 = 1;
                          var foo2 = 2;
                          var foo3 = 3;
                          var foo4 = 4;
                          var foo5 = 5;
                          var foo6 = 6;
                          var foo7 = 7;
                          var foo8 = 8;
                          var foo9 = 9;
                          var foo10 = 10;
                          return function () {
                        
                            // The number of statements in the inner function does not count toward the
                            // statement maximum.
                        
                            return 42;
                          };
                        }
                        
                        let foo = () => {
                          var foo1 = 1;
                          var foo2 = 2;
                          var foo3 = 3;
                          var foo4 = 4;
                          var foo5 = 5;
                          var foo6 = 6;
                          var foo7 = 7;
                          var foo8 = 8;
                          var foo9 = 9;
                          var foo10 = 10;
                          return function () {
                        
                            // The number of statements in the inner function does not count toward the
                            // statement maximum.
                        
                            return 42;
                          };
                        }

                        ignoreTopLevelFunctions

                        Examples of additional correct code for this rule with the { "max": 10 }, { "ignoreTopLevelFunctions": true } options:

                        /*eslint max-statements: ["error", 10, { "ignoreTopLevelFunctions": true }]*/
                        
                        function foo() {
                          var foo1 = 1;
                          var foo2 = 2;
                          var foo3 = 3;
                          var foo4 = 4;
                          var foo5 = 5;
                          var foo6 = 6;
                          var foo7 = 7;
                          var foo8 = 8;
                          var foo9 = 9;
                          var foo10 = 10;
                          var foo11 = 11;
                        }

                        Related Rules

                        • [complexity](complexity.md)
                        • [max-depth](max-depth.md)
                        • [max-len](max-len.md)
                        • [max-nested-callbacks](max-nested-callbacks.md)
                        • [max-params](max-params.md) Source: http://eslint.org/docs/rules/

                        Method 'updateOriginalInput' has a complexity of 8.
                        Open

                                updateOriginalInput: function(opts) {

                        Limit Cyclomatic Complexity (complexity)

                        Cyclomatic complexity measures the number of linearly independent paths through a program's source code. This rule allows setting a cyclomatic complexity threshold.

                        function a(x) {
                            if (true) {
                                return x; // 1st path
                            } else if (false) {
                                return x+1; // 2nd path
                            } else {
                                return 4; // 3rd path
                            }
                        }

                        Rule Details

                        This rule is aimed at reducing code complexity by capping the amount of cyclomatic complexity allowed in a program. As such, it will warn when the cyclomatic complexity crosses the configured threshold (default is 20).

                        Examples of incorrect code for a maximum of 2:

                        /*eslint complexity: ["error", 2]*/
                        
                        function a(x) {
                            if (true) {
                                return x;
                            } else if (false) {
                                return x+1;
                            } else {
                                return 4; // 3rd path
                            }
                        }

                        Examples of correct code for a maximum of 2:

                        /*eslint complexity: ["error", 2]*/
                        
                        function a(x) {
                            if (true) {
                                return x;
                            } else {
                                return 4;
                            }
                        }

                        Options

                        Optionally, you may specify a max object property:

                        "complexity": ["error", 2]

                        is equivalent to

                        "complexity": ["error", { "max": 2 }]

                        Deprecated: the object property maximum is deprecated. Please use the property max instead.

                        When Not To Use It

                        If you can't determine an appropriate complexity limit for your code, then it's best to disable this rule.

                        Further Reading

                        Related Rules

                        • [max-depth](max-depth.md)
                        • [max-len](max-len.md)
                        • [max-nested-callbacks](max-nested-callbacks.md)
                        • [max-params](max-params.md)
                        • [max-statements](max-statements.md) Source: http://eslint.org/docs/rules/

                        Function has a complexity of 8.
                        Open

                            var cmp = function(a, b) {

                        Limit Cyclomatic Complexity (complexity)

                        Cyclomatic complexity measures the number of linearly independent paths through a program's source code. This rule allows setting a cyclomatic complexity threshold.

                        function a(x) {
                            if (true) {
                                return x; // 1st path
                            } else if (false) {
                                return x+1; // 2nd path
                            } else {
                                return 4; // 3rd path
                            }
                        }

                        Rule Details

                        This rule is aimed at reducing code complexity by capping the amount of cyclomatic complexity allowed in a program. As such, it will warn when the cyclomatic complexity crosses the configured threshold (default is 20).

                        Examples of incorrect code for a maximum of 2:

                        /*eslint complexity: ["error", 2]*/
                        
                        function a(x) {
                            if (true) {
                                return x;
                            } else if (false) {
                                return x+1;
                            } else {
                                return 4; // 3rd path
                            }
                        }

                        Examples of correct code for a maximum of 2:

                        /*eslint complexity: ["error", 2]*/
                        
                        function a(x) {
                            if (true) {
                                return x;
                            } else {
                                return 4;
                            }
                        }

                        Options

                        Optionally, you may specify a max object property:

                        "complexity": ["error", 2]

                        is equivalent to

                        "complexity": ["error", { "max": 2 }]

                        Deprecated: the object property maximum is deprecated. Please use the property max instead.

                        When Not To Use It

                        If you can't determine an appropriate complexity limit for your code, then it's best to disable this rule.

                        Further Reading

                        Related Rules

                        • [max-depth](max-depth.md)
                        • [max-len](max-len.md)
                        • [max-nested-callbacks](max-nested-callbacks.md)
                        • [max-params](max-params.md)
                        • [max-statements](max-statements.md) Source: http://eslint.org/docs/rules/

                        Function has a complexity of 8.
                        Open

                            Sifter.prototype.tokenize = function(query) {

                        Limit Cyclomatic Complexity (complexity)

                        Cyclomatic complexity measures the number of linearly independent paths through a program's source code. This rule allows setting a cyclomatic complexity threshold.

                        function a(x) {
                            if (true) {
                                return x; // 1st path
                            } else if (false) {
                                return x+1; // 2nd path
                            } else {
                                return 4; // 3rd path
                            }
                        }

                        Rule Details

                        This rule is aimed at reducing code complexity by capping the amount of cyclomatic complexity allowed in a program. As such, it will warn when the cyclomatic complexity crosses the configured threshold (default is 20).

                        Examples of incorrect code for a maximum of 2:

                        /*eslint complexity: ["error", 2]*/
                        
                        function a(x) {
                            if (true) {
                                return x;
                            } else if (false) {
                                return x+1;
                            } else {
                                return 4; // 3rd path
                            }
                        }

                        Examples of correct code for a maximum of 2:

                        /*eslint complexity: ["error", 2]*/
                        
                        function a(x) {
                            if (true) {
                                return x;
                            } else {
                                return 4;
                            }
                        }

                        Options

                        Optionally, you may specify a max object property:

                        "complexity": ["error", 2]

                        is equivalent to

                        "complexity": ["error", { "max": 2 }]

                        Deprecated: the object property maximum is deprecated. Please use the property max instead.

                        When Not To Use It

                        If you can't determine an appropriate complexity limit for your code, then it's best to disable this rule.

                        Further Reading

                        Related Rules

                        • [max-depth](max-depth.md)
                        • [max-len](max-len.md)
                        • [max-nested-callbacks](max-nested-callbacks.md)
                        • [max-params](max-params.md)
                        • [max-statements](max-statements.md) Source: http://eslint.org/docs/rules/

                        Function has a complexity of 8.
                        Open

                                Interface.prototype.initializePlugins = function(plugins) {

                        Limit Cyclomatic Complexity (complexity)

                        Cyclomatic complexity measures the number of linearly independent paths through a program's source code. This rule allows setting a cyclomatic complexity threshold.

                        function a(x) {
                            if (true) {
                                return x; // 1st path
                            } else if (false) {
                                return x+1; // 2nd path
                            } else {
                                return 4; // 3rd path
                            }
                        }

                        Rule Details

                        This rule is aimed at reducing code complexity by capping the amount of cyclomatic complexity allowed in a program. As such, it will warn when the cyclomatic complexity crosses the configured threshold (default is 20).

                        Examples of incorrect code for a maximum of 2:

                        /*eslint complexity: ["error", 2]*/
                        
                        function a(x) {
                            if (true) {
                                return x;
                            } else if (false) {
                                return x+1;
                            } else {
                                return 4; // 3rd path
                            }
                        }

                        Examples of correct code for a maximum of 2:

                        /*eslint complexity: ["error", 2]*/
                        
                        function a(x) {
                            if (true) {
                                return x;
                            } else {
                                return 4;
                            }
                        }

                        Options

                        Optionally, you may specify a max object property:

                        "complexity": ["error", 2]

                        is equivalent to

                        "complexity": ["error", { "max": 2 }]

                        Deprecated: the object property maximum is deprecated. Please use the property max instead.

                        When Not To Use It

                        If you can't determine an appropriate complexity limit for your code, then it's best to disable this rule.

                        Further Reading

                        Related Rules

                        • [max-depth](max-depth.md)
                        • [max-len](max-len.md)
                        • [max-nested-callbacks](max-nested-callbacks.md)
                        • [max-params](max-params.md)
                        • [max-statements](max-statements.md) Source: http://eslint.org/docs/rules/

                        Method 'updateOption' has too many statements (32). Maximum allowed is 30.
                        Open

                                updateOption: function(value, data) {

                        enforce a maximum number of statements allowed in function blocks (max-statements)

                        The max-statements rule allows you to specify the maximum number of statements allowed in a function.

                        function foo() {
                          var bar = 1; // one statement
                          var baz = 2; // two statements
                          var qux = 3; // three statements
                        }

                        Rule Details

                        This rule enforces a maximum number of statements allowed in function blocks.

                        Options

                        This rule has a number or object option:

                        • "max" (default 10) enforces a maximum number of statements allows in function blocks

                        Deprecated: The object property maximum is deprecated; please use the object property max instead.

                        This rule has an object option:

                        • "ignoreTopLevelFunctions": true ignores top-level functions

                        max

                        Examples of incorrect code for this rule with the default { "max": 10 } option:

                        /*eslint max-statements: ["error", 10]*/
                        /*eslint-env es6*/
                        
                        function foo() {
                          var foo1 = 1;
                          var foo2 = 2;
                          var foo3 = 3;
                          var foo4 = 4;
                          var foo5 = 5;
                          var foo6 = 6;
                          var foo7 = 7;
                          var foo8 = 8;
                          var foo9 = 9;
                          var foo10 = 10;
                        
                          var foo11 = 11; // Too many.
                        }
                        
                        let foo = () => {
                          var foo1 = 1;
                          var foo2 = 2;
                          var foo3 = 3;
                          var foo4 = 4;
                          var foo5 = 5;
                          var foo6 = 6;
                          var foo7 = 7;
                          var foo8 = 8;
                          var foo9 = 9;
                          var foo10 = 10;
                        
                          var foo11 = 11; // Too many.
                        };

                        Examples of correct code for this rule with the default { "max": 10 } option:

                        /*eslint max-statements: ["error", 10]*/
                        /*eslint-env es6*/
                        
                        function foo() {
                          var foo1 = 1;
                          var foo2 = 2;
                          var foo3 = 3;
                          var foo4 = 4;
                          var foo5 = 5;
                          var foo6 = 6;
                          var foo7 = 7;
                          var foo8 = 8;
                          var foo9 = 9;
                          var foo10 = 10;
                          return function () {
                        
                            // The number of statements in the inner function does not count toward the
                            // statement maximum.
                        
                            return 42;
                          };
                        }
                        
                        let foo = () => {
                          var foo1 = 1;
                          var foo2 = 2;
                          var foo3 = 3;
                          var foo4 = 4;
                          var foo5 = 5;
                          var foo6 = 6;
                          var foo7 = 7;
                          var foo8 = 8;
                          var foo9 = 9;
                          var foo10 = 10;
                          return function () {
                        
                            // The number of statements in the inner function does not count toward the
                            // statement maximum.
                        
                            return 42;
                          };
                        }

                        ignoreTopLevelFunctions

                        Examples of additional correct code for this rule with the { "max": 10 }, { "ignoreTopLevelFunctions": true } options:

                        /*eslint max-statements: ["error", 10, { "ignoreTopLevelFunctions": true }]*/
                        
                        function foo() {
                          var foo1 = 1;
                          var foo2 = 2;
                          var foo3 = 3;
                          var foo4 = 4;
                          var foo5 = 5;
                          var foo6 = 6;
                          var foo7 = 7;
                          var foo8 = 8;
                          var foo9 = 9;
                          var foo10 = 10;
                          var foo11 = 11;
                        }

                        Related Rules

                        • [complexity](complexity.md)
                        • [max-depth](max-depth.md)
                        • [max-len](max-len.md)
                        • [max-nested-callbacks](max-nested-callbacks.md)
                        • [max-params](max-params.md) Source: http://eslint.org/docs/rules/

                        Method 'createItem' has a complexity of 8.
                        Open

                                createItem: function(input, triggerDropdown) {

                        Limit Cyclomatic Complexity (complexity)

                        Cyclomatic complexity measures the number of linearly independent paths through a program's source code. This rule allows setting a cyclomatic complexity threshold.

                        function a(x) {
                            if (true) {
                                return x; // 1st path
                            } else if (false) {
                                return x+1; // 2nd path
                            } else {
                                return 4; // 3rd path
                            }
                        }

                        Rule Details

                        This rule is aimed at reducing code complexity by capping the amount of cyclomatic complexity allowed in a program. As such, it will warn when the cyclomatic complexity crosses the configured threshold (default is 20).

                        Examples of incorrect code for a maximum of 2:

                        /*eslint complexity: ["error", 2]*/
                        
                        function a(x) {
                            if (true) {
                                return x;
                            } else if (false) {
                                return x+1;
                            } else {
                                return 4; // 3rd path
                            }
                        }

                        Examples of correct code for a maximum of 2:

                        /*eslint complexity: ["error", 2]*/
                        
                        function a(x) {
                            if (true) {
                                return x;
                            } else {
                                return 4;
                            }
                        }

                        Options

                        Optionally, you may specify a max object property:

                        "complexity": ["error", 2]

                        is equivalent to

                        "complexity": ["error", { "max": 2 }]

                        Deprecated: the object property maximum is deprecated. Please use the property max instead.

                        When Not To Use It

                        If you can't determine an appropriate complexity limit for your code, then it's best to disable this rule.

                        Further Reading

                        Related Rules

                        • [max-depth](max-depth.md)
                        • [max-len](max-len.md)
                        • [max-nested-callbacks](max-nested-callbacks.md)
                        • [max-params](max-params.md)
                        • [max-statements](max-statements.md) Source: http://eslint.org/docs/rules/

                        Function autoGrow has 47 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            var autoGrow = function($input) {
                                var currentWidth = null;
                            
                                var update = function(e, options) {
                                    var value, keyCode, printable, placeholder, width;
                        Severity: Minor
                        Found in public/assets/js/core/selectize/selectize.js - About 1 hr to fix

                          Function deleteSelection has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                                  deleteSelection: function(e) {
                                      var i, n, direction, selection, values, caret, option_select, $option_select, $tail;
                                      var self = this;
                              
                                      direction = (e && e.keyCode === KEY_BACKSPACE) ? -1 : 1;
                          Severity: Minor
                          Found in public/assets/js/core/selectize/selectize.js - About 1 hr to fix

                            Function has too many statements (31). Maximum allowed is 30.
                            Open

                                        debounce_events(this, events, function() {

                            enforce a maximum number of statements allowed in function blocks (max-statements)

                            The max-statements rule allows you to specify the maximum number of statements allowed in a function.

                            function foo() {
                              var bar = 1; // one statement
                              var baz = 2; // two statements
                              var qux = 3; // three statements
                            }

                            Rule Details

                            This rule enforces a maximum number of statements allowed in function blocks.

                            Options

                            This rule has a number or object option:

                            • "max" (default 10) enforces a maximum number of statements allows in function blocks

                            Deprecated: The object property maximum is deprecated; please use the object property max instead.

                            This rule has an object option:

                            • "ignoreTopLevelFunctions": true ignores top-level functions

                            max

                            Examples of incorrect code for this rule with the default { "max": 10 } option:

                            /*eslint max-statements: ["error", 10]*/
                            /*eslint-env es6*/
                            
                            function foo() {
                              var foo1 = 1;
                              var foo2 = 2;
                              var foo3 = 3;
                              var foo4 = 4;
                              var foo5 = 5;
                              var foo6 = 6;
                              var foo7 = 7;
                              var foo8 = 8;
                              var foo9 = 9;
                              var foo10 = 10;
                            
                              var foo11 = 11; // Too many.
                            }
                            
                            let foo = () => {
                              var foo1 = 1;
                              var foo2 = 2;
                              var foo3 = 3;
                              var foo4 = 4;
                              var foo5 = 5;
                              var foo6 = 6;
                              var foo7 = 7;
                              var foo8 = 8;
                              var foo9 = 9;
                              var foo10 = 10;
                            
                              var foo11 = 11; // Too many.
                            };

                            Examples of correct code for this rule with the default { "max": 10 } option:

                            /*eslint max-statements: ["error", 10]*/
                            /*eslint-env es6*/
                            
                            function foo() {
                              var foo1 = 1;
                              var foo2 = 2;
                              var foo3 = 3;
                              var foo4 = 4;
                              var foo5 = 5;
                              var foo6 = 6;
                              var foo7 = 7;
                              var foo8 = 8;
                              var foo9 = 9;
                              var foo10 = 10;
                              return function () {
                            
                                // The number of statements in the inner function does not count toward the
                                // statement maximum.
                            
                                return 42;
                              };
                            }
                            
                            let foo = () => {
                              var foo1 = 1;
                              var foo2 = 2;
                              var foo3 = 3;
                              var foo4 = 4;
                              var foo5 = 5;
                              var foo6 = 6;
                              var foo7 = 7;
                              var foo8 = 8;
                              var foo9 = 9;
                              var foo10 = 10;
                              return function () {
                            
                                // The number of statements in the inner function does not count toward the
                                // statement maximum.
                            
                                return 42;
                              };
                            }

                            ignoreTopLevelFunctions

                            Examples of additional correct code for this rule with the { "max": 10 }, { "ignoreTopLevelFunctions": true } options:

                            /*eslint max-statements: ["error", 10, { "ignoreTopLevelFunctions": true }]*/
                            
                            function foo() {
                              var foo1 = 1;
                              var foo2 = 2;
                              var foo3 = 3;
                              var foo4 = 4;
                              var foo5 = 5;
                              var foo6 = 6;
                              var foo7 = 7;
                              var foo8 = 8;
                              var foo9 = 9;
                              var foo10 = 10;
                              var foo11 = 11;
                            }

                            Related Rules

                            • [complexity](complexity.md)
                            • [max-depth](max-depth.md)
                            • [max-len](max-len.md)
                            • [max-nested-callbacks](max-nested-callbacks.md)
                            • [max-params](max-params.md) Source: http://eslint.org/docs/rules/

                            Function has a complexity of 7.
                            Open

                                    var equalizeSizes = function() {

                            Limit Cyclomatic Complexity (complexity)

                            Cyclomatic complexity measures the number of linearly independent paths through a program's source code. This rule allows setting a cyclomatic complexity threshold.

                            function a(x) {
                                if (true) {
                                    return x; // 1st path
                                } else if (false) {
                                    return x+1; // 2nd path
                                } else {
                                    return 4; // 3rd path
                                }
                            }

                            Rule Details

                            This rule is aimed at reducing code complexity by capping the amount of cyclomatic complexity allowed in a program. As such, it will warn when the cyclomatic complexity crosses the configured threshold (default is 20).

                            Examples of incorrect code for a maximum of 2:

                            /*eslint complexity: ["error", 2]*/
                            
                            function a(x) {
                                if (true) {
                                    return x;
                                } else if (false) {
                                    return x+1;
                                } else {
                                    return 4; // 3rd path
                                }
                            }

                            Examples of correct code for a maximum of 2:

                            /*eslint complexity: ["error", 2]*/
                            
                            function a(x) {
                                if (true) {
                                    return x;
                                } else {
                                    return 4;
                                }
                            }

                            Options

                            Optionally, you may specify a max object property:

                            "complexity": ["error", 2]

                            is equivalent to

                            "complexity": ["error", { "max": 2 }]

                            Deprecated: the object property maximum is deprecated. Please use the property max instead.

                            When Not To Use It

                            If you can't determine an appropriate complexity limit for your code, then it's best to disable this rule.

                            Further Reading

                            Related Rules

                            • [max-depth](max-depth.md)
                            • [max-len](max-len.md)
                            • [max-nested-callbacks](max-nested-callbacks.md)
                            • [max-params](max-params.md)
                            • [max-statements](max-statements.md) Source: http://eslint.org/docs/rules/

                            Method 'search' has a complexity of 7.
                            Open

                                    search: function(query) {

                            Limit Cyclomatic Complexity (complexity)

                            Cyclomatic complexity measures the number of linearly independent paths through a program's source code. This rule allows setting a cyclomatic complexity threshold.

                            function a(x) {
                                if (true) {
                                    return x; // 1st path
                                } else if (false) {
                                    return x+1; // 2nd path
                                } else {
                                    return 4; // 3rd path
                                }
                            }

                            Rule Details

                            This rule is aimed at reducing code complexity by capping the amount of cyclomatic complexity allowed in a program. As such, it will warn when the cyclomatic complexity crosses the configured threshold (default is 20).

                            Examples of incorrect code for a maximum of 2:

                            /*eslint complexity: ["error", 2]*/
                            
                            function a(x) {
                                if (true) {
                                    return x;
                                } else if (false) {
                                    return x+1;
                                } else {
                                    return 4; // 3rd path
                                }
                            }

                            Examples of correct code for a maximum of 2:

                            /*eslint complexity: ["error", 2]*/
                            
                            function a(x) {
                                if (true) {
                                    return x;
                                } else {
                                    return 4;
                                }
                            }

                            Options

                            Optionally, you may specify a max object property:

                            "complexity": ["error", 2]

                            is equivalent to

                            "complexity": ["error", { "max": 2 }]

                            Deprecated: the object property maximum is deprecated. Please use the property max instead.

                            When Not To Use It

                            If you can't determine an appropriate complexity limit for your code, then it's best to disable this rule.

                            Further Reading

                            Related Rules

                            • [max-depth](max-depth.md)
                            • [max-len](max-len.md)
                            • [max-nested-callbacks](max-nested-callbacks.md)
                            • [max-params](max-params.md)
                            • [max-statements](max-statements.md) Source: http://eslint.org/docs/rules/

                            Method 'onMouseDown' has a complexity of 7.
                            Open

                                    onMouseDown: function(e) {

                            Limit Cyclomatic Complexity (complexity)

                            Cyclomatic complexity measures the number of linearly independent paths through a program's source code. This rule allows setting a cyclomatic complexity threshold.

                            function a(x) {
                                if (true) {
                                    return x; // 1st path
                                } else if (false) {
                                    return x+1; // 2nd path
                                } else {
                                    return 4; // 3rd path
                                }
                            }

                            Rule Details

                            This rule is aimed at reducing code complexity by capping the amount of cyclomatic complexity allowed in a program. As such, it will warn when the cyclomatic complexity crosses the configured threshold (default is 20).

                            Examples of incorrect code for a maximum of 2:

                            /*eslint complexity: ["error", 2]*/
                            
                            function a(x) {
                                if (true) {
                                    return x;
                                } else if (false) {
                                    return x+1;
                                } else {
                                    return 4; // 3rd path
                                }
                            }

                            Examples of correct code for a maximum of 2:

                            /*eslint complexity: ["error", 2]*/
                            
                            function a(x) {
                                if (true) {
                                    return x;
                                } else {
                                    return 4;
                                }
                            }

                            Options

                            Optionally, you may specify a max object property:

                            "complexity": ["error", 2]

                            is equivalent to

                            "complexity": ["error", { "max": 2 }]

                            Deprecated: the object property maximum is deprecated. Please use the property max instead.

                            When Not To Use It

                            If you can't determine an appropriate complexity limit for your code, then it's best to disable this rule.

                            Further Reading

                            Related Rules

                            • [max-depth](max-depth.md)
                            • [max-len](max-len.md)
                            • [max-nested-callbacks](max-nested-callbacks.md)
                            • [max-params](max-params.md)
                            • [max-statements](max-statements.md) Source: http://eslint.org/docs/rules/

                            Function update has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                    var update = function(e, options) {
                                        var value, keyCode, printable, placeholder, width;
                                        var shift, character, selection;
                                        e = e || window.event || {};
                                        options = options || {};
                            Severity: Minor
                            Found in public/assets/js/core/selectize/selectize.js - About 1 hr to fix

                              Function addItem has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                      addItem: function(value, silent) {
                                          var events = silent ? [] : ['change'];
                                  
                                          debounce_events(this, events, function() {
                                              var $item, $option, $options;
                              Severity: Minor
                              Found in public/assets/js/core/selectize/selectize.js - About 1 hr to fix

                                Function updateOption has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                        updateOption: function(value, data) {
                                            var self = this;
                                            var $item, $item_new;
                                            var value_new, index_item, cache_items, cache_options, order_old;
                                    
                                Severity: Minor
                                Found in public/assets/js/core/selectize/selectize.js - About 1 hr to fix

                                  Function createItem has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                          createItem: function(input, triggerDropdown) {
                                              var self  = this;
                                              var caret = self.caretPos;
                                              input = input || $.trim(self.$control_input.val() || '');
                                      
                                  Severity: Minor
                                  Found in public/assets/js/core/selectize/selectize.js - About 1 hr to fix

                                    Consider simplifying this complex logical expression.
                                    Open

                                                if (e.type && e.type.toLowerCase() === 'keydown') {
                                                    keyCode = e.keyCode;
                                                    printable = (
                                                        (keyCode >= 97 && keyCode <= 122) || // a-z
                                                        (keyCode >= 65 && keyCode <= 90)  || // A-Z
                                    Severity: Critical
                                    Found in public/assets/js/core/selectize/selectize.js - About 1 hr to fix

                                      Function render has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                                      Open

                                              render: function(templateName, data) {
                                                  var value, id, label;
                                                  var html = '';
                                                  var cache = false;
                                                  var self = this;
                                      Severity: Minor
                                      Found in public/assets/js/core/selectize/selectize.js - About 1 hr to fix

                                        Function initializePlugins has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                                        Open

                                                Interface.prototype.initializePlugins = function(plugins) {
                                                    var i, n, key;
                                                    var self  = this;
                                                    var queue = [];
                                        
                                        
                                        Severity: Minor
                                        Found in public/assets/js/core/selectize/selectize.js - About 1 hr to fix

                                          Function highlight has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                                          Open

                                              var highlight = function($element, pattern) {
                                                  if (typeof pattern === 'string' && !pattern.length) return;
                                                  var regex = (typeof pattern === 'string') ? new RegExp(pattern, 'i') : pattern;
                                              
                                                  var highlight = function(node) {
                                          Severity: Minor
                                          Found in public/assets/js/core/selectize/selectize.js - About 1 hr to fix

                                            Function onBlur has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                                            Open

                                                    onBlur: function(e, dest) {
                                                        var self = this;
                                                        if (!self.isFocused) return;
                                                        self.isFocused = false;
                                                
                                            Severity: Minor
                                            Found in public/assets/js/core/selectize/selectize.js - About 1 hr to fix

                                              Function search has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                                              Open

                                                  Sifter.prototype.search = function(query, options) {
                                                      var self = this, value, score, search, calculateScore;
                                                      var fn_sort;
                                                      var fn_score;
                                              
                                              
                                              Severity: Minor
                                              Found in public/assets/js/core/selectize/selectize.js - About 1 hr to fix

                                                Avoid too many return statements within this function.
                                                Open

                                                                    return;
                                                Severity: Major
                                                Found in public/assets/js/core/selectize/selectize.js - About 30 mins to fix

                                                  Avoid too many return statements within this function.
                                                  Open

                                                                      return;
                                                  Severity: Major
                                                  Found in public/assets/js/core/selectize/selectize.js - About 30 mins to fix

                                                    Avoid too many return statements within this function.
                                                    Open

                                                                        return;
                                                    Severity: Major
                                                    Found in public/assets/js/core/selectize/selectize.js - About 30 mins to fix

                                                      Avoid too many return statements within this function.
                                                      Open

                                                                          return;
                                                      Severity: Major
                                                      Found in public/assets/js/core/selectize/selectize.js - About 30 mins to fix

                                                        Avoid too many return statements within this function.
                                                        Open

                                                                        return;
                                                        Severity: Major
                                                        Found in public/assets/js/core/selectize/selectize.js - About 30 mins to fix

                                                          Avoid too many return statements within this function.
                                                          Open

                                                                              return;
                                                          Severity: Major
                                                          Found in public/assets/js/core/selectize/selectize.js - About 30 mins to fix

                                                            Avoid too many return statements within this function.
                                                            Open

                                                                                return;
                                                            Severity: Major
                                                            Found in public/assets/js/core/selectize/selectize.js - About 30 mins to fix

                                                              Expected return with your callback function.
                                                              Open

                                                                                  callback(this[i], i, this);

                                                              Enforce Return After Callback (callback-return)

                                                              The callback pattern is at the heart of most I/O and event-driven programming in JavaScript.

                                                              function doSomething(err, callback) {
                                                                  if (err) {
                                                                      return callback(err);
                                                                  }
                                                                  callback();
                                                              }

                                                              To prevent calling the callback multiple times it is important to return anytime the callback is triggered outside of the main function body. Neglecting this technique often leads to issues where you do something more than once. For example, in the case of an HTTP request, you may try to send HTTP headers more than once leading Node.js to throw a Can't render headers after they are sent to the client. error.

                                                              Rule Details

                                                              This rule is aimed at ensuring that callbacks used outside of the main function block are always part-of or immediately preceding a return statement. This rule decides what is a callback based on the name of the function being called.

                                                              Options

                                                              The rule takes a single option - an array of possible callback names - which may include object methods. The default callback names are callback, cb, next.

                                                              Default callback names

                                                              Examples of incorrect code for this rule with the default ["callback", "cb", "next"] option:

                                                              /*eslint callback-return: "error"*/
                                                              
                                                              function foo(err, callback) {
                                                                  if (err) {
                                                                      callback(err);
                                                                  }
                                                                  callback();
                                                              }

                                                              Examples of correct code for this rule with the default ["callback", "cb", "next"] option:

                                                              /*eslint callback-return: "error"*/
                                                              
                                                              function foo(err, callback) {
                                                                  if (err) {
                                                                      return callback(err);
                                                                  }
                                                                  callback();
                                                              }

                                                              Supplied callback names

                                                              Examples of incorrect code for this rule with the option ["done", "send.error", "send.success"]:

                                                              /*eslint callback-return: ["error", ["done", "send.error", "send.success"]]*/
                                                              
                                                              function foo(err, done) {
                                                                  if (err) {
                                                                      done(err);
                                                                  }
                                                                  done();
                                                              }
                                                              
                                                              function bar(err, send) {
                                                                  if (err) {
                                                                      send.error(err);
                                                                  }
                                                                  send.success();
                                                              }

                                                              Examples of correct code for this rule with the option ["done", "send.error", "send.success"]:

                                                              /*eslint callback-return: ["error", ["done", "send.error", "send.success"]]*/
                                                              
                                                              function foo(err, done) {
                                                                  if (err) {
                                                                      return done(err);
                                                                  }
                                                                  done();
                                                              }
                                                              
                                                              function bar(err, send) {
                                                                  if (err) {
                                                                      return send.error(err);
                                                                  }
                                                                  send.success();
                                                              }

                                                              Known Limitations

                                                              Because it is difficult to understand the meaning of a program through static analysis, this rule has limitations:

                                                              • false negatives when this rule reports correct code, but the program calls the callback more than one time (which is incorrect behavior)
                                                              • false positives when this rule reports incorrect code, but the program calls the callback only one time (which is correct behavior)

                                                              Passing the callback by reference

                                                              The static analysis of this rule does not detect that the program calls the callback if it is an argument of a function (for example, setTimeout).

                                                              Example of a false negative when this rule reports correct code:

                                                              /*eslint callback-return: "error"*/
                                                              
                                                              function foo(err, callback) {
                                                                  if (err) {
                                                                      setTimeout(callback, 0); // this is bad, but WILL NOT warn
                                                                  }
                                                                  callback();
                                                              }

                                                              Triggering the callback within a nested function

                                                              The static analysis of this rule does not detect that the program calls the callback from within a nested function or an immediately-invoked function expression (IIFE).

                                                              Example of a false negative when this rule reports correct code:

                                                              /*eslint callback-return: "error"*/
                                                              
                                                              function foo(err, callback) {
                                                                  if (err) {
                                                                      process.nextTick(function() {
                                                                          return callback(); // this is bad, but WILL NOT warn
                                                                      });
                                                                  }
                                                                  callback();
                                                              }

                                                              If/else statements

                                                              The static analysis of this rule does not detect that the program calls the callback only one time in each branch of an if statement.

                                                              Example of a false positive when this rule reports incorrect code:

                                                              /*eslint callback-return: "error"*/
                                                              
                                                              function foo(err, callback) {
                                                                  if (err) {
                                                                      callback(err); // this is fine, but WILL warn
                                                                  } else {
                                                                      callback();    // this is fine, but WILL warn
                                                                  }
                                                              }

                                                              When Not To Use It

                                                              There are some cases where you might want to call a callback function more than once. In those cases this rule may lead to incorrect behavior. In those cases you may want to reserve a special name for those callbacks and not include that in the list of callbacks that trigger warnings.

                                                              Further Reading

                                                              Related Rules

                                                              Expected return with your callback function.
                                                              Open

                                                                                      callback(this[key], key, this);

                                                              Enforce Return After Callback (callback-return)

                                                              The callback pattern is at the heart of most I/O and event-driven programming in JavaScript.

                                                              function doSomething(err, callback) {
                                                                  if (err) {
                                                                      return callback(err);
                                                                  }
                                                                  callback();
                                                              }

                                                              To prevent calling the callback multiple times it is important to return anytime the callback is triggered outside of the main function body. Neglecting this technique often leads to issues where you do something more than once. For example, in the case of an HTTP request, you may try to send HTTP headers more than once leading Node.js to throw a Can't render headers after they are sent to the client. error.

                                                              Rule Details

                                                              This rule is aimed at ensuring that callbacks used outside of the main function block are always part-of or immediately preceding a return statement. This rule decides what is a callback based on the name of the function being called.

                                                              Options

                                                              The rule takes a single option - an array of possible callback names - which may include object methods. The default callback names are callback, cb, next.

                                                              Default callback names

                                                              Examples of incorrect code for this rule with the default ["callback", "cb", "next"] option:

                                                              /*eslint callback-return: "error"*/
                                                              
                                                              function foo(err, callback) {
                                                                  if (err) {
                                                                      callback(err);
                                                                  }
                                                                  callback();
                                                              }

                                                              Examples of correct code for this rule with the default ["callback", "cb", "next"] option:

                                                              /*eslint callback-return: "error"*/
                                                              
                                                              function foo(err, callback) {
                                                                  if (err) {
                                                                      return callback(err);
                                                                  }
                                                                  callback();
                                                              }

                                                              Supplied callback names

                                                              Examples of incorrect code for this rule with the option ["done", "send.error", "send.success"]:

                                                              /*eslint callback-return: ["error", ["done", "send.error", "send.success"]]*/
                                                              
                                                              function foo(err, done) {
                                                                  if (err) {
                                                                      done(err);
                                                                  }
                                                                  done();
                                                              }
                                                              
                                                              function bar(err, send) {
                                                                  if (err) {
                                                                      send.error(err);
                                                                  }
                                                                  send.success();
                                                              }

                                                              Examples of correct code for this rule with the option ["done", "send.error", "send.success"]:

                                                              /*eslint callback-return: ["error", ["done", "send.error", "send.success"]]*/
                                                              
                                                              function foo(err, done) {
                                                                  if (err) {
                                                                      return done(err);
                                                                  }
                                                                  done();
                                                              }
                                                              
                                                              function bar(err, send) {
                                                                  if (err) {
                                                                      return send.error(err);
                                                                  }
                                                                  send.success();
                                                              }

                                                              Known Limitations

                                                              Because it is difficult to understand the meaning of a program through static analysis, this rule has limitations:

                                                              • false negatives when this rule reports correct code, but the program calls the callback more than one time (which is incorrect behavior)
                                                              • false positives when this rule reports incorrect code, but the program calls the callback only one time (which is correct behavior)

                                                              Passing the callback by reference

                                                              The static analysis of this rule does not detect that the program calls the callback if it is an argument of a function (for example, setTimeout).

                                                              Example of a false negative when this rule reports correct code:

                                                              /*eslint callback-return: "error"*/
                                                              
                                                              function foo(err, callback) {
                                                                  if (err) {
                                                                      setTimeout(callback, 0); // this is bad, but WILL NOT warn
                                                                  }
                                                                  callback();
                                                              }

                                                              Triggering the callback within a nested function

                                                              The static analysis of this rule does not detect that the program calls the callback from within a nested function or an immediately-invoked function expression (IIFE).

                                                              Example of a false negative when this rule reports correct code:

                                                              /*eslint callback-return: "error"*/
                                                              
                                                              function foo(err, callback) {
                                                                  if (err) {
                                                                      process.nextTick(function() {
                                                                          return callback(); // this is bad, but WILL NOT warn
                                                                      });
                                                                  }
                                                                  callback();
                                                              }

                                                              If/else statements

                                                              The static analysis of this rule does not detect that the program calls the callback only one time in each branch of an if statement.

                                                              Example of a false positive when this rule reports incorrect code:

                                                              /*eslint callback-return: "error"*/
                                                              
                                                              function foo(err, callback) {
                                                                  if (err) {
                                                                      callback(err); // this is fine, but WILL warn
                                                                  } else {
                                                                      callback();    // this is fine, but WILL warn
                                                                  }
                                                              }

                                                              When Not To Use It

                                                              There are some cases where you might want to call a callback function more than once. In those cases this rule may lead to incorrect behavior. In those cases you may want to reserve a special name for those callbacks and not include that in the list of callbacks that trigger warnings.

                                                              Further Reading

                                                              Related Rules

                                                              Expected an assignment or function call and instead saw an expression.
                                                              Open

                                                                                      self.isOpen ? self.close() : self.open();

                                                              Disallow Unused Expressions (no-unused-expressions)

                                                              An unused expression which has no effect on the state of the program indicates a logic error.

                                                              For example, n + 1; is not a syntax error, but it might be a typing mistake where a programmer meant an assignment statement n += 1; instead.

                                                              Rule Details

                                                              This rule aims to eliminate unused expressions which have no effect on the state of the program.

                                                              This rule does not apply to function calls or constructor calls with the new operator, because they could have side effects on the state of the program.

                                                              var i = 0;
                                                              function increment() { i += 1; }
                                                              increment(); // return value is unused, but i changed as a side effect
                                                              
                                                              var nThings = 0;
                                                              function Thing() { nThings += 1; }
                                                              new Thing(); // constructed object is unused, but nThings changed as a side effect

                                                              This rule does not apply to directives (which are in the form of literal string expressions such as "use strict"; at the beginning of a script, module, or function).

                                                              Sequence expressions (those using a comma, such as a = 1, b = 2) are always considered unused unless their return value is assigned or used in a condition evaluation, or a function call is made with the sequence expression value.

                                                              Options

                                                              This rule, in its default state, does not require any arguments. If you would like to enable one or more of the following you may pass an object with the options set as follows:

                                                              • allowShortCircuit set to true will allow you to use short circuit evaluations in your expressions (Default: false).
                                                              • allowTernary set to true will enable you to use ternary operators in your expressions similarly to short circuit evaluations (Default: false).
                                                              • allowTaggedTemplates set to true will enable you to use tagged template literals in your expressions (Default: false).

                                                              These options allow unused expressions only if all of the code paths either directly change the state (for example, assignment statement) or could have side effects (for example, function call).

                                                              Examples of incorrect code for the default { "allowShortCircuit": false, "allowTernary": false } options:

                                                              /*eslint no-unused-expressions: "error"*/
                                                              
                                                              0
                                                              
                                                              if(0) 0
                                                              
                                                              {0}
                                                              
                                                              f(0), {}
                                                              
                                                              a && b()
                                                              
                                                              a, b()
                                                              
                                                              c = a, b;
                                                              
                                                              a() && function namedFunctionInExpressionContext () {f();}
                                                              
                                                              (function anIncompleteIIFE () {});
                                                              
                                                              injectGlobal`body{ color: red; }`

                                                              Note that one or more string expression statements (with or without semi-colons) will only be considered as unused if they are not in the beginning of a script, module, or function (alone and uninterrupted by other statements). Otherwise, they will be treated as part of a "directive prologue", a section potentially usable by JavaScript engines. This includes "strict mode" directives.

                                                              "use strict";
                                                              "use asm"
                                                              "use stricter";
                                                              "use babel"
                                                              "any other strings like this in the prologue";

                                                              Examples of correct code for the default { "allowShortCircuit": false, "allowTernary": false } options:

                                                              /*eslint no-unused-expressions: "error"*/
                                                              
                                                              {} // In this context, this is a block statement, not an object literal
                                                              
                                                              {myLabel: someVar} // In this context, this is a block statement with a label and expression, not an object literal
                                                              
                                                              function namedFunctionDeclaration () {}
                                                              
                                                              (function aGenuineIIFE () {}());
                                                              
                                                              f()
                                                              
                                                              a = 0
                                                              
                                                              new C
                                                              
                                                              delete a.b
                                                              
                                                              void a

                                                              allowShortCircuit

                                                              Examples of incorrect code for the { "allowShortCircuit": true } option:

                                                              /*eslint no-unused-expressions: ["error", { "allowShortCircuit": true }]*/
                                                              
                                                              a || b

                                                              Examples of correct code for the { "allowShortCircuit": true } option:

                                                              /*eslint no-unused-expressions: ["error", { "allowShortCircuit": true }]*/
                                                              
                                                              a && b()
                                                              a() || (b = c)

                                                              allowTernary

                                                              Examples of incorrect code for the { "allowTernary": true } option:

                                                              /*eslint no-unused-expressions: ["error", { "allowTernary": true }]*/
                                                              
                                                              a ? b : 0
                                                              a ? b : c()

                                                              Examples of correct code for the { "allowTernary": true } option:

                                                              /*eslint no-unused-expressions: ["error", { "allowTernary": true }]*/
                                                              
                                                              a ? b() : c()
                                                              a ? (b = c) : d()

                                                              allowShortCircuit and allowTernary

                                                              Examples of correct code for the { "allowShortCircuit": true, "allowTernary": true } options:

                                                              /*eslint no-unused-expressions: ["error", { "allowShortCircuit": true, "allowTernary": true }]*/
                                                              
                                                              a ? b() || (c = d) : e()

                                                              allowTaggedTemplates

                                                              Examples of incorrect code for the { "allowTaggedTemplates": true } option:

                                                              /*eslint no-unused-expressions: ["error", { "allowTaggedTemplates": true }]*/
                                                              
                                                              `some untagged template string`;

                                                              Examples of correct code for the { "allowTaggedTemplates": true } option:

                                                              /*eslint no-unused-expressions: ["error", { "allowTaggedTemplates": true }]*/
                                                              
                                                              tag`some tagged template string`;

                                                              Source: http://eslint.org/docs/rules/

                                                              Expected a conditional expression and instead saw an assignment.
                                                              Open

                                                                          if (value = self.registerOption(data)) {

                                                              disallow assignment operators in conditional statements (no-cond-assign)

                                                              In conditional statements, it is very easy to mistype a comparison operator (such as ==) as an assignment operator (such as =). For example:

                                                              // Check the user's job title
                                                              if (user.jobTitle = "manager") {
                                                                  // user.jobTitle is now incorrect
                                                              }

                                                              There are valid reasons to use assignment operators in conditional statements. However, it can be difficult to tell whether a specific assignment was intentional.

                                                              Rule Details

                                                              This rule disallows ambiguous assignment operators in test conditions of if, for, while, and do...while statements.

                                                              Options

                                                              This rule has a string option:

                                                              • "except-parens" (default) allows assignments in test conditions only if they are enclosed in parentheses (for example, to allow reassigning a variable in the test of a while or do...while loop)
                                                              • "always" disallows all assignments in test conditions

                                                              except-parens

                                                              Examples of incorrect code for this rule with the default "except-parens" option:

                                                              /*eslint no-cond-assign: "error"*/
                                                              
                                                              // Unintentional assignment
                                                              var x;
                                                              if (x = 0) {
                                                                  var b = 1;
                                                              }
                                                              
                                                              // Practical example that is similar to an error
                                                              function setHeight(someNode) {
                                                                  "use strict";
                                                                  do {
                                                                      someNode.height = "100px";
                                                                  } while (someNode = someNode.parentNode);
                                                              }

                                                              Examples of correct code for this rule with the default "except-parens" option:

                                                              /*eslint no-cond-assign: "error"*/
                                                              
                                                              // Assignment replaced by comparison
                                                              var x;
                                                              if (x === 0) {
                                                                  var b = 1;
                                                              }
                                                              
                                                              // Practical example that wraps the assignment in parentheses
                                                              function setHeight(someNode) {
                                                                  "use strict";
                                                                  do {
                                                                      someNode.height = "100px";
                                                                  } while ((someNode = someNode.parentNode));
                                                              }
                                                              
                                                              // Practical example that wraps the assignment and tests for 'null'
                                                              function setHeight(someNode) {
                                                                  "use strict";
                                                                  do {
                                                                      someNode.height = "100px";
                                                                  } while ((someNode = someNode.parentNode) !== null);
                                                              }

                                                              always

                                                              Examples of incorrect code for this rule with the "always" option:

                                                              /*eslint no-cond-assign: ["error", "always"]*/
                                                              
                                                              // Unintentional assignment
                                                              var x;
                                                              if (x = 0) {
                                                                  var b = 1;
                                                              }
                                                              
                                                              // Practical example that is similar to an error
                                                              function setHeight(someNode) {
                                                                  "use strict";
                                                                  do {
                                                                      someNode.height = "100px";
                                                                  } while (someNode = someNode.parentNode);
                                                              }
                                                              
                                                              // Practical example that wraps the assignment in parentheses
                                                              function setHeight(someNode) {
                                                                  "use strict";
                                                                  do {
                                                                      someNode.height = "100px";
                                                                  } while ((someNode = someNode.parentNode));
                                                              }
                                                              
                                                              // Practical example that wraps the assignment and tests for 'null'
                                                              function setHeight(someNode) {
                                                                  "use strict";
                                                                  do {
                                                                      someNode.height = "100px";
                                                                  } while ((someNode = someNode.parentNode) !== null);
                                                              }

                                                              Examples of correct code for this rule with the "always" option:

                                                              /*eslint no-cond-assign: ["error", "always"]*/
                                                              
                                                              // Assignment replaced by comparison
                                                              var x;
                                                              if (x === 0) {
                                                                  var b = 1;
                                                              }

                                                              Related Rules

                                                              Expected a conditional expression and instead saw an assignment.
                                                              Open

                                                                          if (id = this.registerOptionGroup(data)) {

                                                              disallow assignment operators in conditional statements (no-cond-assign)

                                                              In conditional statements, it is very easy to mistype a comparison operator (such as ==) as an assignment operator (such as =). For example:

                                                              // Check the user's job title
                                                              if (user.jobTitle = "manager") {
                                                                  // user.jobTitle is now incorrect
                                                              }

                                                              There are valid reasons to use assignment operators in conditional statements. However, it can be difficult to tell whether a specific assignment was intentional.

                                                              Rule Details

                                                              This rule disallows ambiguous assignment operators in test conditions of if, for, while, and do...while statements.

                                                              Options

                                                              This rule has a string option:

                                                              • "except-parens" (default) allows assignments in test conditions only if they are enclosed in parentheses (for example, to allow reassigning a variable in the test of a while or do...while loop)
                                                              • "always" disallows all assignments in test conditions

                                                              except-parens

                                                              Examples of incorrect code for this rule with the default "except-parens" option:

                                                              /*eslint no-cond-assign: "error"*/
                                                              
                                                              // Unintentional assignment
                                                              var x;
                                                              if (x = 0) {
                                                                  var b = 1;
                                                              }
                                                              
                                                              // Practical example that is similar to an error
                                                              function setHeight(someNode) {
                                                                  "use strict";
                                                                  do {
                                                                      someNode.height = "100px";
                                                                  } while (someNode = someNode.parentNode);
                                                              }

                                                              Examples of correct code for this rule with the default "except-parens" option:

                                                              /*eslint no-cond-assign: "error"*/
                                                              
                                                              // Assignment replaced by comparison
                                                              var x;
                                                              if (x === 0) {
                                                                  var b = 1;
                                                              }
                                                              
                                                              // Practical example that wraps the assignment in parentheses
                                                              function setHeight(someNode) {
                                                                  "use strict";
                                                                  do {
                                                                      someNode.height = "100px";
                                                                  } while ((someNode = someNode.parentNode));
                                                              }
                                                              
                                                              // Practical example that wraps the assignment and tests for 'null'
                                                              function setHeight(someNode) {
                                                                  "use strict";
                                                                  do {
                                                                      someNode.height = "100px";
                                                                  } while ((someNode = someNode.parentNode) !== null);
                                                              }

                                                              always

                                                              Examples of incorrect code for this rule with the "always" option:

                                                              /*eslint no-cond-assign: ["error", "always"]*/
                                                              
                                                              // Unintentional assignment
                                                              var x;
                                                              if (x = 0) {
                                                                  var b = 1;
                                                              }
                                                              
                                                              // Practical example that is similar to an error
                                                              function setHeight(someNode) {
                                                                  "use strict";
                                                                  do {
                                                                      someNode.height = "100px";
                                                                  } while (someNode = someNode.parentNode);
                                                              }
                                                              
                                                              // Practical example that wraps the assignment in parentheses
                                                              function setHeight(someNode) {
                                                                  "use strict";
                                                                  do {
                                                                      someNode.height = "100px";
                                                                  } while ((someNode = someNode.parentNode));
                                                              }
                                                              
                                                              // Practical example that wraps the assignment and tests for 'null'
                                                              function setHeight(someNode) {
                                                                  "use strict";
                                                                  do {
                                                                      someNode.height = "100px";
                                                                  } while ((someNode = someNode.parentNode) !== null);
                                                              }

                                                              Examples of correct code for this rule with the "always" option:

                                                              /*eslint no-cond-assign: ["error", "always"]*/
                                                              
                                                              // Assignment replaced by comparison
                                                              var x;
                                                              if (x === 0) {
                                                                  var b = 1;
                                                              }

                                                              Related Rules

                                                              unnecessary '.apply()'.
                                                              Open

                                                                              resize    : function() { self.positionDropdown.apply(self, []); },

                                                              Disallow unnecessary .call() and .apply(). (no-useless-call)

                                                              The function invocation can be written by Function.prototype.call() and Function.prototype.apply(). But Function.prototype.call() and Function.prototype.apply() are slower than the normal function invocation.

                                                              Rule Details

                                                              This rule is aimed to flag usage of Function.prototype.call() and Function.prototype.apply() that can be replaced with the normal function invocation.

                                                              Examples of incorrect code for this rule:

                                                              /*eslint no-useless-call: "error"*/
                                                              
                                                              // These are same as `foo(1, 2, 3);`
                                                              foo.call(undefined, 1, 2, 3);
                                                              foo.apply(undefined, [1, 2, 3]);
                                                              foo.call(null, 1, 2, 3);
                                                              foo.apply(null, [1, 2, 3]);
                                                              
                                                              // These are same as `obj.foo(1, 2, 3);`
                                                              obj.foo.call(obj, 1, 2, 3);
                                                              obj.foo.apply(obj, [1, 2, 3]);

                                                              Examples of correct code for this rule:

                                                              /*eslint no-useless-call: "error"*/
                                                              
                                                              // The `this` binding is different.
                                                              foo.call(obj, 1, 2, 3);
                                                              foo.apply(obj, [1, 2, 3]);
                                                              obj.foo.call(null, 1, 2, 3);
                                                              obj.foo.apply(null, [1, 2, 3]);
                                                              obj.foo.call(otherObj, 1, 2, 3);
                                                              obj.foo.apply(otherObj, [1, 2, 3]);
                                                              
                                                              // The argument list is variadic.
                                                              foo.apply(undefined, args);
                                                              foo.apply(null, args);
                                                              obj.foo.apply(obj, args);

                                                              Known Limitations

                                                              This rule compares code statically to check whether or not thisArg is changed. So if the code about thisArg is a dynamic expression, this rule cannot judge correctly.

                                                              Examples of incorrect code for this rule:

                                                              /*eslint no-useless-call: "error"*/
                                                              
                                                              a[i++].foo.call(a[i++], 1, 2, 3);

                                                              Examples of correct code for this rule:

                                                              /*eslint no-useless-call: "error"*/
                                                              
                                                              a[++i].foo.call(a[i], 1, 2, 3);

                                                              When Not To Use It

                                                              If you don't want to be notified about unnecessary .call() and .apply(), you can safely disable this rule. Source: http://eslint.org/docs/rules/

                                                              Expected a 'break' statement before 'case'.
                                                              Open

                                                                              case KEY_UP:

                                                              Disallow Case Statement Fallthrough (no-fallthrough)

                                                              The switch statement in JavaScript is one of the more error-prone constructs of the language thanks in part to the ability to "fall through" from one case to the next. For example:

                                                              switch(foo) {
                                                                  case 1:
                                                                      doSomething();
                                                              
                                                                  case 2:
                                                                      doSomethingElse();
                                                              }

                                                              In this example, if foo is 1, then execution will flow through both cases, as the first falls through to the second. You can prevent this by using break, as in this example:

                                                              switch(foo) {
                                                                  case 1:
                                                                      doSomething();
                                                                      break;
                                                              
                                                                  case 2:
                                                                      doSomethingElse();
                                                              }

                                                              That works fine when you don't want a fallthrough, but what if the fallthrough is intentional, there is no way to indicate that in the language. It's considered a best practice to always indicate when a fallthrough is intentional using a comment which matches the /falls?\s?through/i regular expression:

                                                              switch(foo) {
                                                                  case 1:
                                                                      doSomething();
                                                                      // falls through
                                                              
                                                                  case 2:
                                                                      doSomethingElse();
                                                              }
                                                              
                                                              switch(foo) {
                                                                  case 1:
                                                                      doSomething();
                                                                      // fall through
                                                              
                                                                  case 2:
                                                                      doSomethingElse();
                                                              }
                                                              
                                                              switch(foo) {
                                                                  case 1:
                                                                      doSomething();
                                                                      // fallsthrough
                                                              
                                                                  case 2:
                                                                      doSomethingElse();
                                                              }

                                                              In this example, there is no confusion as to the expected behavior. It is clear that the first case is meant to fall through to the second case.

                                                              Rule Details

                                                              This rule is aimed at eliminating unintentional fallthrough of one case to the other. As such, it flags any fallthrough scenarios that are not marked by a comment.

                                                              Examples of incorrect code for this rule:

                                                              /*eslint no-fallthrough: "error"*/
                                                              
                                                              switch(foo) {
                                                                  case 1:
                                                                      doSomething();
                                                              
                                                                  case 2:
                                                                      doSomething();
                                                              }

                                                              Examples of correct code for this rule:

                                                              /*eslint no-fallthrough: "error"*/
                                                              
                                                              switch(foo) {
                                                                  case 1:
                                                                      doSomething();
                                                                      break;
                                                              
                                                                  case 2:
                                                                      doSomething();
                                                              }
                                                              
                                                              function bar(foo) {
                                                                  switch(foo) {
                                                                      case 1:
                                                                          doSomething();
                                                                          return;
                                                              
                                                                      case 2:
                                                                          doSomething();
                                                                  }
                                                              }
                                                              
                                                              switch(foo) {
                                                                  case 1:
                                                                      doSomething();
                                                                      throw new Error("Boo!");
                                                              
                                                                  case 2:
                                                                      doSomething();
                                                              }
                                                              
                                                              switch(foo) {
                                                                  case 1:
                                                                  case 2:
                                                                      doSomething();
                                                              }
                                                              
                                                              switch(foo) {
                                                                  case 1:
                                                                      doSomething();
                                                                      // falls through
                                                              
                                                                  case 2:
                                                                      doSomething();
                                                              }

                                                              Note that the last case statement in these examples does not cause a warning because there is nothing to fall through into.

                                                              Options

                                                              This rule accepts a single options argument:

                                                              • Set the commentPattern option to a regular expression string to change the test for intentional fallthrough comment

                                                              commentPattern

                                                              Examples of correct code for the { "commentPattern": "break[\\s\\w]*omitted" } option:

                                                              /*eslint no-fallthrough: ["error", { "commentPattern": "break[\\s\\w]*omitted" }]*/
                                                              
                                                              switch(foo) {
                                                                  case 1:
                                                                      doSomething();
                                                                      // break omitted
                                                              
                                                                  case 2:
                                                                      doSomething();
                                                              }
                                                              
                                                              switch(foo) {
                                                                  case 1:
                                                                      doSomething();
                                                                      // caution: break is omitted intentionally
                                                              
                                                                  default:
                                                                      doSomething();
                                                              }

                                                              When Not To Use It

                                                              If you don't want to enforce that each case statement should end with a throw, return, break, or comment, then you can safely turn this rule off.

                                                              Related Rules

                                                              Expected an assignment or function call and instead saw an expression.
                                                              Open

                                                                                  e && e.preventDefault();

                                                              Disallow Unused Expressions (no-unused-expressions)

                                                              An unused expression which has no effect on the state of the program indicates a logic error.

                                                              For example, n + 1; is not a syntax error, but it might be a typing mistake where a programmer meant an assignment statement n += 1; instead.

                                                              Rule Details

                                                              This rule aims to eliminate unused expressions which have no effect on the state of the program.

                                                              This rule does not apply to function calls or constructor calls with the new operator, because they could have side effects on the state of the program.

                                                              var i = 0;
                                                              function increment() { i += 1; }
                                                              increment(); // return value is unused, but i changed as a side effect
                                                              
                                                              var nThings = 0;
                                                              function Thing() { nThings += 1; }
                                                              new Thing(); // constructed object is unused, but nThings changed as a side effect

                                                              This rule does not apply to directives (which are in the form of literal string expressions such as "use strict"; at the beginning of a script, module, or function).

                                                              Sequence expressions (those using a comma, such as a = 1, b = 2) are always considered unused unless their return value is assigned or used in a condition evaluation, or a function call is made with the sequence expression value.

                                                              Options

                                                              This rule, in its default state, does not require any arguments. If you would like to enable one or more of the following you may pass an object with the options set as follows:

                                                              • allowShortCircuit set to true will allow you to use short circuit evaluations in your expressions (Default: false).
                                                              • allowTernary set to true will enable you to use ternary operators in your expressions similarly to short circuit evaluations (Default: false).
                                                              • allowTaggedTemplates set to true will enable you to use tagged template literals in your expressions (Default: false).

                                                              These options allow unused expressions only if all of the code paths either directly change the state (for example, assignment statement) or could have side effects (for example, function call).

                                                              Examples of incorrect code for the default { "allowShortCircuit": false, "allowTernary": false } options:

                                                              /*eslint no-unused-expressions: "error"*/
                                                              
                                                              0
                                                              
                                                              if(0) 0
                                                              
                                                              {0}
                                                              
                                                              f(0), {}
                                                              
                                                              a && b()
                                                              
                                                              a, b()
                                                              
                                                              c = a, b;
                                                              
                                                              a() && function namedFunctionInExpressionContext () {f();}
                                                              
                                                              (function anIncompleteIIFE () {});
                                                              
                                                              injectGlobal`body{ color: red; }`

                                                              Note that one or more string expression statements (with or without semi-colons) will only be considered as unused if they are not in the beginning of a script, module, or function (alone and uninterrupted by other statements). Otherwise, they will be treated as part of a "directive prologue", a section potentially usable by JavaScript engines. This includes "strict mode" directives.

                                                              "use strict";
                                                              "use asm"
                                                              "use stricter";
                                                              "use babel"
                                                              "any other strings like this in the prologue";

                                                              Examples of correct code for the default { "allowShortCircuit": false, "allowTernary": false } options:

                                                              /*eslint no-unused-expressions: "error"*/
                                                              
                                                              {} // In this context, this is a block statement, not an object literal
                                                              
                                                              {myLabel: someVar} // In this context, this is a block statement with a label and expression, not an object literal
                                                              
                                                              function namedFunctionDeclaration () {}
                                                              
                                                              (function aGenuineIIFE () {}());
                                                              
                                                              f()
                                                              
                                                              a = 0
                                                              
                                                              new C
                                                              
                                                              delete a.b
                                                              
                                                              void a

                                                              allowShortCircuit

                                                              Examples of incorrect code for the { "allowShortCircuit": true } option:

                                                              /*eslint no-unused-expressions: ["error", { "allowShortCircuit": true }]*/
                                                              
                                                              a || b

                                                              Examples of correct code for the { "allowShortCircuit": true } option:

                                                              /*eslint no-unused-expressions: ["error", { "allowShortCircuit": true }]*/
                                                              
                                                              a && b()
                                                              a() || (b = c)

                                                              allowTernary

                                                              Examples of incorrect code for the { "allowTernary": true } option:

                                                              /*eslint no-unused-expressions: ["error", { "allowTernary": true }]*/
                                                              
                                                              a ? b : 0
                                                              a ? b : c()

                                                              Examples of correct code for the { "allowTernary": true } option:

                                                              /*eslint no-unused-expressions: ["error", { "allowTernary": true }]*/
                                                              
                                                              a ? b() : c()
                                                              a ? (b = c) : d()

                                                              allowShortCircuit and allowTernary

                                                              Examples of correct code for the { "allowShortCircuit": true, "allowTernary": true } options:

                                                              /*eslint no-unused-expressions: ["error", { "allowShortCircuit": true, "allowTernary": true }]*/
                                                              
                                                              a ? b() || (c = d) : e()

                                                              allowTaggedTemplates

                                                              Examples of incorrect code for the { "allowTaggedTemplates": true } option:

                                                              /*eslint no-unused-expressions: ["error", { "allowTaggedTemplates": true }]*/
                                                              
                                                              `some untagged template string`;

                                                              Examples of correct code for the { "allowTaggedTemplates": true } option:

                                                              /*eslint no-unused-expressions: ["error", { "allowTaggedTemplates": true }]*/
                                                              
                                                              tag`some tagged template string`;

                                                              Source: http://eslint.org/docs/rules/

                                                              Expected a 'break' statement before 'case'.
                                                              Open

                                                                              case KEY_DOWN:

                                                              Disallow Case Statement Fallthrough (no-fallthrough)

                                                              The switch statement in JavaScript is one of the more error-prone constructs of the language thanks in part to the ability to "fall through" from one case to the next. For example:

                                                              switch(foo) {
                                                                  case 1:
                                                                      doSomething();
                                                              
                                                                  case 2:
                                                                      doSomethingElse();
                                                              }

                                                              In this example, if foo is 1, then execution will flow through both cases, as the first falls through to the second. You can prevent this by using break, as in this example:

                                                              switch(foo) {
                                                                  case 1:
                                                                      doSomething();
                                                                      break;
                                                              
                                                                  case 2:
                                                                      doSomethingElse();
                                                              }

                                                              That works fine when you don't want a fallthrough, but what if the fallthrough is intentional, there is no way to indicate that in the language. It's considered a best practice to always indicate when a fallthrough is intentional using a comment which matches the /falls?\s?through/i regular expression:

                                                              switch(foo) {
                                                                  case 1:
                                                                      doSomething();
                                                                      // falls through
                                                              
                                                                  case 2:
                                                                      doSomethingElse();
                                                              }
                                                              
                                                              switch(foo) {
                                                                  case 1:
                                                                      doSomething();
                                                                      // fall through
                                                              
                                                                  case 2:
                                                                      doSomethingElse();
                                                              }
                                                              
                                                              switch(foo) {
                                                                  case 1:
                                                                      doSomething();
                                                                      // fallsthrough
                                                              
                                                                  case 2:
                                                                      doSomethingElse();
                                                              }

                                                              In this example, there is no confusion as to the expected behavior. It is clear that the first case is meant to fall through to the second case.

                                                              Rule Details

                                                              This rule is aimed at eliminating unintentional fallthrough of one case to the other. As such, it flags any fallthrough scenarios that are not marked by a comment.

                                                              Examples of incorrect code for this rule:

                                                              /*eslint no-fallthrough: "error"*/
                                                              
                                                              switch(foo) {
                                                                  case 1:
                                                                      doSomething();
                                                              
                                                                  case 2:
                                                                      doSomething();
                                                              }

                                                              Examples of correct code for this rule:

                                                              /*eslint no-fallthrough: "error"*/
                                                              
                                                              switch(foo) {
                                                                  case 1:
                                                                      doSomething();
                                                                      break;
                                                              
                                                                  case 2:
                                                                      doSomething();
                                                              }
                                                              
                                                              function bar(foo) {
                                                                  switch(foo) {
                                                                      case 1:
                                                                          doSomething();
                                                                          return;
                                                              
                                                                      case 2:
                                                                          doSomething();
                                                                  }
                                                              }
                                                              
                                                              switch(foo) {
                                                                  case 1:
                                                                      doSomething();
                                                                      throw new Error("Boo!");
                                                              
                                                                  case 2:
                                                                      doSomething();
                                                              }
                                                              
                                                              switch(foo) {
                                                                  case 1:
                                                                  case 2:
                                                                      doSomething();
                                                              }
                                                              
                                                              switch(foo) {
                                                                  case 1:
                                                                      doSomething();
                                                                      // falls through
                                                              
                                                                  case 2:
                                                                      doSomething();
                                                              }

                                                              Note that the last case statement in these examples does not cause a warning because there is nothing to fall through into.

                                                              Options

                                                              This rule accepts a single options argument:

                                                              • Set the commentPattern option to a regular expression string to change the test for intentional fallthrough comment

                                                              commentPattern

                                                              Examples of correct code for the { "commentPattern": "break[\\s\\w]*omitted" } option:

                                                              /*eslint no-fallthrough: ["error", { "commentPattern": "break[\\s\\w]*omitted" }]*/
                                                              
                                                              switch(foo) {
                                                                  case 1:
                                                                      doSomething();
                                                                      // break omitted
                                                              
                                                                  case 2:
                                                                      doSomething();
                                                              }
                                                              
                                                              switch(foo) {
                                                                  case 1:
                                                                      doSomething();
                                                                      // caution: break is omitted intentionally
                                                              
                                                                  default:
                                                                      doSomething();
                                                              }

                                                              When Not To Use It

                                                              If you don't want to enforce that each case statement should end with a throw, return, break, or comment, then you can safely turn this rule off.

                                                              Related Rules

                                                              Expected an assignment or function call and instead saw an expression.
                                                              Open

                                                                              e && e.preventDefault();

                                                              Disallow Unused Expressions (no-unused-expressions)

                                                              An unused expression which has no effect on the state of the program indicates a logic error.

                                                              For example, n + 1; is not a syntax error, but it might be a typing mistake where a programmer meant an assignment statement n += 1; instead.

                                                              Rule Details

                                                              This rule aims to eliminate unused expressions which have no effect on the state of the program.

                                                              This rule does not apply to function calls or constructor calls with the new operator, because they could have side effects on the state of the program.

                                                              var i = 0;
                                                              function increment() { i += 1; }
                                                              increment(); // return value is unused, but i changed as a side effect
                                                              
                                                              var nThings = 0;
                                                              function Thing() { nThings += 1; }
                                                              new Thing(); // constructed object is unused, but nThings changed as a side effect

                                                              This rule does not apply to directives (which are in the form of literal string expressions such as "use strict"; at the beginning of a script, module, or function).

                                                              Sequence expressions (those using a comma, such as a = 1, b = 2) are always considered unused unless their return value is assigned or used in a condition evaluation, or a function call is made with the sequence expression value.

                                                              Options

                                                              This rule, in its default state, does not require any arguments. If you would like to enable one or more of the following you may pass an object with the options set as follows:

                                                              • allowShortCircuit set to true will allow you to use short circuit evaluations in your expressions (Default: false).
                                                              • allowTernary set to true will enable you to use ternary operators in your expressions similarly to short circuit evaluations (Default: false).
                                                              • allowTaggedTemplates set to true will enable you to use tagged template literals in your expressions (Default: false).

                                                              These options allow unused expressions only if all of the code paths either directly change the state (for example, assignment statement) or could have side effects (for example, function call).

                                                              Examples of incorrect code for the default { "allowShortCircuit": false, "allowTernary": false } options:

                                                              /*eslint no-unused-expressions: "error"*/
                                                              
                                                              0
                                                              
                                                              if(0) 0
                                                              
                                                              {0}
                                                              
                                                              f(0), {}
                                                              
                                                              a && b()
                                                              
                                                              a, b()
                                                              
                                                              c = a, b;
                                                              
                                                              a() && function namedFunctionInExpressionContext () {f();}
                                                              
                                                              (function anIncompleteIIFE () {});
                                                              
                                                              injectGlobal`body{ color: red; }`

                                                              Note that one or more string expression statements (with or without semi-colons) will only be considered as unused if they are not in the beginning of a script, module, or function (alone and uninterrupted by other statements). Otherwise, they will be treated as part of a "directive prologue", a section potentially usable by JavaScript engines. This includes "strict mode" directives.

                                                              "use strict";
                                                              "use asm"
                                                              "use stricter";
                                                              "use babel"
                                                              "any other strings like this in the prologue";

                                                              Examples of correct code for the default { "allowShortCircuit": false, "allowTernary": false } options:

                                                              /*eslint no-unused-expressions: "error"*/
                                                              
                                                              {} // In this context, this is a block statement, not an object literal
                                                              
                                                              {myLabel: someVar} // In this context, this is a block statement with a label and expression, not an object literal
                                                              
                                                              function namedFunctionDeclaration () {}
                                                              
                                                              (function aGenuineIIFE () {}());
                                                              
                                                              f()
                                                              
                                                              a = 0
                                                              
                                                              new C
                                                              
                                                              delete a.b
                                                              
                                                              void a

                                                              allowShortCircuit

                                                              Examples of incorrect code for the { "allowShortCircuit": true } option:

                                                              /*eslint no-unused-expressions: ["error", { "allowShortCircuit": true }]*/
                                                              
                                                              a || b

                                                              Examples of correct code for the { "allowShortCircuit": true } option:

                                                              /*eslint no-unused-expressions: ["error", { "allowShortCircuit": true }]*/
                                                              
                                                              a && b()
                                                              a() || (b = c)

                                                              allowTernary

                                                              Examples of incorrect code for the { "allowTernary": true } option:

                                                              /*eslint no-unused-expressions: ["error", { "allowTernary": true }]*/
                                                              
                                                              a ? b : 0
                                                              a ? b : c()

                                                              Examples of correct code for the { "allowTernary": true } option:

                                                              /*eslint no-unused-expressions: ["error", { "allowTernary": true }]*/
                                                              
                                                              a ? b() : c()
                                                              a ? (b = c) : d()

                                                              allowShortCircuit and allowTernary

                                                              Examples of correct code for the { "allowShortCircuit": true, "allowTernary": true } options:

                                                              /*eslint no-unused-expressions: ["error", { "allowShortCircuit": true, "allowTernary": true }]*/
                                                              
                                                              a ? b() || (c = d) : e()

                                                              allowTaggedTemplates

                                                              Examples of incorrect code for the { "allowTaggedTemplates": true } option:

                                                              /*eslint no-unused-expressions: ["error", { "allowTaggedTemplates": true }]*/
                                                              
                                                              `some untagged template string`;

                                                              Examples of correct code for the { "allowTaggedTemplates": true } option:

                                                              /*eslint no-unused-expressions: ["error", { "allowTaggedTemplates": true }]*/
                                                              
                                                              tag`some tagged template string`;

                                                              Source: http://eslint.org/docs/rules/

                                                              Move the invocation into the parens that contain the function.
                                                              Open

                                                                      var scoreObject = (function() {

                                                              Require IIFEs to be Wrapped (wrap-iife)

                                                              You can immediately invoke function expressions, but not function declarations. A common technique to create an immediately-invoked function expression (IIFE) is to wrap a function declaration in parentheses. The opening parentheses causes the contained function to be parsed as an expression, rather than a declaration.

                                                              // function expression could be unwrapped
                                                              var x = function () { return { y: 1 };}();
                                                              
                                                              // function declaration must be wrapped
                                                              function () { /* side effects */ }(); // SyntaxError

                                                              Rule Details

                                                              This rule requires all immediately-invoked function expressions to be wrapped in parentheses.

                                                              Options

                                                              This rule has two options, a string option and an object option.

                                                              String option:

                                                              • "outside" enforces always wrapping the call expression. The default is "outside".
                                                              • "inside" enforces always wrapping the function expression.
                                                              • "any" enforces always wrapping, but allows either style.

                                                              Object option:

                                                              • "functionPrototypeMethods": true additionally enforces wrapping function expressions invoked using .call and .apply. The default is false.

                                                              outside

                                                              Examples of incorrect code for the default "outside" option:

                                                              /*eslint wrap-iife: ["error", "outside"]*/
                                                              
                                                              var x = function () { return { y: 1 };}(); // unwrapped
                                                              var x = (function () { return { y: 1 };})(); // wrapped function expression

                                                              Examples of correct code for the default "outside" option:

                                                              /*eslint wrap-iife: ["error", "outside"]*/
                                                              
                                                              var x = (function () { return { y: 1 };}()); // wrapped call expression

                                                              inside

                                                              Examples of incorrect code for the "inside" option:

                                                              /*eslint wrap-iife: ["error", "inside"]*/
                                                              
                                                              var x = function () { return { y: 1 };}(); // unwrapped
                                                              var x = (function () { return { y: 1 };}()); // wrapped call expression

                                                              Examples of correct code for the "inside" option:

                                                              /*eslint wrap-iife: ["error", "inside"]*/
                                                              
                                                              var x = (function () { return { y: 1 };})(); // wrapped function expression

                                                              any

                                                              Examples of incorrect code for the "any" option:

                                                              /*eslint wrap-iife: ["error", "any"]*/
                                                              
                                                              var x = function () { return { y: 1 };}(); // unwrapped

                                                              Examples of correct code for the "any" option:

                                                              /*eslint wrap-iife: ["error", "any"]*/
                                                              
                                                              var x = (function () { return { y: 1 };}()); // wrapped call expression
                                                              var x = (function () { return { y: 1 };})(); // wrapped function expression

                                                              functionPrototypeMethods

                                                              Examples of incorrect code for this rule with the "inside", { "functionPrototypeMethods": true } options:

                                                              /* eslint wrap-iife: [2, "inside", { functionPrototypeMethods: true }] */
                                                              
                                                              var x = function(){ foo(); }()
                                                              var x = (function(){ foo(); }())
                                                              var x = function(){ foo(); }.call(bar)
                                                              var x = (function(){ foo(); }.call(bar))

                                                              Examples of correct code for this rule with the "inside", { "functionPrototypeMethods": true } options:

                                                              /* eslint wrap-iife: [2, "inside", { functionPrototypeMethods: true }] */
                                                              
                                                              var x = (function(){ foo(); })()
                                                              var x = (function(){ foo(); }).call(bar)

                                                              Source: http://eslint.org/docs/rules/

                                                              Move the invocation into the parens that contain the function.
                                                              Open

                                                                      self.setup = (function() {

                                                              Require IIFEs to be Wrapped (wrap-iife)

                                                              You can immediately invoke function expressions, but not function declarations. A common technique to create an immediately-invoked function expression (IIFE) is to wrap a function declaration in parentheses. The opening parentheses causes the contained function to be parsed as an expression, rather than a declaration.

                                                              // function expression could be unwrapped
                                                              var x = function () { return { y: 1 };}();
                                                              
                                                              // function declaration must be wrapped
                                                              function () { /* side effects */ }(); // SyntaxError

                                                              Rule Details

                                                              This rule requires all immediately-invoked function expressions to be wrapped in parentheses.

                                                              Options

                                                              This rule has two options, a string option and an object option.

                                                              String option:

                                                              • "outside" enforces always wrapping the call expression. The default is "outside".
                                                              • "inside" enforces always wrapping the function expression.
                                                              • "any" enforces always wrapping, but allows either style.

                                                              Object option:

                                                              • "functionPrototypeMethods": true additionally enforces wrapping function expressions invoked using .call and .apply. The default is false.

                                                              outside

                                                              Examples of incorrect code for the default "outside" option:

                                                              /*eslint wrap-iife: ["error", "outside"]*/
                                                              
                                                              var x = function () { return { y: 1 };}(); // unwrapped
                                                              var x = (function () { return { y: 1 };})(); // wrapped function expression

                                                              Examples of correct code for the default "outside" option:

                                                              /*eslint wrap-iife: ["error", "outside"]*/
                                                              
                                                              var x = (function () { return { y: 1 };}()); // wrapped call expression

                                                              inside

                                                              Examples of incorrect code for the "inside" option:

                                                              /*eslint wrap-iife: ["error", "inside"]*/
                                                              
                                                              var x = function () { return { y: 1 };}(); // unwrapped
                                                              var x = (function () { return { y: 1 };}()); // wrapped call expression

                                                              Examples of correct code for the "inside" option:

                                                              /*eslint wrap-iife: ["error", "inside"]*/
                                                              
                                                              var x = (function () { return { y: 1 };})(); // wrapped function expression

                                                              any

                                                              Examples of incorrect code for the "any" option:

                                                              /*eslint wrap-iife: ["error", "any"]*/
                                                              
                                                              var x = function () { return { y: 1 };}(); // unwrapped

                                                              Examples of correct code for the "any" option:

                                                              /*eslint wrap-iife: ["error", "any"]*/
                                                              
                                                              var x = (function () { return { y: 1 };}()); // wrapped call expression
                                                              var x = (function () { return { y: 1 };})(); // wrapped function expression

                                                              functionPrototypeMethods

                                                              Examples of incorrect code for this rule with the "inside", { "functionPrototypeMethods": true } options:

                                                              /* eslint wrap-iife: [2, "inside", { functionPrototypeMethods: true }] */
                                                              
                                                              var x = function(){ foo(); }()
                                                              var x = (function(){ foo(); }())
                                                              var x = function(){ foo(); }.call(bar)
                                                              var x = (function(){ foo(); }.call(bar))

                                                              Examples of correct code for this rule with the "inside", { "functionPrototypeMethods": true } options:

                                                              /* eslint wrap-iife: [2, "inside", { functionPrototypeMethods: true }] */
                                                              
                                                              var x = (function(){ foo(); })()
                                                              var x = (function(){ foo(); }).call(bar)

                                                              Source: http://eslint.org/docs/rules/

                                                              Move the invocation into the parens that contain the function.
                                                              Open

                                                                      self.unlock = (function() {

                                                              Require IIFEs to be Wrapped (wrap-iife)

                                                              You can immediately invoke function expressions, but not function declarations. A common technique to create an immediately-invoked function expression (IIFE) is to wrap a function declaration in parentheses. The opening parentheses causes the contained function to be parsed as an expression, rather than a declaration.

                                                              // function expression could be unwrapped
                                                              var x = function () { return { y: 1 };}();
                                                              
                                                              // function declaration must be wrapped
                                                              function () { /* side effects */ }(); // SyntaxError

                                                              Rule Details

                                                              This rule requires all immediately-invoked function expressions to be wrapped in parentheses.

                                                              Options

                                                              This rule has two options, a string option and an object option.

                                                              String option:

                                                              • "outside" enforces always wrapping the call expression. The default is "outside".
                                                              • "inside" enforces always wrapping the function expression.
                                                              • "any" enforces always wrapping, but allows either style.

                                                              Object option:

                                                              • "functionPrototypeMethods": true additionally enforces wrapping function expressions invoked using .call and .apply. The default is false.

                                                              outside

                                                              Examples of incorrect code for the default "outside" option:

                                                              /*eslint wrap-iife: ["error", "outside"]*/
                                                              
                                                              var x = function () { return { y: 1 };}(); // unwrapped
                                                              var x = (function () { return { y: 1 };})(); // wrapped function expression

                                                              Examples of correct code for the default "outside" option:

                                                              /*eslint wrap-iife: ["error", "outside"]*/
                                                              
                                                              var x = (function () { return { y: 1 };}()); // wrapped call expression

                                                              inside

                                                              Examples of incorrect code for the "inside" option:

                                                              /*eslint wrap-iife: ["error", "inside"]*/
                                                              
                                                              var x = function () { return { y: 1 };}(); // unwrapped
                                                              var x = (function () { return { y: 1 };}()); // wrapped call expression

                                                              Examples of correct code for the "inside" option:

                                                              /*eslint wrap-iife: ["error", "inside"]*/
                                                              
                                                              var x = (function () { return { y: 1 };})(); // wrapped function expression

                                                              any

                                                              Examples of incorrect code for the "any" option:

                                                              /*eslint wrap-iife: ["error", "any"]*/
                                                              
                                                              var x = function () { return { y: 1 };}(); // unwrapped

                                                              Examples of correct code for the "any" option:

                                                              /*eslint wrap-iife: ["error", "any"]*/
                                                              
                                                              var x = (function () { return { y: 1 };}()); // wrapped call expression
                                                              var x = (function () { return { y: 1 };})(); // wrapped function expression

                                                              functionPrototypeMethods

                                                              Examples of incorrect code for this rule with the "inside", { "functionPrototypeMethods": true } options:

                                                              /* eslint wrap-iife: [2, "inside", { functionPrototypeMethods: true }] */
                                                              
                                                              var x = function(){ foo(); }()
                                                              var x = (function(){ foo(); }())
                                                              var x = function(){ foo(); }.call(bar)
                                                              var x = (function(){ foo(); }.call(bar))

                                                              Examples of correct code for this rule with the "inside", { "functionPrototypeMethods": true } options:

                                                              /* eslint wrap-iife: [2, "inside", { functionPrototypeMethods: true }] */
                                                              
                                                              var x = (function(){ foo(); })()
                                                              var x = (function(){ foo(); }).call(bar)

                                                              Source: http://eslint.org/docs/rules/

                                                              Move the invocation into the parens that contain the function.
                                                              Open

                                                                      this.onKeyDown = (function() {

                                                              Require IIFEs to be Wrapped (wrap-iife)

                                                              You can immediately invoke function expressions, but not function declarations. A common technique to create an immediately-invoked function expression (IIFE) is to wrap a function declaration in parentheses. The opening parentheses causes the contained function to be parsed as an expression, rather than a declaration.

                                                              // function expression could be unwrapped
                                                              var x = function () { return { y: 1 };}();
                                                              
                                                              // function declaration must be wrapped
                                                              function () { /* side effects */ }(); // SyntaxError

                                                              Rule Details

                                                              This rule requires all immediately-invoked function expressions to be wrapped in parentheses.

                                                              Options

                                                              This rule has two options, a string option and an object option.

                                                              String option:

                                                              • "outside" enforces always wrapping the call expression. The default is "outside".
                                                              • "inside" enforces always wrapping the function expression.
                                                              • "any" enforces always wrapping, but allows either style.

                                                              Object option:

                                                              • "functionPrototypeMethods": true additionally enforces wrapping function expressions invoked using .call and .apply. The default is false.

                                                              outside

                                                              Examples of incorrect code for the default "outside" option:

                                                              /*eslint wrap-iife: ["error", "outside"]*/
                                                              
                                                              var x = function () { return { y: 1 };}(); // unwrapped
                                                              var x = (function () { return { y: 1 };})(); // wrapped function expression

                                                              Examples of correct code for the default "outside" option:

                                                              /*eslint wrap-iife: ["error", "outside"]*/
                                                              
                                                              var x = (function () { return { y: 1 };}()); // wrapped call expression

                                                              inside

                                                              Examples of incorrect code for the "inside" option:

                                                              /*eslint wrap-iife: ["error", "inside"]*/
                                                              
                                                              var x = function () { return { y: 1 };}(); // unwrapped
                                                              var x = (function () { return { y: 1 };}()); // wrapped call expression

                                                              Examples of correct code for the "inside" option:

                                                              /*eslint wrap-iife: ["error", "inside"]*/
                                                              
                                                              var x = (function () { return { y: 1 };})(); // wrapped function expression

                                                              any

                                                              Examples of incorrect code for the "any" option:

                                                              /*eslint wrap-iife: ["error", "any"]*/
                                                              
                                                              var x = function () { return { y: 1 };}(); // unwrapped

                                                              Examples of correct code for the "any" option:

                                                              /*eslint wrap-iife: ["error", "any"]*/
                                                              
                                                              var x = (function () { return { y: 1 };}()); // wrapped call expression
                                                              var x = (function () { return { y: 1 };})(); // wrapped function expression

                                                              functionPrototypeMethods

                                                              Examples of incorrect code for this rule with the "inside", { "functionPrototypeMethods": true } options:

                                                              /* eslint wrap-iife: [2, "inside", { functionPrototypeMethods: true }] */
                                                              
                                                              var x = function(){ foo(); }()
                                                              var x = (function(){ foo(); }())
                                                              var x = function(){ foo(); }.call(bar)
                                                              var x = (function(){ foo(); }.call(bar))

                                                              Examples of correct code for this rule with the "inside", { "functionPrototypeMethods": true } options:

                                                              /* eslint wrap-iife: [2, "inside", { functionPrototypeMethods: true }] */
                                                              
                                                              var x = (function(){ foo(); })()
                                                              var x = (function(){ foo(); }).call(bar)

                                                              Source: http://eslint.org/docs/rules/

                                                              Move the invocation into the parens that contain the function.
                                                              Open

                                                                  var asciifold = (function() {

                                                              Require IIFEs to be Wrapped (wrap-iife)

                                                              You can immediately invoke function expressions, but not function declarations. A common technique to create an immediately-invoked function expression (IIFE) is to wrap a function declaration in parentheses. The opening parentheses causes the contained function to be parsed as an expression, rather than a declaration.

                                                              // function expression could be unwrapped
                                                              var x = function () { return { y: 1 };}();
                                                              
                                                              // function declaration must be wrapped
                                                              function () { /* side effects */ }(); // SyntaxError

                                                              Rule Details

                                                              This rule requires all immediately-invoked function expressions to be wrapped in parentheses.

                                                              Options

                                                              This rule has two options, a string option and an object option.

                                                              String option:

                                                              • "outside" enforces always wrapping the call expression. The default is "outside".
                                                              • "inside" enforces always wrapping the function expression.
                                                              • "any" enforces always wrapping, but allows either style.

                                                              Object option:

                                                              • "functionPrototypeMethods": true additionally enforces wrapping function expressions invoked using .call and .apply. The default is false.

                                                              outside

                                                              Examples of incorrect code for the default "outside" option:

                                                              /*eslint wrap-iife: ["error", "outside"]*/
                                                              
                                                              var x = function () { return { y: 1 };}(); // unwrapped
                                                              var x = (function () { return { y: 1 };})(); // wrapped function expression

                                                              Examples of correct code for the default "outside" option:

                                                              /*eslint wrap-iife: ["error", "outside"]*/
                                                              
                                                              var x = (function () { return { y: 1 };}()); // wrapped call expression

                                                              inside

                                                              Examples of incorrect code for the "inside" option:

                                                              /*eslint wrap-iife: ["error", "inside"]*/
                                                              
                                                              var x = function () { return { y: 1 };}(); // unwrapped
                                                              var x = (function () { return { y: 1 };}()); // wrapped call expression

                                                              Examples of correct code for the "inside" option:

                                                              /*eslint wrap-iife: ["error", "inside"]*/
                                                              
                                                              var x = (function () { return { y: 1 };})(); // wrapped function expression

                                                              any

                                                              Examples of incorrect code for the "any" option:

                                                              /*eslint wrap-iife: ["error", "any"]*/
                                                              
                                                              var x = function () { return { y: 1 };}(); // unwrapped

                                                              Examples of correct code for the "any" option:

                                                              /*eslint wrap-iife: ["error", "any"]*/
                                                              
                                                              var x = (function () { return { y: 1 };}()); // wrapped call expression
                                                              var x = (function () { return { y: 1 };})(); // wrapped function expression

                                                              functionPrototypeMethods

                                                              Examples of incorrect code for this rule with the "inside", { "functionPrototypeMethods": true } options:

                                                              /* eslint wrap-iife: [2, "inside", { functionPrototypeMethods: true }] */
                                                              
                                                              var x = function(){ foo(); }()
                                                              var x = (function(){ foo(); }())
                                                              var x = function(){ foo(); }.call(bar)
                                                              var x = (function(){ foo(); }.call(bar))

                                                              Examples of correct code for this rule with the "inside", { "functionPrototypeMethods": true } options:

                                                              /* eslint wrap-iife: [2, "inside", { functionPrototypeMethods: true }] */
                                                              
                                                              var x = (function(){ foo(); })()
                                                              var x = (function(){ foo(); }).call(bar)

                                                              Source: http://eslint.org/docs/rules/

                                                              Unexpected require().
                                                              Open

                                                                      module.exports = factory(require('jquery'), require('sifter'), require('microplugin'));

                                                              Enforce require() on the top-level module scope (global-require)

                                                              In Node.js, module dependencies are included using the require() function, such as:

                                                              var fs = require("fs");

                                                              While require() may be called anywhere in code, some style guides prescribe that it should be called only in the top level of a module to make it easier to identify dependencies. For instance, it's arguably harder to identify dependencies when they are deeply nested inside of functions and other statements:

                                                              function foo() {
                                                              
                                                                  if (condition) {
                                                                      var fs = require("fs");
                                                                  }
                                                              }

                                                              Since require() does a synchronous load, it can cause performance problems when used in other locations.

                                                              Further, ES6 modules mandate that import and export statements can only occur in the top level of the module's body.

                                                              Rule Details

                                                              This rule requires all calls to require() to be at the top level of the module, similar to ES6 import and export statements, which also can occur only at the top level.

                                                              Examples of incorrect code for this rule:

                                                              /*eslint global-require: "error"*/
                                                              /*eslint-env es6*/
                                                              
                                                              // calling require() inside of a function is not allowed
                                                              function readFile(filename, callback) {
                                                                  var fs = require('fs');
                                                                  fs.readFile(filename, callback)
                                                              }
                                                              
                                                              // conditional requires like this are also not allowed
                                                              if (DEBUG) { require('debug'); }
                                                              
                                                              // a require() in a switch statement is also flagged
                                                              switch(x) { case '1': require('1'); break; }
                                                              
                                                              // you may not require() inside an arrow function body
                                                              var getModule = (name) => require(name);
                                                              
                                                              // you may not require() inside of a function body as well
                                                              function getModule(name) { return require(name); }
                                                              
                                                              // you may not require() inside of a try/catch block
                                                              try {
                                                                  require(unsafeModule);
                                                              } catch(e) {
                                                                  console.log(e);
                                                              }

                                                              Examples of correct code for this rule:

                                                              /*eslint global-require: "error"*/
                                                              
                                                              // all these variations of require() are ok
                                                              require('x');
                                                              var y = require('y');
                                                              var z;
                                                              z = require('z').initialize();
                                                              
                                                              // requiring a module and using it in a function is ok
                                                              var fs = require('fs');
                                                              function readFile(filename, callback) {
                                                                  fs.readFile(filename, callback)
                                                              }
                                                              
                                                              // you can use a ternary to determine which module to require
                                                              var logger = DEBUG ? require('dev-logger') : require('logger');
                                                              
                                                              // if you want you can require() at the end of your module
                                                              function doSomethingA() {}
                                                              function doSomethingB() {}
                                                              var x = require("x"),
                                                                  z = require("z");

                                                              When Not To Use It

                                                              If you have a module that must be initialized with information that comes from the file-system or if a module is only used in very rare situations and will cause significant overhead to load it may make sense to disable the rule. If you need to require() an optional dependency inside of a try/catch, you can disable this rule for just that dependency using the // eslint-disable-line global-require comment. Source: http://eslint.org/docs/rules/

                                                              Move the invocation into the parens that contain the function.
                                                              Open

                                                                      this.setup = (function() {

                                                              Require IIFEs to be Wrapped (wrap-iife)

                                                              You can immediately invoke function expressions, but not function declarations. A common technique to create an immediately-invoked function expression (IIFE) is to wrap a function declaration in parentheses. The opening parentheses causes the contained function to be parsed as an expression, rather than a declaration.

                                                              // function expression could be unwrapped
                                                              var x = function () { return { y: 1 };}();
                                                              
                                                              // function declaration must be wrapped
                                                              function () { /* side effects */ }(); // SyntaxError

                                                              Rule Details

                                                              This rule requires all immediately-invoked function expressions to be wrapped in parentheses.

                                                              Options

                                                              This rule has two options, a string option and an object option.

                                                              String option:

                                                              • "outside" enforces always wrapping the call expression. The default is "outside".
                                                              • "inside" enforces always wrapping the function expression.
                                                              • "any" enforces always wrapping, but allows either style.

                                                              Object option:

                                                              • "functionPrototypeMethods": true additionally enforces wrapping function expressions invoked using .call and .apply. The default is false.

                                                              outside

                                                              Examples of incorrect code for the default "outside" option:

                                                              /*eslint wrap-iife: ["error", "outside"]*/
                                                              
                                                              var x = function () { return { y: 1 };}(); // unwrapped
                                                              var x = (function () { return { y: 1 };})(); // wrapped function expression

                                                              Examples of correct code for the default "outside" option:

                                                              /*eslint wrap-iife: ["error", "outside"]*/
                                                              
                                                              var x = (function () { return { y: 1 };}()); // wrapped call expression

                                                              inside

                                                              Examples of incorrect code for the "inside" option:

                                                              /*eslint wrap-iife: ["error", "inside"]*/
                                                              
                                                              var x = function () { return { y: 1 };}(); // unwrapped
                                                              var x = (function () { return { y: 1 };}()); // wrapped call expression

                                                              Examples of correct code for the "inside" option:

                                                              /*eslint wrap-iife: ["error", "inside"]*/
                                                              
                                                              var x = (function () { return { y: 1 };})(); // wrapped function expression

                                                              any

                                                              Examples of incorrect code for the "any" option:

                                                              /*eslint wrap-iife: ["error", "any"]*/
                                                              
                                                              var x = function () { return { y: 1 };}(); // unwrapped

                                                              Examples of correct code for the "any" option:

                                                              /*eslint wrap-iife: ["error", "any"]*/
                                                              
                                                              var x = (function () { return { y: 1 };}()); // wrapped call expression
                                                              var x = (function () { return { y: 1 };})(); // wrapped function expression

                                                              functionPrototypeMethods

                                                              Examples of incorrect code for this rule with the "inside", { "functionPrototypeMethods": true } options:

                                                              /* eslint wrap-iife: [2, "inside", { functionPrototypeMethods: true }] */
                                                              
                                                              var x = function(){ foo(); }()
                                                              var x = (function(){ foo(); }())
                                                              var x = function(){ foo(); }.call(bar)
                                                              var x = (function(){ foo(); }.call(bar))

                                                              Examples of correct code for this rule with the "inside", { "functionPrototypeMethods": true } options:

                                                              /* eslint wrap-iife: [2, "inside", { functionPrototypeMethods: true }] */
                                                              
                                                              var x = (function(){ foo(); })()
                                                              var x = (function(){ foo(); }).call(bar)

                                                              Source: http://eslint.org/docs/rules/

                                                              Move the invocation into the parens that contain the function.
                                                              Open

                                                                      this.onKeyDown = (function() {

                                                              Require IIFEs to be Wrapped (wrap-iife)

                                                              You can immediately invoke function expressions, but not function declarations. A common technique to create an immediately-invoked function expression (IIFE) is to wrap a function declaration in parentheses. The opening parentheses causes the contained function to be parsed as an expression, rather than a declaration.

                                                              // function expression could be unwrapped
                                                              var x = function () { return { y: 1 };}();
                                                              
                                                              // function declaration must be wrapped
                                                              function () { /* side effects */ }(); // SyntaxError

                                                              Rule Details

                                                              This rule requires all immediately-invoked function expressions to be wrapped in parentheses.

                                                              Options

                                                              This rule has two options, a string option and an object option.

                                                              String option:

                                                              • "outside" enforces always wrapping the call expression. The default is "outside".
                                                              • "inside" enforces always wrapping the function expression.
                                                              • "any" enforces always wrapping, but allows either style.

                                                              Object option:

                                                              • "functionPrototypeMethods": true additionally enforces wrapping function expressions invoked using .call and .apply. The default is false.

                                                              outside

                                                              Examples of incorrect code for the default "outside" option:

                                                              /*eslint wrap-iife: ["error", "outside"]*/
                                                              
                                                              var x = function () { return { y: 1 };}(); // unwrapped
                                                              var x = (function () { return { y: 1 };})(); // wrapped function expression

                                                              Examples of correct code for the default "outside" option:

                                                              /*eslint wrap-iife: ["error", "outside"]*/
                                                              
                                                              var x = (function () { return { y: 1 };}()); // wrapped call expression

                                                              inside

                                                              Examples of incorrect code for the "inside" option:

                                                              /*eslint wrap-iife: ["error", "inside"]*/
                                                              
                                                              var x = function () { return { y: 1 };}(); // unwrapped
                                                              var x = (function () { return { y: 1 };}()); // wrapped call expression

                                                              Examples of correct code for the "inside" option:

                                                              /*eslint wrap-iife: ["error", "inside"]*/
                                                              
                                                              var x = (function () { return { y: 1 };})(); // wrapped function expression

                                                              any

                                                              Examples of incorrect code for the "any" option:

                                                              /*eslint wrap-iife: ["error", "any"]*/
                                                              
                                                              var x = function () { return { y: 1 };}(); // unwrapped

                                                              Examples of correct code for the "any" option:

                                                              /*eslint wrap-iife: ["error", "any"]*/
                                                              
                                                              var x = (function () { return { y: 1 };}()); // wrapped call expression
                                                              var x = (function () { return { y: 1 };})(); // wrapped function expression

                                                              functionPrototypeMethods

                                                              Examples of incorrect code for this rule with the "inside", { "functionPrototypeMethods": true } options:

                                                              /* eslint wrap-iife: [2, "inside", { functionPrototypeMethods: true }] */
                                                              
                                                              var x = function(){ foo(); }()
                                                              var x = (function(){ foo(); }())
                                                              var x = function(){ foo(); }.call(bar)
                                                              var x = (function(){ foo(); }.call(bar))

                                                              Examples of correct code for this rule with the "inside", { "functionPrototypeMethods": true } options:

                                                              /* eslint wrap-iife: [2, "inside", { functionPrototypeMethods: true }] */
                                                              
                                                              var x = (function(){ foo(); })()
                                                              var x = (function(){ foo(); }).call(bar)

                                                              Source: http://eslint.org/docs/rules/

                                                              Move the invocation into the parens that contain the function.
                                                              Open

                                                                      self.setup = (function() {

                                                              Require IIFEs to be Wrapped (wrap-iife)

                                                              You can immediately invoke function expressions, but not function declarations. A common technique to create an immediately-invoked function expression (IIFE) is to wrap a function declaration in parentheses. The opening parentheses causes the contained function to be parsed as an expression, rather than a declaration.

                                                              // function expression could be unwrapped
                                                              var x = function () { return { y: 1 };}();
                                                              
                                                              // function declaration must be wrapped
                                                              function () { /* side effects */ }(); // SyntaxError

                                                              Rule Details

                                                              This rule requires all immediately-invoked function expressions to be wrapped in parentheses.

                                                              Options

                                                              This rule has two options, a string option and an object option.

                                                              String option:

                                                              • "outside" enforces always wrapping the call expression. The default is "outside".
                                                              • "inside" enforces always wrapping the function expression.
                                                              • "any" enforces always wrapping, but allows either style.

                                                              Object option:

                                                              • "functionPrototypeMethods": true additionally enforces wrapping function expressions invoked using .call and .apply. The default is false.

                                                              outside

                                                              Examples of incorrect code for the default "outside" option:

                                                              /*eslint wrap-iife: ["error", "outside"]*/
                                                              
                                                              var x = function () { return { y: 1 };}(); // unwrapped
                                                              var x = (function () { return { y: 1 };})(); // wrapped function expression

                                                              Examples of correct code for the default "outside" option:

                                                              /*eslint wrap-iife: ["error", "outside"]*/
                                                              
                                                              var x = (function () { return { y: 1 };}()); // wrapped call expression

                                                              inside

                                                              Examples of incorrect code for the "inside" option:

                                                              /*eslint wrap-iife: ["error", "inside"]*/
                                                              
                                                              var x = function () { return { y: 1 };}(); // unwrapped
                                                              var x = (function () { return { y: 1 };}()); // wrapped call expression

                                                              Examples of correct code for the "inside" option:

                                                              /*eslint wrap-iife: ["error", "inside"]*/
                                                              
                                                              var x = (function () { return { y: 1 };})(); // wrapped function expression

                                                              any

                                                              Examples of incorrect code for the "any" option:

                                                              /*eslint wrap-iife: ["error", "any"]*/
                                                              
                                                              var x = function () { return { y: 1 };}(); // unwrapped

                                                              Examples of correct code for the "any" option:

                                                              /*eslint wrap-iife: ["error", "any"]*/
                                                              
                                                              var x = (function () { return { y: 1 };}()); // wrapped call expression
                                                              var x = (function () { return { y: 1 };})(); // wrapped function expression

                                                              functionPrototypeMethods

                                                              Examples of incorrect code for this rule with the "inside", { "functionPrototypeMethods": true } options:

                                                              /* eslint wrap-iife: [2, "inside", { functionPrototypeMethods: true }] */
                                                              
                                                              var x = function(){ foo(); }()
                                                              var x = (function(){ foo(); }())
                                                              var x = function(){ foo(); }.call(bar)
                                                              var x = (function(){ foo(); }.call(bar))

                                                              Examples of correct code for this rule with the "inside", { "functionPrototypeMethods": true } options:

                                                              /* eslint wrap-iife: [2, "inside", { functionPrototypeMethods: true }] */
                                                              
                                                              var x = (function(){ foo(); })()
                                                              var x = (function(){ foo(); }).call(bar)

                                                              Source: http://eslint.org/docs/rules/

                                                              Move the invocation into the parens that contain the function.
                                                              Open

                                                                      self.lock = (function() {

                                                              Require IIFEs to be Wrapped (wrap-iife)

                                                              You can immediately invoke function expressions, but not function declarations. A common technique to create an immediately-invoked function expression (IIFE) is to wrap a function declaration in parentheses. The opening parentheses causes the contained function to be parsed as an expression, rather than a declaration.

                                                              // function expression could be unwrapped
                                                              var x = function () { return { y: 1 };}();
                                                              
                                                              // function declaration must be wrapped
                                                              function () { /* side effects */ }(); // SyntaxError

                                                              Rule Details

                                                              This rule requires all immediately-invoked function expressions to be wrapped in parentheses.

                                                              Options

                                                              This rule has two options, a string option and an object option.

                                                              String option:

                                                              • "outside" enforces always wrapping the call expression. The default is "outside".
                                                              • "inside" enforces always wrapping the function expression.
                                                              • "any" enforces always wrapping, but allows either style.

                                                              Object option:

                                                              • "functionPrototypeMethods": true additionally enforces wrapping function expressions invoked using .call and .apply. The default is false.

                                                              outside

                                                              Examples of incorrect code for the default "outside" option:

                                                              /*eslint wrap-iife: ["error", "outside"]*/
                                                              
                                                              var x = function () { return { y: 1 };}(); // unwrapped
                                                              var x = (function () { return { y: 1 };})(); // wrapped function expression

                                                              Examples of correct code for the default "outside" option:

                                                              /*eslint wrap-iife: ["error", "outside"]*/
                                                              
                                                              var x = (function () { return { y: 1 };}()); // wrapped call expression

                                                              inside

                                                              Examples of incorrect code for the "inside" option:

                                                              /*eslint wrap-iife: ["error", "inside"]*/
                                                              
                                                              var x = function () { return { y: 1 };}(); // unwrapped
                                                              var x = (function () { return { y: 1 };}()); // wrapped call expression

                                                              Examples of correct code for the "inside" option:

                                                              /*eslint wrap-iife: ["error", "inside"]*/
                                                              
                                                              var x = (function () { return { y: 1 };})(); // wrapped function expression

                                                              any

                                                              Examples of incorrect code for the "any" option:

                                                              /*eslint wrap-iife: ["error", "any"]*/
                                                              
                                                              var x = function () { return { y: 1 };}(); // unwrapped

                                                              Examples of correct code for the "any" option:

                                                              /*eslint wrap-iife: ["error", "any"]*/
                                                              
                                                              var x = (function () { return { y: 1 };}()); // wrapped call expression
                                                              var x = (function () { return { y: 1 };})(); // wrapped function expression

                                                              functionPrototypeMethods

                                                              Examples of incorrect code for this rule with the "inside", { "functionPrototypeMethods": true } options:

                                                              /* eslint wrap-iife: [2, "inside", { functionPrototypeMethods: true }] */
                                                              
                                                              var x = function(){ foo(); }()
                                                              var x = (function(){ foo(); }())
                                                              var x = function(){ foo(); }.call(bar)
                                                              var x = (function(){ foo(); }.call(bar))

                                                              Examples of correct code for this rule with the "inside", { "functionPrototypeMethods": true } options:

                                                              /* eslint wrap-iife: [2, "inside", { functionPrototypeMethods: true }] */
                                                              
                                                              var x = (function(){ foo(); })()
                                                              var x = (function(){ foo(); }).call(bar)

                                                              Source: http://eslint.org/docs/rules/

                                                              Unexpected require().
                                                              Open

                                                                      module.exports = factory(require('jquery'), require('sifter'), require('microplugin'));

                                                              Enforce require() on the top-level module scope (global-require)

                                                              In Node.js, module dependencies are included using the require() function, such as:

                                                              var fs = require("fs");

                                                              While require() may be called anywhere in code, some style guides prescribe that it should be called only in the top level of a module to make it easier to identify dependencies. For instance, it's arguably harder to identify dependencies when they are deeply nested inside of functions and other statements:

                                                              function foo() {
                                                              
                                                                  if (condition) {
                                                                      var fs = require("fs");
                                                                  }
                                                              }

                                                              Since require() does a synchronous load, it can cause performance problems when used in other locations.

                                                              Further, ES6 modules mandate that import and export statements can only occur in the top level of the module's body.

                                                              Rule Details

                                                              This rule requires all calls to require() to be at the top level of the module, similar to ES6 import and export statements, which also can occur only at the top level.

                                                              Examples of incorrect code for this rule:

                                                              /*eslint global-require: "error"*/
                                                              /*eslint-env es6*/
                                                              
                                                              // calling require() inside of a function is not allowed
                                                              function readFile(filename, callback) {
                                                                  var fs = require('fs');
                                                                  fs.readFile(filename, callback)
                                                              }
                                                              
                                                              // conditional requires like this are also not allowed
                                                              if (DEBUG) { require('debug'); }
                                                              
                                                              // a require() in a switch statement is also flagged
                                                              switch(x) { case '1': require('1'); break; }
                                                              
                                                              // you may not require() inside an arrow function body
                                                              var getModule = (name) => require(name);
                                                              
                                                              // you may not require() inside of a function body as well
                                                              function getModule(name) { return require(name); }
                                                              
                                                              // you may not require() inside of a try/catch block
                                                              try {
                                                                  require(unsafeModule);
                                                              } catch(e) {
                                                                  console.log(e);
                                                              }

                                                              Examples of correct code for this rule:

                                                              /*eslint global-require: "error"*/
                                                              
                                                              // all these variations of require() are ok
                                                              require('x');
                                                              var y = require('y');
                                                              var z;
                                                              z = require('z').initialize();
                                                              
                                                              // requiring a module and using it in a function is ok
                                                              var fs = require('fs');
                                                              function readFile(filename, callback) {
                                                                  fs.readFile(filename, callback)
                                                              }
                                                              
                                                              // you can use a ternary to determine which module to require
                                                              var logger = DEBUG ? require('dev-logger') : require('logger');
                                                              
                                                              // if you want you can require() at the end of your module
                                                              function doSomethingA() {}
                                                              function doSomethingB() {}
                                                              var x = require("x"),
                                                                  z = require("z");

                                                              When Not To Use It

                                                              If you have a module that must be initialized with information that comes from the file-system or if a module is only used in very rare situations and will cause significant overhead to load it may make sense to disable the rule. If you need to require() an optional dependency inside of a try/catch, you can disable this rule for just that dependency using the // eslint-disable-line global-require comment. Source: http://eslint.org/docs/rules/

                                                              Unexpected require().
                                                              Open

                                                                      module.exports = factory(require('jquery'), require('sifter'), require('microplugin'));

                                                              Enforce require() on the top-level module scope (global-require)

                                                              In Node.js, module dependencies are included using the require() function, such as:

                                                              var fs = require("fs");

                                                              While require() may be called anywhere in code, some style guides prescribe that it should be called only in the top level of a module to make it easier to identify dependencies. For instance, it's arguably harder to identify dependencies when they are deeply nested inside of functions and other statements:

                                                              function foo() {
                                                              
                                                                  if (condition) {
                                                                      var fs = require("fs");
                                                                  }
                                                              }

                                                              Since require() does a synchronous load, it can cause performance problems when used in other locations.

                                                              Further, ES6 modules mandate that import and export statements can only occur in the top level of the module's body.

                                                              Rule Details

                                                              This rule requires all calls to require() to be at the top level of the module, similar to ES6 import and export statements, which also can occur only at the top level.

                                                              Examples of incorrect code for this rule:

                                                              /*eslint global-require: "error"*/
                                                              /*eslint-env es6*/
                                                              
                                                              // calling require() inside of a function is not allowed
                                                              function readFile(filename, callback) {
                                                                  var fs = require('fs');
                                                                  fs.readFile(filename, callback)
                                                              }
                                                              
                                                              // conditional requires like this are also not allowed
                                                              if (DEBUG) { require('debug'); }
                                                              
                                                              // a require() in a switch statement is also flagged
                                                              switch(x) { case '1': require('1'); break; }
                                                              
                                                              // you may not require() inside an arrow function body
                                                              var getModule = (name) => require(name);
                                                              
                                                              // you may not require() inside of a function body as well
                                                              function getModule(name) { return require(name); }
                                                              
                                                              // you may not require() inside of a try/catch block
                                                              try {
                                                                  require(unsafeModule);
                                                              } catch(e) {
                                                                  console.log(e);
                                                              }

                                                              Examples of correct code for this rule:

                                                              /*eslint global-require: "error"*/
                                                              
                                                              // all these variations of require() are ok
                                                              require('x');
                                                              var y = require('y');
                                                              var z;
                                                              z = require('z').initialize();
                                                              
                                                              // requiring a module and using it in a function is ok
                                                              var fs = require('fs');
                                                              function readFile(filename, callback) {
                                                                  fs.readFile(filename, callback)
                                                              }
                                                              
                                                              // you can use a ternary to determine which module to require
                                                              var logger = DEBUG ? require('dev-logger') : require('logger');
                                                              
                                                              // if you want you can require() at the end of your module
                                                              function doSomethingA() {}
                                                              function doSomethingB() {}
                                                              var x = require("x"),
                                                                  z = require("z");

                                                              When Not To Use It

                                                              If you have a module that must be initialized with information that comes from the file-system or if a module is only used in very rare situations and will cause significant overhead to load it may make sense to disable the rule. If you need to require() an optional dependency inside of a try/catch, you can disable this rule for just that dependency using the // eslint-disable-line global-require comment. Source: http://eslint.org/docs/rules/

                                                              Similar blocks of code found in 2 locations. Consider refactoring.
                                                              Open

                                                                      if (self.settings.options) {
                                                                          for (i = 0, n = self.settings.options.length; i < n; i++) {
                                                                              self.registerOption(self.settings.options[i]);
                                                                          }
                                                                          delete self.settings.options;
                                                              Severity: Major
                                                              Found in public/assets/js/core/selectize/selectize.js and 1 other location - About 3 hrs to fix
                                                              public/assets/js/core/selectize/selectize.js on lines 1121..1126

                                                              Duplicated Code

                                                              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                              Tuning

                                                              This issue has a mass of 95.

                                                              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                              Refactorings

                                                              Further Reading

                                                              Similar blocks of code found in 2 locations. Consider refactoring.
                                                              Open

                                                                      if (self.settings.optgroups) {
                                                                          for (i = 0, n = self.settings.optgroups.length; i < n; i++) {
                                                                              self.registerOptionGroup(self.settings.optgroups[i]);
                                                                          }
                                                                          delete self.settings.optgroups;
                                                              Severity: Major
                                                              Found in public/assets/js/core/selectize/selectize.js and 1 other location - About 3 hrs to fix
                                                              public/assets/js/core/selectize/selectize.js on lines 1113..1118

                                                              Duplicated Code

                                                              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                              Tuning

                                                              This issue has a mass of 95.

                                                              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                              Refactorings

                                                              Further Reading

                                                              Similar blocks of code found in 2 locations. Consider refactoring.
                                                              Open

                                                              (function(root, factory) {
                                                                  if (typeof define === 'function' && define.amd) {
                                                                      define('sifter', factory);
                                                                  } else if (typeof exports === 'object') {
                                                                      module.exports = factory();
                                                              Severity: Major
                                                              Found in public/assets/js/core/selectize/selectize.js and 1 other location - About 2 hrs to fix
                                                              public/assets/js/core/selectize/selectize.js on lines 490..608

                                                              Duplicated Code

                                                              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                              Tuning

                                                              This issue has a mass of 84.

                                                              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                              Refactorings

                                                              Further Reading

                                                              Similar blocks of code found in 2 locations. Consider refactoring.
                                                              Open

                                                              (function(root, factory) {
                                                                  if (typeof define === 'function' && define.amd) {
                                                                      define('microplugin', factory);
                                                                  } else if (typeof exports === 'object') {
                                                                      module.exports = factory();
                                                              Severity: Major
                                                              Found in public/assets/js/core/selectize/selectize.js and 1 other location - About 2 hrs to fix
                                                              public/assets/js/core/selectize/selectize.js on lines 17..470

                                                              Duplicated Code

                                                              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                              Tuning

                                                              This issue has a mass of 84.

                                                              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                              Refactorings

                                                              Further Reading

                                                              Similar blocks of code found in 2 locations. Consider refactoring.
                                                              Open

                                                                      self.lock = (function() {
                                                                          var original = self.lock;
                                                                          return function() {
                                                                              var sortable = self.$control.data('sortable');
                                                                              if (sortable) sortable.disable();
                                                              Severity: Major
                                                              Found in public/assets/js/core/selectize/selectize.js and 1 other location - About 2 hrs to fix
                                                              public/assets/js/core/selectize/selectize.js on lines 3418..3425

                                                              Duplicated Code

                                                              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                              Tuning

                                                              This issue has a mass of 83.

                                                              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                              Refactorings

                                                              Further Reading

                                                              Similar blocks of code found in 2 locations. Consider refactoring.
                                                              Open

                                                                      self.unlock = (function() {
                                                                          var original = self.unlock;
                                                                          return function() {
                                                                              var sortable = self.$control.data('sortable');
                                                                              if (sortable) sortable.enable();
                                                              Severity: Major
                                                              Found in public/assets/js/core/selectize/selectize.js and 1 other location - About 2 hrs to fix
                                                              public/assets/js/core/selectize/selectize.js on lines 3409..3416

                                                              Duplicated Code

                                                              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                              Tuning

                                                              This issue has a mass of 83.

                                                              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                              Refactorings

                                                              Further Reading

                                                              Similar blocks of code found in 2 locations. Consider refactoring.
                                                              Open

                                                                              } else if (y < scroll) {
                                                                                  self.$dropdown_content.stop().animate({scrollTop: scroll_top}, animate ? self.settings.scrollDuration : 0);
                                                                              }
                                                              Severity: Minor
                                                              Found in public/assets/js/core/selectize/selectize.js and 1 other location - About 35 mins to fix
                                                              public/assets/js/core/selectize/selectize.js on lines 1924..1928

                                                              Duplicated Code

                                                              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                              Tuning

                                                              This issue has a mass of 47.

                                                              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                              Refactorings

                                                              Further Reading

                                                              Similar blocks of code found in 2 locations. Consider refactoring.
                                                              Open

                                                                              if (y + height_item > height_menu + scroll) {
                                                                                  self.$dropdown_content.stop().animate({scrollTop: scroll_bottom}, animate ? self.settings.scrollDuration : 0);
                                                                              } else if (y < scroll) {
                                                                                  self.$dropdown_content.stop().animate({scrollTop: scroll_top}, animate ? self.settings.scrollDuration : 0);
                                                                              }
                                                              Severity: Minor
                                                              Found in public/assets/js/core/selectize/selectize.js and 1 other location - About 35 mins to fix
                                                              public/assets/js/core/selectize/selectize.js on lines 1926..1928

                                                              Duplicated Code

                                                              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                              Tuning

                                                              This issue has a mass of 47.

                                                              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                              Refactorings

                                                              Further Reading

                                                              There are no issues that match your filters.

                                                              Category
                                                              Status