Skip to content

refactor(linter): jest/vitest/no-restricted-*-methods align config + right schemars output#22920

Merged
graphite-app[bot] merged 1 commit into
mainfrom
06-02-refactor_linter_jest_vitest_no-restricted-_-methods_align_config_right_schemars_output
Jun 2, 2026
Merged

refactor(linter): jest/vitest/no-restricted-*-methods align config + right schemars output#22920
graphite-app[bot] merged 1 commit into
mainfrom
06-02-refactor_linter_jest_vitest_no-restricted-_-methods_align_config_right_schemars_output

Conversation

@Sysix

@Sysix Sysix commented Jun 2, 2026

Copy link
Copy Markdown
Member

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:

  "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:

  "jest/no-restricted-jest-methods"?:
    | [AllowWarnDeny]
    | [
        AllowWarnDeny,
        {
          [k: string]: string | null;
        }
      ];

Bonus: used Option<CompactStr> for more performance (?)

Sysix commented Jun 2, 2026

Copy link
Copy Markdown
Member Author

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 changes, fast-track this PR to the front of 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.

@github-actions github-actions Bot added the A-linter Area - Linter label Jun 2, 2026
@Sysix Sysix requested a review from Copilot June 2, 2026 17:26

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 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 custom schemars schema to emit the intended output.
  • Updates runtime config parsing to store null as None and strings as Some(CompactStr).
  • Simplifies diagnostic emission for custom messages (but currently drops the previous empty-string handling).

@codspeed-hq

codspeed-hq Bot commented Jun 2, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 5 untouched benchmarks
⏩ 61 skipped benchmarks1


Comparing 06-02-refactor_linter_jest_vitest_no-restricted-_-methods_align_config_right_schemars_output (9fbb2ae) with main (5b8dd68)2

Open in CodSpeed

Footnotes

  1. 61 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.

  2. No successful run was found on main (0f7c319) during the generation of this report, so 5b8dd68 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@Sysix Sysix marked this pull request as ready for review June 2, 2026 17:33
@Sysix Sysix requested a review from camc314 as a code owner June 2, 2026 17:33
@camc314 camc314 added the 0-merge Merge with Graphite Merge Queue label Jun 2, 2026

camc314 commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

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 (?)
@graphite-app graphite-app Bot force-pushed the 06-02-refactor_linter_jest_vitest_no-restricted-_-methods_align_config_right_schemars_output branch from 9fbb2ae to 0611de1 Compare June 2, 2026 17:36
@graphite-app graphite-app Bot merged commit 0611de1 into main Jun 2, 2026
29 checks passed
@graphite-app graphite-app Bot removed the 0-merge Merge with Graphite Merge Queue label Jun 2, 2026
@graphite-app graphite-app Bot deleted the 06-02-refactor_linter_jest_vitest_no-restricted-_-methods_align_config_right_schemars_output branch June 2, 2026 17:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-linter Area - Linter

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants