Built-in API should be called with arguments of correct types

  • MISMATCHED_TYPE_OF_ARG
  • Error
  • High, Medium
  • No tags

This rule applies when built-in API is called with arguments of wrong types.

Because built-in has the specification for its arguments, arguments can cause error or unintended behavior if the types of arguments are wrong.

Noncompliant Code Example

var arr = Array.from(items);
var pos_of_three = arr.findIndex(3); // MISMATCHED_TYPE_OF_ARG alarm because 'Array.prototype.findIndex' takes a function as an argument.

Compliant Code Example

var arr = Array.from(items);
var pos_of_three = arr.findIndex(item => item === 3);

Version

This rule was introduced in DeepScan 1.4.0-beta.

See