-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
New error: Literal values in right-hand side of instanceof
#2777
Closed
jugglinmike opened this issue
Nov 21, 2015
· 0 comments
· Fixed by chauncey-garrett/dotfiles#15 · May be fixed by ajesse11x/cjdns#1
Closed
New error: Literal values in right-hand side of instanceof
#2777
jugglinmike opened this issue
Nov 21, 2015
· 0 comments
· Fixed by chauncey-garrett/dotfiles#15 · May be fixed by ajesse11x/cjdns#1
Labels
Comments
ehjay
added a commit
to ehjay/jshint
that referenced
this issue
May 18, 2016
This patch adds a new parse error that is used when a literal or function declaration is found on the right-hand side of the `instanceof` infix operator. Specifically, it checks for number, string, object, array and regular expression literals, as well as the null and undefined keywords and function declarations. The following generate errors: x instanceof 0; x instanceof ''; x instanceof null; x instanceof undefined; x instanceof {}; x instanceof []; x instanceof /./; x instanceof function() {}; x instanceof function MyUnusableFunction() {}; But this is okay: /x/ instanceof /x/.constructor; as per jshintGH-2773 References: Closes jshintGH-2777
ehjay
pushed a commit
to ehjay/jshint
that referenced
this issue
May 24, 2016
This patch adds a new error that is used when a literal is found on the right-hand side of the `instanceof` infix operator. A warning is used when a function declaration is found. Literals generate errors: x instanceof 0; x instanceof ''; x instanceof null; x instanceof undefined; x instanceof {}; x instanceof []; x instanceof /./; x instanceof ``; Function declarations generate warnings: x instanceof function() {}; x instanceof function MyUnusableFunction() {}; But this is okay: x instanceof /x/.constructor; x instanceof "".constructor; as per jshintGH-2773 References: Closes jshintGH-2777
ehjay
pushed a commit
to ehjay/jshint
that referenced
this issue
May 29, 2016
This patch adds a new error that is used when a literal is found on the right-hand side of the `instanceof` infix operator. A warning is used when a function declaration is found. Literals generate errors: x instanceof 0; x instanceof ''; x instanceof null; x instanceof undefined; x instanceof {}; x instanceof []; x instanceof /./; x instanceof ``; Function declarations generate warnings: x instanceof function() {}; x instanceof function MyUnusableFunction() {}; But this is okay: x instanceof /x/.constructor; x instanceof "".constructor; as per jshintGH-2773 References: Closes jshintGH-2777
ehjay
pushed a commit
to ehjay/jshint
that referenced
this issue
Jun 4, 2016
This patch adds a new error that is used when a literal is found on the right-hand side of the `instanceof` infix operator. A warning is used when a function declaration is found. Literals generate errors: x instanceof 0; x instanceof ''; x instanceof null; x instanceof undefined; x instanceof {}; x instanceof []; x instanceof /./; x instanceof ``; Function declarations generate warnings: x instanceof function() {}; x instanceof function MyUnusableFunction() {}; But this is okay: x instanceof /x/.constructor; x instanceof "".constructor; as per jshintGH-2773 References: Closes jshintGH-2777
ehjay
pushed a commit
to ehjay/jshint
that referenced
this issue
Jun 5, 2016
jugglinmike
pushed a commit
to jugglinmike/jshint
that referenced
this issue
Sep 4, 2016
This patch adds a new error that is used when a literal is found on the right-hand side of the `instanceof` infix operator. A warning is used when a function declaration is found. Literals generate errors: x instanceof 0; x instanceof ''; x instanceof null; x instanceof undefined; x instanceof {}; x instanceof []; x instanceof /./; x instanceof ``; Function declarations generate warnings: x instanceof function() {}; x instanceof function MyUnusableFunction() {}; But this is okay: x instanceof /x/.constructor; x instanceof "".constructor; as per jshintGH-2773 References: Closes jshintGH-2777
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
According to ES5 11.8.6:
We can't completely enforce this statically, but there are some forms which we can reject
outright. The following
instanceof
applications should trigger an error:And it probably wouldn't hurt to warn on the following cases, too:
The text was updated successfully, but these errors were encountered: