Skip to content

Delete unused code in tests#1101

Open
JasonYeMSFT wants to merge 1 commit intomicrosoft:mainfrom
JasonYeMSFT:chuye/no-unused-export
Open

Delete unused code in tests#1101
JasonYeMSFT wants to merge 1 commit intomicrosoft:mainfrom
JasonYeMSFT:chuye/no-unused-export

Conversation

@JasonYeMSFT
Copy link
Member

This PR adds a new ESLint plugin with rules to detect duplicate imports and unused exports.

  • If a module is imported, there can be only one import statement for it.
  • If a module is exported, another module other than itself must use it.

I removed the export operator from the unused exports detected and then removed the unused code revealed.

Copilot AI review requested due to automatic review settings March 2, 2026 23:12
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 cleans up unused test utilities/exports and tightens linting by adding eslint-plugin-import (including a rule to surface unused exports), then removing code that becomes unused as a result.

Changes:

  • Add eslint-plugin-import to the tests ESLint flat config and enable import/no-unused-modules (unused exports) as a warning.
  • Remove unused exports/utility functions across tests/utils/** (e.g., fixture helpers, unused detectors, unused wrapper factories).
  • Consolidate several duplicate import statements in integration tests.

Reviewed changes

Copilot reviewed 19 out of 20 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tests/utils/trigger-matcher.ts Removes unused exported types/helpers and minor formatting cleanup.
tests/utils/skill-loader.ts Removes unused exported helpers and narrows exported surface area.
tests/utils/regression-detectors.ts Removes unused detector functions and trims unused imports.
tests/utils/git-clone.ts Makes an internal options type non-exported.
tests/utils/fixtures.ts Deletes unused fixtures utility module.
tests/utils/evaluate.ts Removes an unused exported helper and reformats types.
tests/utils/agent-runner.ts Removes unused exports (deploy link helper + multi-turn conversation runner).
tests/package.json Adds eslint-plugin-import.
tests/package-lock.json Locks new dependency tree for the lint plugin (and updated transitive deps).
tests/microsoft-foundry/integration.test.ts Consolidates imports from evaluate.
tests/microsoft-foundry/foundry-agent/create/integration.test.ts Consolidates imports from evaluate.
tests/eslint.config.mjs Adds eslint-plugin-import flat configs + enables import/no-unused-modules.
tests/azure-validate/utils.ts Removes an unused helper and trims related comment text.
tests/azure-validate/integration.test.ts Consolidates imports from evaluate.
tests/azure-resource-visualizer/integration.test.ts Consolidates imports from evaluate.
tests/azure-rbac/integration.test.ts Consolidates imports from evaluate.
tests/azure-prepare/integration.test.ts Consolidates imports from evaluate.
tests/azure-messaging/integration.test.ts Consolidates imports from evaluate.
tests/azure-hosted-copilot-sdk/util.ts Makes internal helper functions non-exported.
tests/.eslintrc Adds a legacy ESLint config file intended to ignore jest.config.ts.
Files not reviewed (1)
  • tests/package-lock.json: Language not supported

Comment on lines +1 to +5
{
"ignorePatterns": [
"jest.config.ts"
]
} No newline at end of file
Copy link

Copilot AI Mar 2, 2026

Choose a reason for hiding this comment

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

This repo uses ESLint v9 flat config (tests/eslint.config.mjs), so this legacy .eslintrc file won’t affect npm run lint and may lead to inconsistent linting between CI/editor setups. If the goal is to ignore jest.config.ts, add it to the ignores list in tests/eslint.config.mjs (or configure import/no-unused-modules), and remove this file to avoid config ambiguity.

Suggested change
{
"ignorePatterns": [
"jest.config.ts"
]
}
{}

Copilot uses AI. Check for mistakes.
"license": "Apache-2.0",
"peer": true,
"engines": {
"node": "^20.19.0 || ^22.13.0 || >=24"
Copy link

Copilot AI Mar 2, 2026

Choose a reason for hiding this comment

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

eslint-visitor-keys@5.0.1 in the lockfile declares an engines requirement of ^20.19.0 || ^22.13.0 || >=24. CI jobs like .github/workflows/pr.yml use node-version: '20', and local devs may be on earlier Node 20 minors; this can lead to install/runtime issues. Consider pinning to a compatible eslint-visitor-keys/@typescript-eslint/* version set, or tightening the workflows/node tooling requirement to a Node version that satisfies these engines constraints.

Suggested change
"node": "^20.19.0 || ^22.13.0 || >=24"
"node": "20 || >=22"

Copilot uses AI. Check for mistakes.
// We don't have deterministic metrics for them yet.
"jest/expect-expect": "off"
"jest/expect-expect": "off",
"import/no-unused-modules": [1, { "unusedExports": true }]
Copy link

Copilot AI Mar 2, 2026

Choose a reason for hiding this comment

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

import/no-unused-modules will report unusedExports for modules that are executed by Jest via configuration (e.g. jest.config.ts and jest.globalSetup.mjs) but are never imported in code. Consider either adding those files to the flat-config ignores list (preferred, since ESLint 9 uses eslint.config.mjs), or configuring import/no-unused-modules with ignoreExports / scoping the rule to only the directories you actually want to police (e.g. tests/utils/**).

Suggested change
"import/no-unused-modules": [1, { "unusedExports": true }]
"import/no-unused-modules": [1, {
"unusedExports": true,
"ignoreExports": [
"**/jest.config.ts",
"**/jest.globalSetup.mjs"
]
}]

Copilot uses AI. Check for mistakes.
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