Strict equality should not be used for two values with different types

  • COMPARE_INCOMPATIBLE_TYPE_STRICTLY
  • Error
  • Medium
  • No tags

This rule applies when two values with different types are compared with strict equality.

Strict equality is always false for different types, so this comparison is not likely to be a programmer's intent.

Currently, this rule is applied for the return value of built-in API.

Noncompliant Code Example

var x = 10 / 3;
x.toFixed(1) === 3.3; // COMPARE_INCOMPATIBLE_TYPE_STRICTLY alarm because 'toFixed' function returns string type.

Compliant Code Example

var x = 10 / 3;
x.toFixed(1) === "3.3";

Version

This rule was introduced in DeepScan 1.0.0-alpha.