refactor(linter): jest/vitest/no-restricted-*-methods align config + right schemars output#22920
Conversation
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
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. This stack of pull requests is managed by Graphite. Learn more about stacking. |
There was a problem hiding this comment.
Pull request overview
This PR updates the shared implementation behind jest/no-restricted-jest-methods and vitest/no-restricted-vi-methods to ensure the generated JSON Schema matches upstream rule configuration docs (a top-level object map of method name → string | null). It also switches stored messages to Option<CompactStr> to better model null and reduce allocations.
Changes:
- Refactors the config shape to a flattened map (
{ [k: string]: string | null }) and adds a customschemarsschema to emit the intended output. - Updates runtime config parsing to store
nullasNoneand strings asSome(CompactStr). - Simplifies diagnostic emission for custom messages (but currently drops the previous empty-string handling).
Merging this PR will not alter performance
Comparing Footnotes
|
Merge activity
|
…+ right schemars output (#22920) With #22907 I want to start outputting the schema for rule configs. Boths rules (`jest/no-restricted-jest-methods` & `vitest/no-restricted-vi-methods`) had not the right user configuration output: Upstream docs: - https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/no-restricted-vi-methods.md - https://github.com/jest-community/eslint-plugin-jest/blob/main/docs/rules/no-restricted-jest-methods.md The Schema before this PR: ```ts "jest/no-restricted-jest-methods"?: | [AllowWarnDeny] | [ AllowWarnDeny, { /** * A mapping of restricted Jest method names to custom messages - or * `null`, for a generic message. */ restrictedJestMethods?: { [k: string]: string; }; [k: string]: unknown; } ]; ``` With this PR: ```ts "jest/no-restricted-jest-methods"?: | [AllowWarnDeny] | [ AllowWarnDeny, { [k: string]: string | null; } ]; ``` --- Bonus: used `Option<CompactStr>` for more performance (?)
9fbb2ae to
0611de1
Compare
… schemars output (#22921) The same as github.com//pull/22920, created a util helper for schema objects. - https://github.com/jest-community/eslint-plugin-jest/blob/main/docs/rules/no-restricted-matchers.md - https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/no-restricted-matchers.md

With #22907 I want to start outputting the schema for rule configs.
Boths rules (
jest/no-restricted-jest-methods&vitest/no-restricted-vi-methods) had not the right user configuration output:Upstream docs:
The Schema before this PR:
With this PR:
Bonus: used
Option<CompactStr>for more performance (?)