yiisoft/yii2

View on GitHub
framework/assets/yii.validation.js

Summary

Maintainability
F
6 days
Test Coverage

Function validation has a Cognitive Complexity of 228 (exceeds 5 allowed). Consider refactoring.
Open

yii.validation = (function ($) {
    var pub = {
        isEmpty: function (value) {
            return value === null || value === undefined || ($.isArray(value) && value.length === 0) || value === '';
        },
Severity: Minor
Found in framework/assets/yii.validation.js - About 4 days to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Method 'compare' has a complexity of 16.
Open

        compare: function (value, messages, options, $form) {
Severity: Minor
Found in framework/assets/yii.validation.js by eslint

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 'ip' has a complexity of 14.
Open

        ip: function (value, messages, options) {
Severity: Minor
Found in framework/assets/yii.validation.js by eslint

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 'validateFile' has a complexity of 10.
Open

    function validateFile(file, messages, options)
Severity: Minor
Found in framework/assets/yii.validation.js by eslint

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 'required' has a complexity of 9.
Open

        required: function (value, messages, options) {
Severity: Minor
Found in framework/assets/yii.validation.js by eslint

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 'email' has a complexity of 8.
Open

        email: function (value, messages, options) {
Severity: Minor
Found in framework/assets/yii.validation.js by eslint

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 'captcha' has a complexity of 7.
Open

        captcha: function (value, messages, options) {
Severity: Minor
Found in framework/assets/yii.validation.js by eslint

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 'getUploadedFiles' has a complexity of 7.
Open

    function getUploadedFiles(attribute, messages, options)
Severity: Minor
Found in framework/assets/yii.validation.js by eslint

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 'url' has a complexity of 7.
Open

        url: function (value, messages, options) {
Severity: Minor
Found in framework/assets/yii.validation.js by eslint

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 'trim' has a complexity of 7.
Open

        trim: function ($form, attribute, options, value) {
Severity: Minor
Found in framework/assets/yii.validation.js by eslint

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 validateImage has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

        validateImage: function (file, messages, options, deferred, fileReader, image) {
Severity: Minor
Found in framework/assets/yii.validation.js - About 45 mins to fix

    Avoid too many return statements within this function.
    Open

                return [];
    Severity: Major
    Found in framework/assets/yii.validation.js - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

              return files;
      Severity: Major
      Found in framework/assets/yii.validation.js - About 30 mins to fix

        Expected '===' and instead saw '=='.
        Open

                        var isString = typeof value == 'string' || value instanceof String;
        Severity: Minor
        Found in framework/assets/yii.validation.js by eslint

        Require === and !== (eqeqeq)

        It is considered good practice to use the type-safe equality operators === and !== instead of their regular counterparts == and !=.

        The reason for this is that == and != do type coercion which follows the rather obscure Abstract Equality Comparison Algorithm. For instance, the following statements are all considered true:

        • [] == false
        • [] == ![]
        • 3 == "03"

        If one of those occurs in an innocent-looking statement such as a == b the actual problem is very difficult to spot.

        Rule Details

        This rule is aimed at eliminating the type-unsafe equality operators.

        Examples of incorrect code for this rule:

        /*eslint eqeqeq: "error"*/
        
        if (x == 42) { }
        
        if ("" == text) { }
        
        if (obj.getStuff() != undefined) { }

        The --fix option on the command line automatically fixes some problems reported by this rule. A problem is only fixed if one of the operands is a typeof expression, or if both operands are literals with the same type.

        Options

        always

        The "always" option (default) enforces the use of === and !== in every situation (except when you opt-in to more specific handling of null [see below]).

        Examples of incorrect code for the "always" option:

        /*eslint eqeqeq: ["error", "always"]*/
        
        a == b
        foo == true
        bananas != 1
        value == undefined
        typeof foo == 'undefined'
        'hello' != 'world'
        0 == 0
        true == true
        foo == null

        Examples of correct code for the "always" option:

        /*eslint eqeqeq: ["error", "always"]*/
        
        a === b
        foo === true
        bananas !== 1
        value === undefined
        typeof foo === 'undefined'
        'hello' !== 'world'
        0 === 0
        true === true
        foo === null

        This rule optionally takes a second argument, which should be an object with the following supported properties:

        • "null": Customize how this rule treats null literals. Possible values:
          • always (default) - Always use === or !==.
          • never - Never use === or !== with null.
          • ignore - Do not apply this rule to null.

        smart

        The "smart" option enforces the use of === and !== except for these cases:

        • Comparing two literal values
        • Evaluating the value of typeof
        • Comparing against null

        Examples of incorrect code for the "smart" option:

        /*eslint eqeqeq: ["error", "smart"]*/
        
        // comparing two variables requires ===
        a == b
        
        // only one side is a literal
        foo == true
        bananas != 1
        
        // comparing to undefined requires ===
        value == undefined

        Examples of correct code for the "smart" option:

        /*eslint eqeqeq: ["error", "smart"]*/
        
        typeof foo == 'undefined'
        'hello' != 'world'
        0 == 0
        true == true
        foo == null

        allow-null

        Deprecated: Instead of using this option use "always" and pass a "null" option property with value "ignore". This will tell eslint to always enforce strict equality except when comparing with the null literal.

        ["error", "always", {"null": "ignore"}]

        When Not To Use It

        If you don't want to enforce a style for using equality operators, then it's safe to disable this rule. Source: http://eslint.org/docs/rules/

        Expected '===' and instead saw '=='.
        Open

                    } else if (!options.strict && value == options.requiredValue || options.strict && value === options.requiredValue) {
        Severity: Minor
        Found in framework/assets/yii.validation.js by eslint

        Require === and !== (eqeqeq)

        It is considered good practice to use the type-safe equality operators === and !== instead of their regular counterparts == and !=.

        The reason for this is that == and != do type coercion which follows the rather obscure Abstract Equality Comparison Algorithm. For instance, the following statements are all considered true:

        • [] == false
        • [] == ![]
        • 3 == "03"

        If one of those occurs in an innocent-looking statement such as a == b the actual problem is very difficult to spot.

        Rule Details

        This rule is aimed at eliminating the type-unsafe equality operators.

        Examples of incorrect code for this rule:

        /*eslint eqeqeq: "error"*/
        
        if (x == 42) { }
        
        if ("" == text) { }
        
        if (obj.getStuff() != undefined) { }

        The --fix option on the command line automatically fixes some problems reported by this rule. A problem is only fixed if one of the operands is a typeof expression, or if both operands are literals with the same type.

        Options

        always

        The "always" option (default) enforces the use of === and !== in every situation (except when you opt-in to more specific handling of null [see below]).

        Examples of incorrect code for the "always" option:

        /*eslint eqeqeq: ["error", "always"]*/
        
        a == b
        foo == true
        bananas != 1
        value == undefined
        typeof foo == 'undefined'
        'hello' != 'world'
        0 == 0
        true == true
        foo == null

        Examples of correct code for the "always" option:

        /*eslint eqeqeq: ["error", "always"]*/
        
        a === b
        foo === true
        bananas !== 1
        value === undefined
        typeof foo === 'undefined'
        'hello' !== 'world'
        0 === 0
        true === true
        foo === null

        This rule optionally takes a second argument, which should be an object with the following supported properties:

        • "null": Customize how this rule treats null literals. Possible values:
          • always (default) - Always use === or !==.
          • never - Never use === or !== with null.
          • ignore - Do not apply this rule to null.

        smart

        The "smart" option enforces the use of === and !== except for these cases:

        • Comparing two literal values
        • Evaluating the value of typeof
        • Comparing against null

        Examples of incorrect code for the "smart" option:

        /*eslint eqeqeq: ["error", "smart"]*/
        
        // comparing two variables requires ===
        a == b
        
        // only one side is a literal
        foo == true
        bananas != 1
        
        // comparing to undefined requires ===
        value == undefined

        Examples of correct code for the "smart" option:

        /*eslint eqeqeq: ["error", "smart"]*/
        
        typeof foo == 'undefined'
        'hello' != 'world'
        0 == 0
        true == true
        foo == null

        allow-null

        Deprecated: Instead of using this option use "always" and pass a "null" option property with value "ignore". This will tell eslint to always enforce strict equality except when comparing with the null literal.

        ["error", "always", {"null": "ignore"}]

        When Not To Use It

        If you don't want to enforce a style for using equality operators, then it's safe to disable this rule. Source: http://eslint.org/docs/rules/

        Expected '===' and instead saw '=='.
        Open

                    var valid = !options.strict && (value == options.trueValue || value == options.falseValue)
        Severity: Minor
        Found in framework/assets/yii.validation.js by eslint

        Require === and !== (eqeqeq)

        It is considered good practice to use the type-safe equality operators === and !== instead of their regular counterparts == and !=.

        The reason for this is that == and != do type coercion which follows the rather obscure Abstract Equality Comparison Algorithm. For instance, the following statements are all considered true:

        • [] == false
        • [] == ![]
        • 3 == "03"

        If one of those occurs in an innocent-looking statement such as a == b the actual problem is very difficult to spot.

        Rule Details

        This rule is aimed at eliminating the type-unsafe equality operators.

        Examples of incorrect code for this rule:

        /*eslint eqeqeq: "error"*/
        
        if (x == 42) { }
        
        if ("" == text) { }
        
        if (obj.getStuff() != undefined) { }

        The --fix option on the command line automatically fixes some problems reported by this rule. A problem is only fixed if one of the operands is a typeof expression, or if both operands are literals with the same type.

        Options

        always

        The "always" option (default) enforces the use of === and !== in every situation (except when you opt-in to more specific handling of null [see below]).

        Examples of incorrect code for the "always" option:

        /*eslint eqeqeq: ["error", "always"]*/
        
        a == b
        foo == true
        bananas != 1
        value == undefined
        typeof foo == 'undefined'
        'hello' != 'world'
        0 == 0
        true == true
        foo == null

        Examples of correct code for the "always" option:

        /*eslint eqeqeq: ["error", "always"]*/
        
        a === b
        foo === true
        bananas !== 1
        value === undefined
        typeof foo === 'undefined'
        'hello' !== 'world'
        0 === 0
        true === true
        foo === null

        This rule optionally takes a second argument, which should be an object with the following supported properties:

        • "null": Customize how this rule treats null literals. Possible values:
          • always (default) - Always use === or !==.
          • never - Never use === or !== with null.
          • ignore - Do not apply this rule to null.

        smart

        The "smart" option enforces the use of === and !== except for these cases:

        • Comparing two literal values
        • Evaluating the value of typeof
        • Comparing against null

        Examples of incorrect code for the "smart" option:

        /*eslint eqeqeq: ["error", "smart"]*/
        
        // comparing two variables requires ===
        a == b
        
        // only one side is a literal
        foo == true
        bananas != 1
        
        // comparing to undefined requires ===
        value == undefined

        Examples of correct code for the "smart" option:

        /*eslint eqeqeq: ["error", "smart"]*/
        
        typeof foo == 'undefined'
        'hello' != 'world'
        0 == 0
        true == true
        foo == null

        allow-null

        Deprecated: Instead of using this option use "always" and pass a "null" option property with value "ignore". This will tell eslint to always enforce strict equality except when comparing with the null literal.

        ["error", "always", {"null": "ignore"}]

        When Not To Use It

        If you don't want to enforce a style for using equality operators, then it's safe to disable this rule. Source: http://eslint.org/docs/rules/

        Use ‘===’ to compare with ‘null’.
        Open

                    hash = hash == null ? options.hash : hash[options.caseSensitive ? 0 : 1];
        Severity: Minor
        Found in framework/assets/yii.validation.js by eslint

        Disallow Null Comparisons (no-eq-null)

        Comparing to null without a type-checking operator (== or !=), can have unintended results as the comparison will evaluate to true when comparing to not just a null, but also an undefined value.

        if (foo == null) {
          bar();
        }

        Rule Details

        The no-eq-null rule aims reduce potential bug and unwanted behavior by ensuring that comparisons to null only match null, and not also undefined. As such it will flag comparisons to null when using == and !=.

        Examples of incorrect code for this rule:

        /*eslint no-eq-null: "error"*/
        
        if (foo == null) {
          bar();
        }
        
        while (qux != null) {
          baz();
        }

        Examples of correct code for this rule:

        /*eslint no-eq-null: "error"*/
        
        if (foo === null) {
          bar();
        }
        
        while (qux !== null) {
          baz();
        }

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

        Expected '===' and instead saw '=='.
        Open

                    hash = hash == null ? options.hash : hash[options.caseSensitive ? 0 : 1];
        Severity: Minor
        Found in framework/assets/yii.validation.js by eslint

        Require === and !== (eqeqeq)

        It is considered good practice to use the type-safe equality operators === and !== instead of their regular counterparts == and !=.

        The reason for this is that == and != do type coercion which follows the rather obscure Abstract Equality Comparison Algorithm. For instance, the following statements are all considered true:

        • [] == false
        • [] == ![]
        • 3 == "03"

        If one of those occurs in an innocent-looking statement such as a == b the actual problem is very difficult to spot.

        Rule Details

        This rule is aimed at eliminating the type-unsafe equality operators.

        Examples of incorrect code for this rule:

        /*eslint eqeqeq: "error"*/
        
        if (x == 42) { }
        
        if ("" == text) { }
        
        if (obj.getStuff() != undefined) { }

        The --fix option on the command line automatically fixes some problems reported by this rule. A problem is only fixed if one of the operands is a typeof expression, or if both operands are literals with the same type.

        Options

        always

        The "always" option (default) enforces the use of === and !== in every situation (except when you opt-in to more specific handling of null [see below]).

        Examples of incorrect code for the "always" option:

        /*eslint eqeqeq: ["error", "always"]*/
        
        a == b
        foo == true
        bananas != 1
        value == undefined
        typeof foo == 'undefined'
        'hello' != 'world'
        0 == 0
        true == true
        foo == null

        Examples of correct code for the "always" option:

        /*eslint eqeqeq: ["error", "always"]*/
        
        a === b
        foo === true
        bananas !== 1
        value === undefined
        typeof foo === 'undefined'
        'hello' !== 'world'
        0 === 0
        true === true
        foo === null

        This rule optionally takes a second argument, which should be an object with the following supported properties:

        • "null": Customize how this rule treats null literals. Possible values:
          • always (default) - Always use === or !==.
          • never - Never use === or !== with null.
          • ignore - Do not apply this rule to null.

        smart

        The "smart" option enforces the use of === and !== except for these cases:

        • Comparing two literal values
        • Evaluating the value of typeof
        • Comparing against null

        Examples of incorrect code for the "smart" option:

        /*eslint eqeqeq: ["error", "smart"]*/
        
        // comparing two variables requires ===
        a == b
        
        // only one side is a literal
        foo == true
        bananas != 1
        
        // comparing to undefined requires ===
        value == undefined

        Examples of correct code for the "smart" option:

        /*eslint eqeqeq: ["error", "smart"]*/
        
        typeof foo == 'undefined'
        'hello' != 'world'
        0 == 0
        true == true
        foo == null

        allow-null

        Deprecated: Instead of using this option use "always" and pass a "null" option property with value "ignore". This will tell eslint to always enforce strict equality except when comparing with the null literal.

        ["error", "always", {"null": "ignore"}]

        When Not To Use It

        If you don't want to enforce a style for using equality operators, then it's safe to disable this rule. Source: http://eslint.org/docs/rules/

        Do not use String as a constructor.
        Open

                value = new String(value);
        Severity: Minor
        Found in framework/assets/yii.validation.js by eslint

        Disallow Primitive Wrapper Instances (no-new-wrappers)

        There are three primitive types in JavaScript that have wrapper objects: string, number, and boolean. These are represented by the constructors String, Number, and Boolean, respectively. The primitive wrapper types are used whenever one of these primitive values is read, providing them with object-like capabilities such as methods. Behind the scenes, an object of the associated wrapper type is created and then destroyed, which is why you can call methods on primitive values, such as:

        var text = "Hello world".substring(2);

        Behind the scenes in this example, a String object is constructed. The substring() method exists on String.prototype and so is accessible to the string instance.

        It's also possible to manually create a new wrapper instance:

        var stringObject = new String("Hello world");
        var numberObject = new Number(33);
        var booleanObject = new Boolean(false);

        Although possible, there aren't any good reasons to use these primitive wrappers as constructors. They tend to confuse other developers more than anything else because they seem like they should act as primitives, but they do not. For example:

        var stringObject = new String("Hello world");
        console.log(typeof stringObject);       // "object"
        
        var text = "Hello world";
        console.log(typeof text);               // "string"
        
        var booleanObject = new Boolean(false);
        if (booleanObject) {    // all objects are truthy!
            console.log("This executes");
        }

        The first problem is that primitive wrapper objects are, in fact, objects. That means typeof will return "object" instead of "string", "number", or "boolean". The second problem comes with boolean objects. Every object is truthy, that means an instance of Boolean always resolves to true even when its actual value is false.

        For these reasons, it's considered a best practice to avoid using primitive wrapper types with new.

        Rule Details

        This rule aims to eliminate the use of String, Number, and Boolean with the new operator. As such, it warns whenever it sees new String, new Number, or new Boolean.

        Examples of incorrect code for this rule:

        /*eslint no-new-wrappers: "error"*/
        
        var stringObject = new String("Hello world");
        var numberObject = new Number(33);
        var booleanObject = new Boolean(false);
        
        var stringObject = new String;
        var numberObject = new Number;
        var booleanObject = new Boolean;

        Examples of correct code for this rule:

        /*eslint no-new-wrappers: "error"*/
        
        var text = String(someValue);
        var num = Number(someValue);
        
        var object = new MyString();

        When Not To Use It

        If you want to allow the use of primitive wrapper objects, then you can safely disable this rule.

        Further Reading

        Related Rules

        Expected '!==' and instead saw '!='.
        Open

                    if (options.is !== undefined && value.length != options.is) {
        Severity: Minor
        Found in framework/assets/yii.validation.js by eslint

        Require === and !== (eqeqeq)

        It is considered good practice to use the type-safe equality operators === and !== instead of their regular counterparts == and !=.

        The reason for this is that == and != do type coercion which follows the rather obscure Abstract Equality Comparison Algorithm. For instance, the following statements are all considered true:

        • [] == false
        • [] == ![]
        • 3 == "03"

        If one of those occurs in an innocent-looking statement such as a == b the actual problem is very difficult to spot.

        Rule Details

        This rule is aimed at eliminating the type-unsafe equality operators.

        Examples of incorrect code for this rule:

        /*eslint eqeqeq: "error"*/
        
        if (x == 42) { }
        
        if ("" == text) { }
        
        if (obj.getStuff() != undefined) { }

        The --fix option on the command line automatically fixes some problems reported by this rule. A problem is only fixed if one of the operands is a typeof expression, or if both operands are literals with the same type.

        Options

        always

        The "always" option (default) enforces the use of === and !== in every situation (except when you opt-in to more specific handling of null [see below]).

        Examples of incorrect code for the "always" option:

        /*eslint eqeqeq: ["error", "always"]*/
        
        a == b
        foo == true
        bananas != 1
        value == undefined
        typeof foo == 'undefined'
        'hello' != 'world'
        0 == 0
        true == true
        foo == null

        Examples of correct code for the "always" option:

        /*eslint eqeqeq: ["error", "always"]*/
        
        a === b
        foo === true
        bananas !== 1
        value === undefined
        typeof foo === 'undefined'
        'hello' !== 'world'
        0 === 0
        true === true
        foo === null

        This rule optionally takes a second argument, which should be an object with the following supported properties:

        • "null": Customize how this rule treats null literals. Possible values:
          • always (default) - Always use === or !==.
          • never - Never use === or !== with null.
          • ignore - Do not apply this rule to null.

        smart

        The "smart" option enforces the use of === and !== except for these cases:

        • Comparing two literal values
        • Evaluating the value of typeof
        • Comparing against null

        Examples of incorrect code for the "smart" option:

        /*eslint eqeqeq: ["error", "smart"]*/
        
        // comparing two variables requires ===
        a == b
        
        // only one side is a literal
        foo == true
        bananas != 1
        
        // comparing to undefined requires ===
        value == undefined

        Examples of correct code for the "smart" option:

        /*eslint eqeqeq: ["error", "smart"]*/
        
        typeof foo == 'undefined'
        'hello' != 'world'
        0 == 0
        true == true
        foo == null

        allow-null

        Deprecated: Instead of using this option use "always" and pass a "null" option property with value "ignore". This will tell eslint to always enforce strict equality except when comparing with the null literal.

        ["error", "always", {"null": "ignore"}]

        When Not To Use It

        If you don't want to enforce a style for using equality operators, then it's safe to disable this rule. Source: http://eslint.org/docs/rules/

        Expected '===' and instead saw '=='.
        Open

                    if (ipVersion == 6) {
        Severity: Minor
        Found in framework/assets/yii.validation.js by eslint

        Require === and !== (eqeqeq)

        It is considered good practice to use the type-safe equality operators === and !== instead of their regular counterparts == and !=.

        The reason for this is that == and != do type coercion which follows the rather obscure Abstract Equality Comparison Algorithm. For instance, the following statements are all considered true:

        • [] == false
        • [] == ![]
        • 3 == "03"

        If one of those occurs in an innocent-looking statement such as a == b the actual problem is very difficult to spot.

        Rule Details

        This rule is aimed at eliminating the type-unsafe equality operators.

        Examples of incorrect code for this rule:

        /*eslint eqeqeq: "error"*/
        
        if (x == 42) { }
        
        if ("" == text) { }
        
        if (obj.getStuff() != undefined) { }

        The --fix option on the command line automatically fixes some problems reported by this rule. A problem is only fixed if one of the operands is a typeof expression, or if both operands are literals with the same type.

        Options

        always

        The "always" option (default) enforces the use of === and !== in every situation (except when you opt-in to more specific handling of null [see below]).

        Examples of incorrect code for the "always" option:

        /*eslint eqeqeq: ["error", "always"]*/
        
        a == b
        foo == true
        bananas != 1
        value == undefined
        typeof foo == 'undefined'
        'hello' != 'world'
        0 == 0
        true == true
        foo == null

        Examples of correct code for the "always" option:

        /*eslint eqeqeq: ["error", "always"]*/
        
        a === b
        foo === true
        bananas !== 1
        value === undefined
        typeof foo === 'undefined'
        'hello' !== 'world'
        0 === 0
        true === true
        foo === null

        This rule optionally takes a second argument, which should be an object with the following supported properties:

        • "null": Customize how this rule treats null literals. Possible values:
          • always (default) - Always use === or !==.
          • never - Never use === or !== with null.
          • ignore - Do not apply this rule to null.

        smart

        The "smart" option enforces the use of === and !== except for these cases:

        • Comparing two literal values
        • Evaluating the value of typeof
        • Comparing against null

        Examples of incorrect code for the "smart" option:

        /*eslint eqeqeq: ["error", "smart"]*/
        
        // comparing two variables requires ===
        a == b
        
        // only one side is a literal
        foo == true
        bananas != 1
        
        // comparing to undefined requires ===
        value == undefined

        Examples of correct code for the "smart" option:

        /*eslint eqeqeq: ["error", "smart"]*/
        
        typeof foo == 'undefined'
        'hello' != 'world'
        0 == 0
        true == true
        foo == null

        allow-null

        Deprecated: Instead of using this option use "always" and pass a "null" option property with value "ignore". This will tell eslint to always enforce strict equality except when comparing with the null literal.

        ["error", "always", {"null": "ignore"}]

        When Not To Use It

        If you don't want to enforce a style for using equality operators, then it's safe to disable this rule. Source: http://eslint.org/docs/rules/

        Expected '===' and instead saw '=='.
        Open

                    var valid = !options.strict && (value == options.trueValue || value == options.falseValue)
        Severity: Minor
        Found in framework/assets/yii.validation.js by eslint

        Require === and !== (eqeqeq)

        It is considered good practice to use the type-safe equality operators === and !== instead of their regular counterparts == and !=.

        The reason for this is that == and != do type coercion which follows the rather obscure Abstract Equality Comparison Algorithm. For instance, the following statements are all considered true:

        • [] == false
        • [] == ![]
        • 3 == "03"

        If one of those occurs in an innocent-looking statement such as a == b the actual problem is very difficult to spot.

        Rule Details

        This rule is aimed at eliminating the type-unsafe equality operators.

        Examples of incorrect code for this rule:

        /*eslint eqeqeq: "error"*/
        
        if (x == 42) { }
        
        if ("" == text) { }
        
        if (obj.getStuff() != undefined) { }

        The --fix option on the command line automatically fixes some problems reported by this rule. A problem is only fixed if one of the operands is a typeof expression, or if both operands are literals with the same type.

        Options

        always

        The "always" option (default) enforces the use of === and !== in every situation (except when you opt-in to more specific handling of null [see below]).

        Examples of incorrect code for the "always" option:

        /*eslint eqeqeq: ["error", "always"]*/
        
        a == b
        foo == true
        bananas != 1
        value == undefined
        typeof foo == 'undefined'
        'hello' != 'world'
        0 == 0
        true == true
        foo == null

        Examples of correct code for the "always" option:

        /*eslint eqeqeq: ["error", "always"]*/
        
        a === b
        foo === true
        bananas !== 1
        value === undefined
        typeof foo === 'undefined'
        'hello' !== 'world'
        0 === 0
        true === true
        foo === null

        This rule optionally takes a second argument, which should be an object with the following supported properties:

        • "null": Customize how this rule treats null literals. Possible values:
          • always (default) - Always use === or !==.
          • never - Never use === or !== with null.
          • ignore - Do not apply this rule to null.

        smart

        The "smart" option enforces the use of === and !== except for these cases:

        • Comparing two literal values
        • Evaluating the value of typeof
        • Comparing against null

        Examples of incorrect code for the "smart" option:

        /*eslint eqeqeq: ["error", "smart"]*/
        
        // comparing two variables requires ===
        a == b
        
        // only one side is a literal
        foo == true
        bananas != 1
        
        // comparing to undefined requires ===
        value == undefined

        Examples of correct code for the "smart" option:

        /*eslint eqeqeq: ["error", "smart"]*/
        
        typeof foo == 'undefined'
        'hello' != 'world'
        0 == 0
        true == true
        foo == null

        allow-null

        Deprecated: Instead of using this option use "always" and pass a "null" option property with value "ignore". This will tell eslint to always enforce strict equality except when comparing with the null literal.

        ["error", "always", {"null": "ignore"}]

        When Not To Use It

        If you don't want to enforce a style for using equality operators, then it's safe to disable this rule. Source: http://eslint.org/docs/rules/

        Expected '===' and instead saw '=='.
        Open

                        if ($.inArray(v, options.range) == -1) {
        Severity: Minor
        Found in framework/assets/yii.validation.js by eslint

        Require === and !== (eqeqeq)

        It is considered good practice to use the type-safe equality operators === and !== instead of their regular counterparts == and !=.

        The reason for this is that == and != do type coercion which follows the rather obscure Abstract Equality Comparison Algorithm. For instance, the following statements are all considered true:

        • [] == false
        • [] == ![]
        • 3 == "03"

        If one of those occurs in an innocent-looking statement such as a == b the actual problem is very difficult to spot.

        Rule Details

        This rule is aimed at eliminating the type-unsafe equality operators.

        Examples of incorrect code for this rule:

        /*eslint eqeqeq: "error"*/
        
        if (x == 42) { }
        
        if ("" == text) { }
        
        if (obj.getStuff() != undefined) { }

        The --fix option on the command line automatically fixes some problems reported by this rule. A problem is only fixed if one of the operands is a typeof expression, or if both operands are literals with the same type.

        Options

        always

        The "always" option (default) enforces the use of === and !== in every situation (except when you opt-in to more specific handling of null [see below]).

        Examples of incorrect code for the "always" option:

        /*eslint eqeqeq: ["error", "always"]*/
        
        a == b
        foo == true
        bananas != 1
        value == undefined
        typeof foo == 'undefined'
        'hello' != 'world'
        0 == 0
        true == true
        foo == null

        Examples of correct code for the "always" option:

        /*eslint eqeqeq: ["error", "always"]*/
        
        a === b
        foo === true
        bananas !== 1
        value === undefined
        typeof foo === 'undefined'
        'hello' !== 'world'
        0 === 0
        true === true
        foo === null

        This rule optionally takes a second argument, which should be an object with the following supported properties:

        • "null": Customize how this rule treats null literals. Possible values:
          • always (default) - Always use === or !==.
          • never - Never use === or !== with null.
          • ignore - Do not apply this rule to null.

        smart

        The "smart" option enforces the use of === and !== except for these cases:

        • Comparing two literal values
        • Evaluating the value of typeof
        • Comparing against null

        Examples of incorrect code for the "smart" option:

        /*eslint eqeqeq: ["error", "smart"]*/
        
        // comparing two variables requires ===
        a == b
        
        // only one side is a literal
        foo == true
        bananas != 1
        
        // comparing to undefined requires ===
        value == undefined

        Examples of correct code for the "smart" option:

        /*eslint eqeqeq: ["error", "smart"]*/
        
        typeof foo == 'undefined'
        'hello' != 'world'
        0 == 0
        true == true
        foo == null

        allow-null

        Deprecated: Instead of using this option use "always" and pass a "null" option property with value "ignore". This will tell eslint to always enforce strict equality except when comparing with the null literal.

        ["error", "always", {"null": "ignore"}]

        When Not To Use It

        If you don't want to enforce a style for using equality operators, then it's safe to disable this rule. Source: http://eslint.org/docs/rules/

        Expected '===' and instead saw '=='.
        Open

                            valid = value == compareValue;
        Severity: Minor
        Found in framework/assets/yii.validation.js by eslint

        Require === and !== (eqeqeq)

        It is considered good practice to use the type-safe equality operators === and !== instead of their regular counterparts == and !=.

        The reason for this is that == and != do type coercion which follows the rather obscure Abstract Equality Comparison Algorithm. For instance, the following statements are all considered true:

        • [] == false
        • [] == ![]
        • 3 == "03"

        If one of those occurs in an innocent-looking statement such as a == b the actual problem is very difficult to spot.

        Rule Details

        This rule is aimed at eliminating the type-unsafe equality operators.

        Examples of incorrect code for this rule:

        /*eslint eqeqeq: "error"*/
        
        if (x == 42) { }
        
        if ("" == text) { }
        
        if (obj.getStuff() != undefined) { }

        The --fix option on the command line automatically fixes some problems reported by this rule. A problem is only fixed if one of the operands is a typeof expression, or if both operands are literals with the same type.

        Options

        always

        The "always" option (default) enforces the use of === and !== in every situation (except when you opt-in to more specific handling of null [see below]).

        Examples of incorrect code for the "always" option:

        /*eslint eqeqeq: ["error", "always"]*/
        
        a == b
        foo == true
        bananas != 1
        value == undefined
        typeof foo == 'undefined'
        'hello' != 'world'
        0 == 0
        true == true
        foo == null

        Examples of correct code for the "always" option:

        /*eslint eqeqeq: ["error", "always"]*/
        
        a === b
        foo === true
        bananas !== 1
        value === undefined
        typeof foo === 'undefined'
        'hello' !== 'world'
        0 === 0
        true === true
        foo === null

        This rule optionally takes a second argument, which should be an object with the following supported properties:

        • "null": Customize how this rule treats null literals. Possible values:
          • always (default) - Always use === or !==.
          • never - Never use === or !== with null.
          • ignore - Do not apply this rule to null.

        smart

        The "smart" option enforces the use of === and !== except for these cases:

        • Comparing two literal values
        • Evaluating the value of typeof
        • Comparing against null

        Examples of incorrect code for the "smart" option:

        /*eslint eqeqeq: ["error", "smart"]*/
        
        // comparing two variables requires ===
        a == b
        
        // only one side is a literal
        foo == true
        bananas != 1
        
        // comparing to undefined requires ===
        value == undefined

        Examples of correct code for the "smart" option:

        /*eslint eqeqeq: ["error", "smart"]*/
        
        typeof foo == 'undefined'
        'hello' != 'world'
        0 == 0
        true == true
        foo == null

        allow-null

        Deprecated: Instead of using this option use "always" and pass a "null" option property with value "ignore". This will tell eslint to always enforce strict equality except when comparing with the null literal.

        ["error", "always", {"null": "ignore"}]

        When Not To Use It

        If you don't want to enforce a style for using equality operators, then it's safe to disable this rule. Source: http://eslint.org/docs/rules/

        Expected '!==' and instead saw '!='.
        Open

                    if (h != hash) {
        Severity: Minor
        Found in framework/assets/yii.validation.js by eslint

        Require === and !== (eqeqeq)

        It is considered good practice to use the type-safe equality operators === and !== instead of their regular counterparts == and !=.

        The reason for this is that == and != do type coercion which follows the rather obscure Abstract Equality Comparison Algorithm. For instance, the following statements are all considered true:

        • [] == false
        • [] == ![]
        • 3 == "03"

        If one of those occurs in an innocent-looking statement such as a == b the actual problem is very difficult to spot.

        Rule Details

        This rule is aimed at eliminating the type-unsafe equality operators.

        Examples of incorrect code for this rule:

        /*eslint eqeqeq: "error"*/
        
        if (x == 42) { }
        
        if ("" == text) { }
        
        if (obj.getStuff() != undefined) { }

        The --fix option on the command line automatically fixes some problems reported by this rule. A problem is only fixed if one of the operands is a typeof expression, or if both operands are literals with the same type.

        Options

        always

        The "always" option (default) enforces the use of === and !== in every situation (except when you opt-in to more specific handling of null [see below]).

        Examples of incorrect code for the "always" option:

        /*eslint eqeqeq: ["error", "always"]*/
        
        a == b
        foo == true
        bananas != 1
        value == undefined
        typeof foo == 'undefined'
        'hello' != 'world'
        0 == 0
        true == true
        foo == null

        Examples of correct code for the "always" option:

        /*eslint eqeqeq: ["error", "always"]*/
        
        a === b
        foo === true
        bananas !== 1
        value === undefined
        typeof foo === 'undefined'
        'hello' !== 'world'
        0 === 0
        true === true
        foo === null

        This rule optionally takes a second argument, which should be an object with the following supported properties:

        • "null": Customize how this rule treats null literals. Possible values:
          • always (default) - Always use === or !==.
          • never - Never use === or !== with null.
          • ignore - Do not apply this rule to null.

        smart

        The "smart" option enforces the use of === and !== except for these cases:

        • Comparing two literal values
        • Evaluating the value of typeof
        • Comparing against null

        Examples of incorrect code for the "smart" option:

        /*eslint eqeqeq: ["error", "smart"]*/
        
        // comparing two variables requires ===
        a == b
        
        // only one side is a literal
        foo == true
        bananas != 1
        
        // comparing to undefined requires ===
        value == undefined

        Examples of correct code for the "smart" option:

        /*eslint eqeqeq: ["error", "smart"]*/
        
        typeof foo == 'undefined'
        'hello' != 'world'
        0 == 0
        true == true
        foo == null

        allow-null

        Deprecated: Instead of using this option use "always" and pass a "null" option property with value "ignore". This will tell eslint to always enforce strict equality except when comparing with the null literal.

        ["error", "always", {"null": "ignore"}]

        When Not To Use It

        If you don't want to enforce a style for using equality operators, then it's safe to disable this rule. Source: http://eslint.org/docs/rules/

        Expected '!==' and instead saw '!='.
        Open

                            valid = value != compareValue;
        Severity: Minor
        Found in framework/assets/yii.validation.js by eslint

        Require === and !== (eqeqeq)

        It is considered good practice to use the type-safe equality operators === and !== instead of their regular counterparts == and !=.

        The reason for this is that == and != do type coercion which follows the rather obscure Abstract Equality Comparison Algorithm. For instance, the following statements are all considered true:

        • [] == false
        • [] == ![]
        • 3 == "03"

        If one of those occurs in an innocent-looking statement such as a == b the actual problem is very difficult to spot.

        Rule Details

        This rule is aimed at eliminating the type-unsafe equality operators.

        Examples of incorrect code for this rule:

        /*eslint eqeqeq: "error"*/
        
        if (x == 42) { }
        
        if ("" == text) { }
        
        if (obj.getStuff() != undefined) { }

        The --fix option on the command line automatically fixes some problems reported by this rule. A problem is only fixed if one of the operands is a typeof expression, or if both operands are literals with the same type.

        Options

        always

        The "always" option (default) enforces the use of === and !== in every situation (except when you opt-in to more specific handling of null [see below]).

        Examples of incorrect code for the "always" option:

        /*eslint eqeqeq: ["error", "always"]*/
        
        a == b
        foo == true
        bananas != 1
        value == undefined
        typeof foo == 'undefined'
        'hello' != 'world'
        0 == 0
        true == true
        foo == null

        Examples of correct code for the "always" option:

        /*eslint eqeqeq: ["error", "always"]*/
        
        a === b
        foo === true
        bananas !== 1
        value === undefined
        typeof foo === 'undefined'
        'hello' !== 'world'
        0 === 0
        true === true
        foo === null

        This rule optionally takes a second argument, which should be an object with the following supported properties:

        • "null": Customize how this rule treats null literals. Possible values:
          • always (default) - Always use === or !==.
          • never - Never use === or !== with null.
          • ignore - Do not apply this rule to null.

        smart

        The "smart" option enforces the use of === and !== except for these cases:

        • Comparing two literal values
        • Evaluating the value of typeof
        • Comparing against null

        Examples of incorrect code for the "smart" option:

        /*eslint eqeqeq: ["error", "smart"]*/
        
        // comparing two variables requires ===
        a == b
        
        // only one side is a literal
        foo == true
        bananas != 1
        
        // comparing to undefined requires ===
        value == undefined

        Examples of correct code for the "smart" option:

        /*eslint eqeqeq: ["error", "smart"]*/
        
        typeof foo == 'undefined'
        'hello' != 'world'
        0 == 0
        true == true
        foo == null

        allow-null

        Deprecated: Instead of using this option use "always" and pass a "null" option property with value "ignore". This will tell eslint to always enforce strict equality except when comparing with the null literal.

        ["error", "always", {"null": "ignore"}]

        When Not To Use It

        If you don't want to enforce a style for using equality operators, then it's safe to disable this rule. Source: http://eslint.org/docs/rules/

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

        yii.validation = (function ($) {
        Severity: Minor
        Found in framework/assets/yii.validation.js by eslint

        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/

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

                    if (ipVersion == 6) {
                        if (!(new RegExp(options.ipv6Pattern)).test(value)) {
                            pub.addMessage(messages, options.messages.message, value);
                        }
                        if (!options.ipv6) {
        Severity: Major
        Found in framework/assets/yii.validation.js and 1 other location - About 2 hrs to fix
        framework/assets/yii.validation.js on lines 371..378

        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 (!(new RegExp(options.ipv4Pattern)).test(value)) {
                            pub.addMessage(messages, options.messages.message, value);
                        }
                        if (!options.ipv4) {
        Severity: Major
        Found in framework/assets/yii.validation.js and 1 other location - About 2 hrs to fix
        framework/assets/yii.validation.js on lines 364..371

        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 6 locations. Consider refactoring.
        Open

                if (options.minWidth && image.width < options.minWidth) {
                    messages.push(options.underWidth.replace(/\{file\}/g, file.name));
                }
        Severity: Major
        Found in framework/assets/yii.validation.js and 5 other locations - About 1 hr to fix
        framework/assets/yii.validation.js on lines 444..446
        framework/assets/yii.validation.js on lines 448..450
        framework/assets/yii.validation.js on lines 470..472
        framework/assets/yii.validation.js on lines 474..476
        framework/assets/yii.validation.js on lines 478..480

        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 55.

        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 6 locations. Consider refactoring.
        Open

                if (options.minHeight && image.height < options.minHeight) {
                    messages.push(options.underHeight.replace(/\{file\}/g, file.name));
                }
        Severity: Major
        Found in framework/assets/yii.validation.js and 5 other locations - About 1 hr to fix
        framework/assets/yii.validation.js on lines 444..446
        framework/assets/yii.validation.js on lines 448..450
        framework/assets/yii.validation.js on lines 466..468
        framework/assets/yii.validation.js on lines 470..472
        framework/assets/yii.validation.js on lines 478..480

        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 55.

        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 6 locations. Consider refactoring.
        Open

                if (options.maxWidth && image.width > options.maxWidth) {
                    messages.push(options.overWidth.replace(/\{file\}/g, file.name));
                }
        Severity: Major
        Found in framework/assets/yii.validation.js and 5 other locations - About 1 hr to fix
        framework/assets/yii.validation.js on lines 444..446
        framework/assets/yii.validation.js on lines 448..450
        framework/assets/yii.validation.js on lines 466..468
        framework/assets/yii.validation.js on lines 474..476
        framework/assets/yii.validation.js on lines 478..480

        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 55.

        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 6 locations. Consider refactoring.
        Open

                if (options.maxHeight && image.height > options.maxHeight) {
                    messages.push(options.overHeight.replace(/\{file\}/g, file.name));
                }
        Severity: Major
        Found in framework/assets/yii.validation.js and 5 other locations - About 1 hr to fix
        framework/assets/yii.validation.js on lines 444..446
        framework/assets/yii.validation.js on lines 448..450
        framework/assets/yii.validation.js on lines 466..468
        framework/assets/yii.validation.js on lines 470..472
        framework/assets/yii.validation.js on lines 474..476

        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 55.

        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 6 locations. Consider refactoring.
        Open

                if (options.minSize && options.minSize > file.size) {
                    messages.push(options.tooSmall.replace(/\{file\}/g, file.name));
                }
        Severity: Major
        Found in framework/assets/yii.validation.js and 5 other locations - About 1 hr to fix
        framework/assets/yii.validation.js on lines 444..446
        framework/assets/yii.validation.js on lines 466..468
        framework/assets/yii.validation.js on lines 470..472
        framework/assets/yii.validation.js on lines 474..476
        framework/assets/yii.validation.js on lines 478..480

        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 55.

        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 6 locations. Consider refactoring.
        Open

                if (options.maxSize && options.maxSize < file.size) {
                    messages.push(options.tooBig.replace(/\{file\}/g, file.name));
                }
        Severity: Major
        Found in framework/assets/yii.validation.js and 5 other locations - About 1 hr to fix
        framework/assets/yii.validation.js on lines 448..450
        framework/assets/yii.validation.js on lines 466..468
        framework/assets/yii.validation.js on lines 470..472
        framework/assets/yii.validation.js on lines 474..476
        framework/assets/yii.validation.js on lines 478..480

        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 55.

        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 (options.min !== undefined && value.length < options.min) {
                        pub.addMessage(messages, options.tooShort, value);
                    }
        Severity: Minor
        Found in framework/assets/yii.validation.js and 1 other location - About 40 mins to fix
        framework/assets/yii.validation.js on lines 69..71

        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 48.

        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 (options.max !== undefined && value.length > options.max) {
                        pub.addMessage(messages, options.tooLong, value);
                    }
        Severity: Minor
        Found in framework/assets/yii.validation.js and 1 other location - About 40 mins to fix
        framework/assets/yii.validation.js on lines 66..68

        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 48.

        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 3 locations. Consider refactoring.
        Open

                    if (options.negation === false && negation !== null) {
                        pub.addMessage(messages, options.messages.message, value);
                        return;
                    }
        Severity: Minor
        Found in framework/assets/yii.validation.js and 2 other locations - About 30 mins to fix
        framework/assets/yii.validation.js on lines 350..353
        framework/assets/yii.validation.js on lines 354..357

        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 45.

        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 3 locations. Consider refactoring.
        Open

                    if (options.subnet === true && cidr === null) {
                        pub.addMessage(messages, options.messages.noSubnet, value);
                        return;
                    }
        Severity: Minor
        Found in framework/assets/yii.validation.js and 2 other locations - About 30 mins to fix
        framework/assets/yii.validation.js on lines 354..357
        framework/assets/yii.validation.js on lines 358..361

        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 45.

        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 3 locations. Consider refactoring.
        Open

                    if (options.subnet === false && cidr !== null) {
                        pub.addMessage(messages, options.messages.hasSubnet, value);
                        return;
                    }
        Severity: Minor
        Found in framework/assets/yii.validation.js and 2 other locations - About 30 mins to fix
        framework/assets/yii.validation.js on lines 350..353
        framework/assets/yii.validation.js on lines 358..361

        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 45.

        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