typecheck-string - use angular.isString instead of typeof comparisons

February 26, 2018 ยท View on GitHub

You should use the angular.isString method instead of the default JavaScript implementation (typeof "" === "[object String]").

Rule based on Angular 1.x

Examples

The following patterns are considered problems;

/*eslint angular/typecheck-string: 2*/

// invalid
typeof someString === 'string' // error: You should use the angular.isString method

The following patterns are not considered problems;

/*eslint angular/typecheck-string: 2*/

// valid
angular.isString(someString);

Version

This rule was introduced in eslint-plugin-angular 0.1.0