New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
jshint considers user delete() function as keyword, not function, yields 'function not used' for argument #1881
Comments
REPL says:
|
Changing |
The problem is a little more subtle than the bug report suggests. For example: /* jshint unused: true */
/* jshint unused: true */
var a = {};
function before() {}
a.delete(before);
a.delete(after);
function after() {} Results in:
Given that there is no warning issued for the variable /* jshint unused: true */
var a = {};
function deleteBefore() {}
function typeofBefore() {}
function voidBefore() {}
function newBefore() {}
a.delete(deleteBefore);
a.typeof(typeofBefore);
a.void(voidBefore);
a.new(newBefore);
a.delete(deleteAfter);
a.typeof(typeofAfter);
a.void(voidAfter);
a.new(newAfter);
function deleteAfter() {}
function typeofAfter() {}
function voidAfter() {}
function newAfter() {} issues:
So this is going to be a fun one. |
...I guess it's not surprising that |
I have a solution for this, but it is dependent on gh-1903. |
Operators `typeof` and `delete` both accept null references, so JSHint should not warn when their sole operand is a undefined variable, nor should that identifier be included in the `implieds` array of the generated report. A runtime error will occur if the operand is an expression containing the undefined identifier, so a warning should be issued in this case. This patch also addresses an existing bug where property identifiers with values "typeof" or "delete" were incorrectly interpreted as unary operators when marking variables as unused. Resolves jshintgh-1881
Operators `typeof` and `delete` both accept null references, so JSHint should not warn when their sole operand is a undefined variable, nor should that identifier be included in the `implieds` array of the generated report. A runtime error will occur if the operand is an expression containing the undefined identifier, so a warning should be issued in this case. This patch also addresses an existing bug where property identifiers with values "typeof" or "delete" were incorrectly interpreted as unary operators when marking variables as unused. Resolves jshintgh-1881
Operators `typeof` and `delete` both accept null references, so JSHint should not warn when their sole operand is a undefined variable, nor should that identifier be included in the `implieds` array of the generated report. A runtime error will occur if the operand is an expression containing the undefined identifier, so a warning should be issued in this case. This patch also addresses an existing bug where property identifiers with values "typeof" or "delete" were incorrectly interpreted as unary operators when marking variables as unused. Resolves jshintgh-1881
Consider this code(you can try validate it on jshint.com)
JSHint yields "deleteContact" is defined, but never used.
This is wrong, deleteContact is actually used in delete().
Possibly, jshint assumes contactsRouter.delete() is keyword 'delete', not user function.
Possibly related: #1562
The text was updated successfully, but these errors were encountered: