Skip to content

Conversation

@overlookmotel
Copy link
Member

@overlookmotel overlookmotel commented Dec 13, 2025

Pure refactor of tests.

In tokens unit tests, use a setup function to set source text for each test, rather than writing to local sourceText var.

Remove a bunch of unnecessary resetSourceAndAst() calls. beforeEach hook does this already before each test.

@github-actions github-actions bot added A-linter Area - Linter A-cli Area - CLI A-linter-plugins Area - Linter JS plugins labels Dec 13, 2025
Copy link
Member Author

overlookmotel commented Dec 13, 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.

This stack of pull requests is managed by Graphite. Learn more about stacking.

Copy link

@charliecreates charliecreates bot left a comment

Choose a reason for hiding this comment

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

  • setup() currently resets state despite comments implying it’s only needed to change the source text, leading to redundant resets and a confusing helper contract.
  • The beforeEach comment refers to setSourceText, but the helper is named setup, creating inconsistency and reducing clarity.
Summary of changes

Summary

Refactors apps/oxlint/test/tokens.test.ts to centralize per-test initialization:

  • Introduces a setup(text: string) helper that calls resetSourceAndAst() and assigns sourceText.
  • Updates the beforeEach hook to call setup(SOURCE_TEXT) instead of duplicating reset/assignment logic.
  • Replaces many direct sourceText = ... assignments (and several redundant resetSourceAndAst() calls) with setup(...) in individual test cases.
  • Keeps behavior the same while reducing repeated boilerplate across token-store tests.

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 refactors the token plugin unit tests to improve consistency and maintainability by introducing a setup() function that encapsulates test state initialization. The refactor eliminates code duplication and removes redundant resetSourceAndAst() calls that were already being handled by the beforeEach hook.

Key Changes:

  • Introduced a setup() helper function that combines resetSourceAndAst() and sourceText assignment
  • Replaced all direct sourceText = "..." assignments with setup("...") calls throughout the test suite
  • Removed redundant resetSourceAndAst() calls since the beforeEach hook now handles reset via setup()

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@overlookmotel overlookmotel self-assigned this Dec 13, 2025
@overlookmotel overlookmotel force-pushed the 12-13-test_linter_plugins_refactor_tokens_tests branch from c457c5c to bfbf14d Compare December 13, 2025 18:42
@overlookmotel overlookmotel force-pushed the 12-13-test_linter_plugins_tests_use_oxc_parser branch from 8d2b90f to 005982b Compare December 13, 2025 18:42
@overlookmotel overlookmotel added the 0-merge Merge with Graphite Merge Queue label Dec 13, 2025
Copy link
Member Author

overlookmotel commented Dec 13, 2025

Merge activity

Pure refactor of tests.

In tokens unit tests, use a `setup` function to set source text for each test, rather than writing to local `sourceText` var.

Remove a bunch of unnecessary `resetSourceAndAst()` calls. `beforeEach` hook does this already before each test.
@graphite-app graphite-app bot force-pushed the 12-13-test_linter_plugins_tests_use_oxc_parser branch from 005982b to 5619f9e Compare December 13, 2025 18:51
@graphite-app graphite-app bot force-pushed the 12-13-test_linter_plugins_refactor_tokens_tests branch from bfbf14d to d734b86 Compare December 13, 2025 18:52
Base automatically changed from 12-13-test_linter_plugins_tests_use_oxc_parser to main December 13, 2025 18:57
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Dec 13, 2025
@graphite-app graphite-app bot merged commit d734b86 into main Dec 13, 2025
19 checks passed
@graphite-app graphite-app bot deleted the 12-13-test_linter_plugins_refactor_tokens_tests branch December 13, 2025 18:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-cli Area - CLI A-linter Area - Linter A-linter-plugins Area - Linter JS plugins C-test Category - Testing. Code is missing test cases, or a PR is adding them

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants