Skip to content
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

RegExp after instanceof #2773

Closed
nicolo-ribaudo opened this issue Nov 19, 2015 · 1 comment · Fixed by chauncey-garrett/dotfiles#15 · May be fixed by ajesse11x/cjdns#1
Closed

RegExp after instanceof #2773

nicolo-ribaudo opened this issue Nov 19, 2015 · 1 comment · Fixed by chauncey-garrett/dotfiles#15 · May be fixed by ajesse11x/cjdns#1

Comments

@nicolo-ribaudo
Copy link
Contributor

A stupid example:

var a = new Boolean() instanceof /a/.test("a").constructor;

JSHint doesn't like the / after instanceof, even if this is valid js.

@jugglinmike jugglinmike added the P4 label Nov 21, 2015
@jugglinmike
Copy link
Member

Sounds good to me! See also gh-2777.

nicolo-ribaudo added a commit to nicolo-ribaudo/jshint that referenced this issue Dec 5, 2015
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
jugglinmike pushed a commit that referenced this issue Jun 11, 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 GH-2773

References:

    Closes GH-2777
jugglinmike pushed a commit to jugglinmike/jshint that referenced this issue Sep 4, 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
Projects
None yet
2 participants