Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign upEnforce comparing `typeof` expressions against string literals #629
Comments
feross
added
the
enhancement
label
Sep 16, 2016
This comment has been minimized.
This comment has been minimized.
|
Essentially no ecosystem impact:
|
feross
added this to the
standard v9 milestone
Sep 16, 2016
This comment has been minimized.
This comment has been minimized.
|
|
This comment has been minimized.
This comment has been minimized.
|
Make it so |
This comment has been minimized.
This comment has been minimized.
|
Why not standard <9 too? |
This comment has been minimized.
This comment has been minimized.
|
@dcousens I fear users will get fatigue from too many releases of Also, frankly, it's a lot of work to do a release. It takes at least an hour to properly test everything, write the changelog, update the various packages, etc. I'd prefer to hold back most of these rule changes until |
This comment has been minimized.
This comment has been minimized.
|
@feross I feel like we don't thank you enough. Thanks so much for the work, totally understandable. Looking forward to |
This comment has been minimized.
This comment has been minimized.
|
@dcousens Thanks. I appreciate your contributions, too! It's really nice to not be in this all alone. |
feross
added a commit
to standard/eslint-config-standard
that referenced
this issue
Feb 9, 2017
This comment has been minimized.
This comment has been minimized.
|
This will be part of standard v9. Only one repo was impacted and it was doing this: const OBJ = 'object'
module.exports = function merge (a, b, checked) {
if (checked || typeof a === OBJ) {Can't see a reason that's preferable to |
feross commentedSep 16, 2016
•
edited
I propose adding
{ "requireStringLiterals": true }to thevalid-typeofrule that we already enforce.This requires
typeofexpressions to only be compared to string literals, and disallows comparisons to any other value.Examples of incorrect code:
Examples of correct code:
http://eslint.org/docs/rules/valid-typeof