Skip to content

Commit

Permalink
Update: support "bigint" in valid-typeof rule
Browse files Browse the repository at this point in the history
BigInt just moved to Stage 4, so add support for it to
the valid-typeof rule.
  • Loading branch information
cjihrig committed Jun 4, 2019
1 parent cb1922b commit cefbb2d
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion docs/rules/valid-typeof.md
@@ -1,6 +1,6 @@
# enforce comparing `typeof` expressions against valid strings (valid-typeof)

For a vast majority of use cases, the result of the `typeof` operator is one of the following string literals: `"undefined"`, `"object"`, `"boolean"`, `"number"`, `"string"`, `"function"` and `"symbol"`. It is usually a typing mistake to compare the result of a `typeof` operator to other string literals.
For a vast majority of use cases, the result of the `typeof` operator is one of the following string literals: `"undefined"`, `"object"`, `"boolean"`, `"bigint"`, `"number"`, `"string"`, `"function"` and `"symbol"`. It is usually a typing mistake to compare the result of a `typeof` operator to other string literals.

## Rule Details

Expand Down
2 changes: 1 addition & 1 deletion lib/rules/valid-typeof.js
Expand Up @@ -39,7 +39,7 @@ module.exports = {

create(context) {

const VALID_TYPES = ["symbol", "undefined", "object", "boolean", "number", "string", "function"],
const VALID_TYPES = ["symbol", "undefined", "object", "boolean", "bigint", "number", "string", "function"],
OPERATORS = ["==", "===", "!=", "!=="];

const requireStringLiterals = context.options[0] && context.options[0].requireStringLiterals;
Expand Down
1 change: 1 addition & 0 deletions tests/lib/rules/valid-typeof.js
Expand Up @@ -25,6 +25,7 @@ ruleTester.run("valid-typeof", rule, {
"typeof foo === 'function'",
"typeof foo === 'undefined'",
"typeof foo === 'boolean'",
"typeof foo === 'bigint'",
"typeof foo === 'number'",
"'string' === typeof foo",
"'object' === typeof foo",
Expand Down

0 comments on commit cefbb2d

Please sign in to comment.