Skip to content

Commit

Permalink
Issue #444 Rule typecheck-object is failed for simple comparing wit…
Browse files Browse the repository at this point in the history
…h 'object'
  • Loading branch information
EmmanuelDemey committed Mar 18, 2017
1 parent b561aa4 commit 092ce8c
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions test/typecheck-array.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ eslintTester.run('typecheck-array', rule, {
].concat(commonFalsePositives),
invalid: [
{code: 'Object.prototype.toString.call([]) === "[object Array]"', errors: [{message: 'You should use the angular.isArray method'}]},
{code: 'function name(){return variable === "[object Array]";}', errors: [{message: 'You should use the angular.isArray method'}]},
{code: '"[object Array]" === Object.prototype.toString.call([])', errors: [{message: 'You should use the angular.isArray method'}]},
{code: 'variable === "[object Array]"', errors: [{message: 'You should use the angular.isArray method'}]},
{code: '"[object Array]" === variable', errors: [{message: 'You should use the angular.isArray method'}]},
Expand Down
1 change: 1 addition & 0 deletions test/typecheck-date.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ eslintTester.run('typecheck-date', rule, {
].concat(commonFalsePositives),
invalid: [
{code: 'Object.prototype.toString.call(variable) === "[object Date]"', errors: [{message: 'You should use the angular.isDate method'}]},
{code: 'function name(){return variable === "[object Date]";}', errors: [{message: 'You should use the angular.isDate method'}]},
{code: '"[object Date]" === Object.prototype.toString.call(variable)', errors: [{message: 'You should use the angular.isDate method'}]},
{code: 'variable === "[object Date]"', errors: [{message: 'You should use the angular.isDate method'}]},
{code: '"[object Date]" === variable', errors: [{message: 'You should use the angular.isDate method'}]},
Expand Down
1 change: 1 addition & 0 deletions test/typecheck-function.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ eslintTester.run('typecheck-function', rule, {
].concat(commonFalsePositives),
invalid: [
{code: 'typeof variable === "function"', errors: [{message: 'You should use the angular.isFunction method'}]},
{code: 'function name(){return variable === "function";}', errors: [{message: 'You should use the angular.isFunction method'}]},
{code: '"function" === typeof variable', errors: [{message: 'You should use the angular.isFunction method'}]},
{code: 'variable === "function"', errors: [{message: 'You should use the angular.isFunction method'}]},
{code: '"function" === variable', errors: [{message: 'You should use the angular.isFunction method'}]},
Expand Down
1 change: 1 addition & 0 deletions test/typecheck-number.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ eslintTester.run('typecheck-number', rule, {
].concat(commonFalsePositives),
invalid: [
{code: 'Object.prototype.toString.call(variable) === "[object Number]"', errors: [{message: 'You should use the angular.isNumber method'}]},
{code: 'function name(){return variable === "[object Number]";}', errors: [{message: 'You should use the angular.isNumber method'}]},
{code: '"[object Number]" === Object.prototype.toString.call(variable)', errors: [{message: 'You should use the angular.isNumber method'}]},
{code: 'variable === "[object Number]"', errors: [{message: 'You should use the angular.isNumber method'}]},
{code: '"[object Number]" === variable', errors: [{message: 'You should use the angular.isNumber method'}]},
Expand Down
1 change: 1 addition & 0 deletions test/typecheck-object.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ eslintTester.run('typecheck-object', rule, {
].concat(commonFalsePositives),
invalid: [
{code: 'typeof variable === "object"', errors: [{message: 'You should use the angular.isObject method'}]},
{code: 'function name(){return variable === "object";}', errors: [{message: 'You should use the angular.isObject method'}]},

This comment has been minimized.

Copy link
@Valdermeyder

Valdermeyder Jun 23, 2017

As for me, this test (and other added in the same commit) shouldn't show errors. Looks like issue #444 was wrongly understood.
I think it is no sense to show error when typeof is not used before the variable name. In the project where I work, we have our own business "types" which are described by some object's property. And because of this rule we need put /eslint angular/typecheck-object: 0/ in a lot of places

{code: '"object" === typeof variable', errors: [{message: 'You should use the angular.isObject method'}]},
{code: 'variable === "object"', errors: [{message: 'You should use the angular.isObject method'}]},
{code: '"object" === variable', errors: [{message: 'You should use the angular.isObject method'}]},
Expand Down
1 change: 1 addition & 0 deletions test/typecheck-string.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ eslintTester.run('typecheck-string', rule, {
].concat(commonFalsePositives),
invalid: [
{code: 'Object.prototype.toString.call(variable) === "[object String]"', errors: [{message: 'You should use the angular.isString method'}]},
{code: 'function name(){return variable === "[object String]";}', errors: [{message: 'You should use the angular.isString method'}]},
{code: '"[object String]" === Object.prototype.toString.call(variable)', errors: [{message: 'You should use the angular.isString method'}]},
{code: 'variable === "[object String]"', errors: [{message: 'You should use the angular.isString method'}]},
{code: '"[object String]" === variable', errors: [{message: 'You should use the angular.isString method'}]},
Expand Down

0 comments on commit 092ce8c

Please sign in to comment.