Skip to content

Conversation

@connorshea
Copy link
Collaborator

@connorshea connorshea commented Oct 21, 2025

This ensures the autogenerated documentation handles the configuration section. Part of #14743.

The generated docs look like this (but without the backslashes before the code blocks):

## Configuration

This rule accepts a configuration object with the following properties:

### requireStringLiterals

type: `boolean`

default: `false`

The `requireStringLiterals` option when set to `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`.

With `requireStringLiterals` set to `true`, the following are examples of **incorrect** code:
\```js
typeof foo === undefined
typeof bar == Object
typeof baz === "strnig"
typeof qux === "some invalid type"
typeof baz === anotherVariable
typeof foo == 5
\```

With `requireStringLiterals` set to `true`, the following are examples of **correct** code:
\```js
typeof foo === "undefined"
typeof bar == "object"
typeof baz === "string"
typeof bar === typeof qux
\```

…o the struct.

This ensures the autogenerated documentation handles the configuration section.
Copilot AI review requested due to automatic review settings October 21, 2025 03:30
@connorshea connorshea requested a review from camc314 as a code owner October 21, 2025 03:30
@graphite-app
Copy link
Contributor

graphite-app bot commented Oct 21, 2025

How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR relocates the documentation for the requireStringLiterals configuration option from the rule's main documentation block to the struct field, enabling auto-generated configuration documentation. The change improves documentation structure by allowing the configuration section to be automatically generated from the struct's field comments.

  • Moved requireStringLiterals documentation from declare_oxc_lint! macro to the ValidTypeof struct field
  • Added JsonSchema derive and serde attribute to enable configuration schema generation
  • Added config = ValidTypeof parameter to declare_oxc_lint! macro to link the configuration

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@github-actions github-actions bot added A-linter Area - Linter C-docs Category - Documentation. Related to user-facing or internal documentation labels Oct 21, 2025
@codspeed-hq
Copy link

codspeed-hq bot commented Oct 21, 2025

CodSpeed Performance Report

Merging #14841 will not alter performance

Comparing connorshea:valid-typeof-docs (fb762ee) with main (d0faa7c)

Summary

✅ 4 untouched
⏩ 33 skipped1

Footnotes

  1. 33 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

Copy link
Contributor

@camc314 camc314 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@camc314 camc314 merged commit b6402dd into oxc-project:main Oct 21, 2025
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-linter Area - Linter C-docs Category - Documentation. Related to user-facing or internal documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants