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

docs: update valid-typeof rule #18001

Merged
merged 1 commit into from Jan 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 8 additions & 6 deletions docs/src/rules/valid-typeof.md
Expand Up @@ -15,12 +15,6 @@ For a vast majority of use cases, the result of the `typeof` operator is one of

This rule enforces comparing `typeof` expressions to valid string literals.

## Options

This rule has an object option:

* `"requireStringLiterals": true` requires `typeof` expressions to only be compared to string literals or other `typeof` expressions, and disallows comparisons to any other value.

Examples of **incorrect** code for this rule:

::: incorrect
Expand Down Expand Up @@ -51,6 +45,14 @@ typeof bar === typeof qux

:::

## Options

This rule has an object option:

* `"requireStringLiterals": true` allows the comparison of `typeof` expressions with only string literals or other `typeof` expressions, and disallows comparisons to any other value. Default is `false`.

### requireStringLiterals

Examples of **incorrect** code with the `{ "requireStringLiterals": true }` option:

::: incorrect
Expand Down