Skip to content

chore(eslint): @typescript-eslint/consistent-type-imports#1195

Merged
chimurai merged 1 commit intomasterfrom
typescript-eslint_consistent-type-imports
Apr 6, 2026
Merged

chore(eslint): @typescript-eslint/consistent-type-imports#1195
chimurai merged 1 commit intomasterfrom
typescript-eslint_consistent-type-imports

Conversation

@chimurai
Copy link
Copy Markdown
Owner

@chimurai chimurai commented Apr 6, 2026

Summary by CodeRabbit

  • Refactor
    • Converted value imports to type-only imports across multiple source and test files for TypeScript optimization.
    • Enhanced ESLint configuration to enforce consistent type import patterns for TypeScript files.
    • Added explicit type annotations to test variables throughout the test suite.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 6, 2026

📝 Walkthrough

Walkthrough

This pull request implements TypeScript type-only imports across the codebase by converting value imports to type-only imports where types are used solely for annotations. An ESLint rule @typescript-eslint/consistent-type-imports is added to enforce this pattern. Additionally, explicit type annotations are added to some test variables for clarity.

Changes

Cohort / File(s) Summary
ESLint Configuration
eslint.config.mjs
Added @typescript-eslint/consistent-type-imports rule with warn severity for **/*.ts files to enforce type-only imports.
Source Module Imports
src/configuration.ts, src/logger.ts
Converted imports of Options and Logger from value imports to type-only imports, as they are used exclusively in type annotations.
Plugin Type Imports
src/plugins/default/debug-proxy-errors-plugin.ts, src/plugins/default/error-response-plugin.ts, src/plugins/default/logger-plugin.ts, src/plugins/default/proxy-events.ts
Changed Plugin imports from value to type-only imports across all default plugins, removing runtime dependencies while preserving type annotations.
End-to-End Test Type Imports
test/e2e/hono.spec.ts, test/e2e/http-proxy-middleware.spec.ts, test/e2e/path-rewriter.spec.ts, test/e2e/plugins.spec.ts, test/e2e/router.spec.ts, test/e2e/websocket.spec.ts
Converted type-only dependencies (HttpBindings, ServerType, Mockttp, CompletedRequest, ErrorRequestHandler, RawData) to type-only imports while retaining runtime value imports (getLocal, serve, generateCACertificate, WebSocket, WebSocketServer).
Unit Test Imports & Type Annotations
test/unit/configuration.spec.ts, test/unit/fix-request-body.spec.ts, test/unit/path-filter.spec.ts
Converted BodyParserLikeRequest to type-only import and added explicit type annotations to test helper variables (fn: () => void, url: string).

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

Poem

🐰 Hop, hop, hooray! The types now dance
In their own rightful space, no runtime prance
Tree-shaking sweetly, the code grows light—
Type-only imports, oh what a sight! 🌳✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the primary change: adding and enforcing the @typescript-eslint/consistent-type-imports ESLint rule across the codebase.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch typescript-eslint_consistent-type-imports

Comment @coderabbitai help to get the list of available commands and usage tips.

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Apr 6, 2026

npm i https://pkg.pr.new/http-proxy-middleware@1195

commit: e0df3f6

@coveralls
Copy link
Copy Markdown

coveralls commented Apr 6, 2026

Coverage Status

coverage: 93.333%. remained the same
when pulling e0df3f6 on typescript-eslint_consistent-type-imports
into 2344bed on master.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 8

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@test/e2e/hono.spec.ts`:
- Around line 5-6: The import statement formatting is off: add a space before
the closing brace in the type import. Update the import line that references
Mockttp (import type { Mockttp}) so it reads with a space before the brace
(import type { Mockttp }) to satisfy Prettier; ensure the other import
(getLocal) remains unchanged.
- Around line 1-2: The import statement formatting is missing a space before the
closing brace in the type import; update the import line that references the
symbols HttpBindings and ServerType (i.e., the "import type { HttpBindings,
ServerType}" statement) to include a space before the closing brace so it reads
with proper Prettier spacing.

In `@test/e2e/http-proxy-middleware.spec.ts`:
- Around line 5-6: The import type line has a Prettier formatting error due to a
missing space before the closing brace; update the import statement importing
CompletedRequest and Mockttp (the line containing "import type {
CompletedRequest, Mockttp") to include a space before the closing brace so it
reads with "{ CompletedRequest, Mockttp }", ensuring Prettier passes.

In `@test/e2e/path-rewriter.spec.ts`:
- Line 1: The import line for Mockttp has incorrect spacing; update the import
statement that references the Mockttp type (the "Mockttp" symbol) so the braces
are spaced correctly (i.e., ensure there's a space before the closing brace) to
satisfy Prettier formatting for the import in path-rewriter.spec.ts.

In `@test/e2e/plugins.spec.ts`:
- Line 1: The import statement has incorrect spacing in the named type import
for Mockttp causing Prettier failure; update the import in the file so the named
type has a space before the closing brace (change the token sequence from
"Mockttp}" to "Mockttp }") — e.g. fix the import that references Mockttp in the
top of test/e2e/plugins.spec.ts so it reads the standard form with a space
inside the braces.

In `@test/e2e/router.spec.ts`:
- Line 3: The type import for Mockttp is missing a space before the closing
brace; update the import statement that references Mockttp (the line with
"import type { Mockttp") to include the space so it reads with a space before
the "}" (i.e., fix the import of Mockttp), then re-run Prettier/formatting to
ensure CI passes.

In `@test/e2e/websocket.spec.ts`:
- Around line 5-6: The import statement formatting for the RawData type is
missing a space before the closing brace; update the import of RawData in the
test file (the line importing "RawData" from 'ws' — e.g., the import that
currently reads "import type { RawData} from 'ws';") to include a space before
the brace so it becomes "import type { RawData } from 'ws';" to satisfy
Prettier.

In `@test/unit/fix-request-body.spec.ts`:
- Around line 8-9: Prettier fails due to a missing space before the closing
brace in the type import; update the import statement that references
BodyParserLikeRequest so it reads "import type { BodyParserLikeRequest } from
'../../src/handlers/fix-request-body.js';" (ensure the space before the closing
brace) and verify any other similar imports (e.g., the fixRequestBody import
line) follow the same formatting convention.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 062cf88e-d421-49c0-9718-9a28dac0238e

📥 Commits

Reviewing files that changed from the base of the PR and between 2344bed and 5199079.

📒 Files selected for processing (16)
  • eslint.config.mjs
  • src/configuration.ts
  • src/logger.ts
  • src/plugins/default/debug-proxy-errors-plugin.ts
  • src/plugins/default/error-response-plugin.ts
  • src/plugins/default/logger-plugin.ts
  • src/plugins/default/proxy-events.ts
  • test/e2e/hono.spec.ts
  • test/e2e/http-proxy-middleware.spec.ts
  • test/e2e/path-rewriter.spec.ts
  • test/e2e/plugins.spec.ts
  • test/e2e/router.spec.ts
  • test/e2e/websocket.spec.ts
  • test/unit/configuration.spec.ts
  • test/unit/fix-request-body.spec.ts
  • test/unit/path-filter.spec.ts

Comment thread test/e2e/hono.spec.ts Outdated
Comment thread test/e2e/hono.spec.ts Outdated
Comment thread test/e2e/http-proxy-middleware.spec.ts Outdated
Comment thread test/e2e/path-rewriter.spec.ts Outdated
Comment thread test/e2e/plugins.spec.ts Outdated
Comment thread test/e2e/router.spec.ts Outdated
Comment thread test/e2e/websocket.spec.ts Outdated
Comment thread test/unit/fix-request-body.spec.ts Outdated
@chimurai chimurai force-pushed the typescript-eslint_consistent-type-imports branch from 5199079 to e0df3f6 Compare April 6, 2026 08:43
@chimurai chimurai merged commit 3b9ccee into master Apr 6, 2026
20 checks passed
@chimurai chimurai deleted the typescript-eslint_consistent-type-imports branch April 6, 2026 08:45
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