Skip to content

test: extract shared test helpers into @local/testkit - #1915

Merged
Rel1cx merged 2 commits into
mainfrom
refactor/testkit
Jul 18, 2026
Merged

test: extract shared test helpers into @local/testkit#1915
Rel1cx merged 2 commits into
mainfrom
refactor/testkit

Conversation

@Rel1cx

@Rel1cx Rel1cx commented Jul 18, 2026

Copy link
Copy Markdown
Owner
  • Add .pkgs/testkit (@local/testkit, source-only internal package) with parseCode/collectNodes/getFirstNodeOfType, runInRule/getNodeInRule/ runCollector, createScopeContext, and createRuleTesterForJsxEmit
  • Turn testing/helpers into re-export shims for backward compatibility
  • Migrate 24 package unit tests and 2 rule specs to the shared kit, removing per-file copy-pasted harness boilerplate
  • Document the new helpers in docs/rule-implementation-patterns.md and docs/repo-path-aliases.md

Update "[ ]" to "[x]" to check a box

What kind of change does this PR introduce?

Check at least one. If you are introducing a new binding, you must reference an issue where this binding has been proposed, discussed and approved by the maintainers.

  • Bugfix
  • Feature
  • Perf
  • Docs
  • Test
  • Chore
  • Enhancement
  • New Binding issue #___
  • Code style update
  • Refactor
  • Build-related changes
  • Other, please describe:

Does this PR introduce a breaking change?

If yes, please describe the impact and migration path for existing applications in an attached issue.

  • Yes, and the changes were approved in issue #___
  • No

Checklist

  • When resolving issues, they are referenced in the PR's title (e.g fix: remove a typo, closes #___, #___)
  • I have added a convincing reason for adding this feature, if necessary

Other information

@vercel

vercel Bot commented Jul 18, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
eslint-react Ready Ready Preview, Comment Jul 18, 2026 5:17pm

@Rel1cx
Rel1cx requested a review from Copilot July 18, 2026 17:05
@Rel1cx
Rel1cx marked this pull request as ready for review July 18, 2026 17:06

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

Adds a shared internal test helper package (@local/testkit) and migrates existing unit/rule tests to use it, keeping #/testing/helpers as backward-compatible re-export shims.

Changes:

  • Introduces .pkgs/testkit with shared parsing, linter harness, RuleTester setup, and scope-context helpers.
  • Replaces testing/helpers/* implementations with re-exports from @local/testkit.
  • Updates multiple package/plugin tests and docs to use the shared helpers; wires workspace deps accordingly.

Reviewed changes

Copilot reviewed 45 out of 46 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
testing/helpers/rule-tester.ts Re-export RuleTester helpers from @local/testkit.
testing/helpers/lint-runner.ts Re-export ESLint runner helper from @local/testkit.
testing/helpers/get-fixtures-root-dir.ts Re-export fixtures root resolver from @local/testkit.
plugins/eslint-plugin-react-jsx/src/rules/no-key-after-spread/no-key-after-spread.spec.ts Uses createRuleTesterForJsxEmit instead of bespoke RuleTester setup.
plugins/eslint-plugin-react-debug/src/rules/jsx/jsx.spec.ts Uses createRuleTesterForJsxEmit instead of bespoke RuleTester setup.
packages/var/src/resolve.test.ts Migrates custom linter harness to runInRule.
packages/var/src/resolve-import-source.test.ts Migrates parsing/fixtures to parseCode + getFixturesRootDir.
packages/var/src/resolve-enclosing-assignment-target.test.ts Migrates parsing to parseCode.
packages/var/src/is-value-equal.test.ts Migrates custom linter harness to runInRule.
packages/var/src/is-assignment-target-equal.test.ts Migrates custom linter harness to runInRule.
packages/var/src/compute-object-type.test.ts Migrates custom linter harness to runInRule.
packages/var/package.json Adds @local/testkit devDependency.
packages/jsx/src/text.test.ts Migrates JSX node capture to getNodeInRule.
packages/jsx/src/element.test.ts Migrates JSX node capture to getNodeInRule.
packages/jsx/src/children.test.ts Migrates JSX node capture to getNodeInRule.
packages/jsx/src/attribute-value.test.ts Migrates context+node capture to getNodeInRule.
packages/jsx/src/attribute-find.test.ts Migrates context+node capture to getNodeInRule.
packages/jsx/package.json Adds @local/testkit devDependency.
packages/core/src/jsx.test.ts Migrates parsing/scope-context construction to parseCode + createScopeContext.
packages/core/src/hook.test.ts Migrates parsing to parseCode.
packages/core/src/hook-collector.test.ts Migrates collector harness to runCollector.
packages/core/src/function.test.ts Migrates parsing to parseCode.
packages/core/src/function-component.test.ts Migrates parsing to parseCode.
packages/core/src/function-component-collector.test.ts Migrates collector harness to runCollector.
packages/core/src/class.test.ts Migrates parsing to parseCode.
packages/core/src/class-component.test.ts Migrates parsing to parseCode.
packages/core/package.json Adds @local/testkit devDependency.
packages/ast/src/traverse.test.ts Migrates parsing to parseCode.
packages/ast/src/extract.test.ts Migrates node extraction to getFirstNodeOfType.
packages/ast/src/compare.test.ts Migrates node collection to collectNodes.
packages/ast/src/check.test.ts Migrates helpers to @local/testkit (fixtures + node extraction).
packages/ast/package.json Adds @local/testkit devDependency.
docs/rule-implementation-patterns.md Documents new shared helpers and preferred usage patterns.
docs/repo-path-aliases.md Documents @local/testkit vs #/testing/helpers guidance.
.pkgs/testkit/package.json Declares new internal @local/testkit package and exports.
.pkgs/testkit/tsconfig.json TypeScript config for the new package.
.pkgs/testkit/tsl.config.ts TSL config for the new package.
.pkgs/testkit/src/index.ts Barrel exports for testkit helpers.
.pkgs/testkit/src/fixtures.ts Implements fixtures root resolution for testkit.
.pkgs/testkit/src/parse.ts Adds parseCode + node collection helpers.
.pkgs/testkit/src/linter.ts Adds runInRule, getNodeInRule, runCollector harnesses.
.pkgs/testkit/src/mock-context.ts Adds createScopeContext helper for scope-aware contexts.
.pkgs/testkit/src/rule-tester.ts Centralizes RuleTester + vitest wiring and JSX-emit helpers.
.pkgs/testkit/src/lint-runner.ts Adds lintWithConfig helper implementation.
package.json Adds workspace dependency on @local/testkit.
pnpm-lock.yaml Locks new workspace package and dependency graph updates.
Files not reviewed (1)
  • pnpm-lock.yaml: Generated file

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

Comment thread .pkgs/testkit/src/fixtures.ts
- Add .pkgs/testkit (@local/testkit, source-only internal package) with
  parseCode/collectNodes/getFirstNodeOfType, runInRule/getNodeInRule/
  runCollector, createScopeContext, and createRuleTesterForJsxEmit
- Turn testing/helpers into re-export shims for backward compatibility
- Migrate 24 package unit tests and 2 rule specs to the shared kit,
  removing per-file copy-pasted harness boilerplate
- Document the new helpers in docs/rule-implementation-patterns.md and
  docs/repo-path-aliases.md
@Rel1cx
Rel1cx force-pushed the refactor/testkit branch from 7732d06 to 95fd7d1 Compare July 18, 2026 17:10
@socket-security

socket-security Bot commented Jul 18, 2026

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addedlucide-react@​1.25.0100100989680
Addedtailwindcss@​4.3.31001008198100
Addedvite@​8.1.5981008298100
Addedeslint-plugin-jsdoc@​63.0.148610010095100
Addedtsdown@​0.22.9981008898100
Added@​tailwindcss/​postcss@​4.3.39910010098100

View full report

@socket-security

socket-security Bot commented Jul 18, 2026

Copy link
Copy Markdown

Warning

Review the following alerts detected in dependencies.

According to your organization's Security Policy, it is recommended to resolve "Warn" alerts. Learn more about Socket for GitHub.

Action Severity Alert  (click "▶" to expand/collapse)
Warn High
Obfuscated code: npm eslint-plugin-jsdoc is 90.0% likely obfuscated

Confidence: 0.90

Location: Package overview

From: .pkgs/configs/package.jsonnpm/eslint-plugin-jsdoc@63.0.14

ℹ Read more on: This package | This alert | What is obfuscated code?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: Packages should not obfuscate their code. Consider not using packages with obfuscated code.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/eslint-plugin-jsdoc@63.0.14. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

View full report

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Signed-off-by: REL1CX <solarflarex@qq.com>
@Rel1cx
Rel1cx merged commit bcff9ff into main Jul 18, 2026
10 of 11 checks passed
@Rel1cx
Rel1cx deleted the refactor/testkit branch July 18, 2026 17:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants