Skip to content

[WIP]chore: normalize import order across codebase#2231

Draft
RYGRIT wants to merge 1 commit intonpmx-dev:mainfrom
RYGRIT:chore/import-order
Draft

[WIP]chore: normalize import order across codebase#2231
RYGRIT wants to merge 1 commit intonpmx-dev:mainfrom
RYGRIT:chore/import-order

Conversation

@RYGRIT
Copy link
Contributor

@RYGRIT RYGRIT commented Mar 23, 2026

🔗 Linked issue

🧭 Context

  • Organize imports per CONTRIBUTING.md: type → external → internal → relative.
  • Fixes 96 files across app/, server/, test/, and other directories.

📚 Description

@vercel
Copy link

vercel bot commented Mar 23, 2026

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

Project Deployment Actions Updated (UTC)
npmx.dev Ready Ready Preview, Comment Mar 23, 2026 10:06am
2 Skipped Deployments
Project Deployment Actions Updated (UTC)
docs.npmx.dev Ignored Ignored Preview Mar 23, 2026 10:06am
npmx-lunaria Ignored Ignored Mar 23, 2026 10:06am

Request Review

@RYGRIT RYGRIT marked this pull request as draft March 23, 2026 10:05
@RYGRIT RYGRIT changed the title chore: normalize import order across codebase [WIP]chore: normalize import order across codebase Mar 23, 2026
@codecov
Copy link

codecov bot commented Mar 23, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 23, 2026

📝 Walkthrough

Walkthrough

This pull request reorganises import statements across the entire codebase without introducing any functional logic changes, runtime behaviour modifications, or exported API alterations. The changes include reordering type-only imports to appear at the top of files, consolidating duplicate imports into single statements, grouping imports by source or category, and removing unnecessary blank lines between import blocks. No component behaviour, control flow, or business logic is affected.

Possibly related PRs

Suggested labels

front

Suggested reviewers

  • danielroe
🚥 Pre-merge checks | ✅ 1
✅ Passed checks (1 passed)
Check name Status Explanation
Description check ✅ Passed The PR description adequately explains the changeset: it organizes imports across 96 files to follow CONTRIBUTING.md guidelines (type → external → internal → relative ordering).

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

Copy link
Contributor

@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: 4

🧹 Nitpick comments (4)
test/unit/app/utils/versions.spec.ts (1)

18-20: Avoid non-null assertion on tags[0] in helper return

primaryTag: tags[0]! bypasses type safety and can mask an empty-tags bug in tests. Prefer a guarded fallback (or throw explicitly) to keep index access safe.

Suggested refactor
 function row(version: string, tags: string[]) {
-  return { id: `version:${version}`, primaryTag: tags[0]!, tags, version }
+  const primaryTag = tags[0] ?? ''
+  return { id: `version:${version}`, primaryTag, tags, version }
 }

As per coding guidelines, “Ensure you write strictly type-safe code, for example by ensuring you always check when accessing an array value by index”.

scripts/unocss-checker.ts (1)

5-6: Consider consolidating imports from the same package.

Both lines import from unocss and could be combined into a single import statement for conciseness.

♻️ Consolidate imports
-import { createGenerator } from 'unocss'
-import { presetWind4 } from 'unocss'
+import { createGenerator, presetWind4 } from 'unocss'
server/api/auth/atproto.get.ts (1)

4-5: Consider consolidating imports from the same module.

isAtUriString and isAtIdentifierString are imported separately from @atproto/lex on consecutive lines. They could be combined into a single import statement for consistency with the rest of the file.

♻️ Suggested change
-import { Client, isAtUriString } from '@atproto/lex'
-import { isAtIdentifierString } from '@atproto/lex'
+import { Client, isAtIdentifierString, isAtUriString } from '@atproto/lex'
modules/blog.ts (1)

4-13: Import grouping follows the stated convention.

The reorganization correctly groups external imports (lines 4–12) before relative imports (line 13 onwards), adhering to the project's type → external → internal → relative ordering.

For enhanced readability, consider one of these optional refinements within the external import group:

  • Option 1: Alphabetize all external imports together
  • Option 2: Subgroup by category (e.g., regular packages, then node built-ins, then framework packages)
  • Option 3: Add a blank line between external and relative import groups
♻️ Example: Subgrouped and separated
 import shiki from '@shikijs/markdown-exit'
 import { defu } from 'defu'
 import { read } from 'gray-matter'
 import MarkdownItAnchor from 'markdown-it-anchor'
+import { globSync } from 'tinyglobby'
+import Markdown from 'unplugin-vue-markdown/vite'
+import { array, safeParse } from 'valibot'
+
 import crypto from 'node:crypto'
 import { existsSync } from 'node:fs'
 import { mkdir, writeFile } from 'node:fs/promises'
 import { join } from 'node:path'
+
 import { addTemplate, addVitePlugin, defineNuxtModule, useNuxt, createResolver } from 'nuxt/kit'
-import { globSync } from 'tinyglobby'
-import Markdown from 'unplugin-vue-markdown/vite'
-import { array, safeParse } from 'valibot'
+
 import { isProduction } from '../config/env'

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: bb500ae7-f4bf-406c-953c-843b9080119a

📥 Commits

Reviewing files that changed from the base of the PR and between 1824c62 and 9e5f080.

📒 Files selected for processing (96)
  • .storybook/manager.ts
  • .storybook/preview.ts
  • app/components/AppHeader.vue
  • app/components/BlueskyComment.vue
  • app/components/Compare/FacetBarChart.vue
  • app/components/Header/AuthModal.client.vue
  • app/components/Header/MobileMenu.client.vue
  • app/components/Package/InstallScripts.vue
  • app/components/Package/TrendsChart.vue
  • app/components/Package/Versions.vue
  • app/components/Package/WeeklyDownloadStats.vue
  • app/composables/useGlobalSearch.ts
  • app/composables/useSettings.ts
  • app/composables/useVersionDistribution.ts
  • app/pages/about.stories.ts
  • app/pages/compare.vue
  • app/pages/org/[org].vue
  • app/pages/search.vue
  • app/utils/atproto/likes.ts
  • app/utils/run-command.ts
  • cli/src/mock-app.ts
  • cli/src/server.ts
  • config/env.ts
  • lunaria.config.ts
  • lunaria/components.ts
  • lunaria/lunaria.ts
  • modules/blog.ts
  • modules/runtime/server/cache.ts
  • modules/standard-site-sync.ts
  • nuxt.config.ts
  • playwright.config.ts
  • scripts/remove-unused-translations.ts
  • scripts/unocss-checker.ts
  • server/api/atproto/bluesky-author-profiles.get.ts
  • server/api/atproto/bluesky-comments.get.ts
  • server/api/atproto/pds-graphs.get.ts
  • server/api/atproto/pds-users.get.ts
  • server/api/auth/atproto.get.ts
  • server/api/auth/session.get.ts
  • server/api/jsr/[...pkg].get.ts
  • server/api/registry/analysis/[...pkg].get.ts
  • server/api/registry/file/[...pkg].get.ts
  • server/api/registry/org/[org]/packages.get.ts
  • server/api/social/like.post.ts
  • server/api/social/profile/[identifier]/index.put.ts
  • server/routes/skills/[...pkg].get.ts
  • server/utils/atproto/oauth.ts
  • server/utils/atproto/utils/likes.ts
  • server/utils/atproto/utils/profile.ts
  • server/utils/dependency-analysis.ts
  • server/utils/dependency-resolver.ts
  • server/utils/docs/client.ts
  • server/utils/docs/render.ts
  • server/utils/docs/text.ts
  • server/utils/error-handler.ts
  • server/utils/readme.ts
  • shared/schemas/blog.ts
  • shared/utils/atproto.ts
  • shared/utils/constellation.ts
  • shared/utils/diff.ts
  • test/nuxt/a11y.spec.ts
  • test/nuxt/components/HeaderConnectorModal.spec.ts
  • test/nuxt/components/OgImagePackage.spec.ts
  • test/nuxt/components/Package/LikeCard.spec.ts
  • test/nuxt/components/Package/MetricsBadges.spec.ts
  • test/nuxt/components/Package/Sidebar.spec.ts
  • test/nuxt/components/Package/Versions.spec.ts
  • test/nuxt/components/Package/WeeklyDownloadStats.spec.ts
  • test/nuxt/components/ProfileInviteSection.spec.ts
  • test/nuxt/components/compare/FacetSelector.spec.ts
  • test/nuxt/composables/use-colors.spec.ts
  • test/nuxt/composables/use-compare-replacements.spec.ts
  • test/nuxt/composables/use-facet-selection.spec.ts
  • test/nuxt/composables/use-install-command.spec.ts
  • test/nuxt/composables/use-package-comparison.spec.ts
  • test/nuxt/composables/use-replacement-dependencies.spec.ts
  • test/nuxt/pages/PackageVersionsPage.spec.ts
  • test/unit/app/composables/use-charts.spec.ts
  • test/unit/app/utils/chart-data-prediction.spec.ts
  • test/unit/app/utils/charts.spec.ts
  • test/unit/app/utils/download-anomalies.spec.ts
  • test/unit/app/utils/install-command.spec.ts
  • test/unit/app/utils/npm/common.spec.ts
  • test/unit/app/utils/run-command.spec.ts
  • test/unit/app/utils/versions.spec.ts
  • test/unit/server/utils/dependency-resolver.spec.ts
  • test/unit/server/utils/docs/format.spec.ts
  • test/unit/server/utils/docs/render.spec.ts
  • test/unit/server/utils/docs/text.spec.ts
  • test/unit/server/utils/file-tree.spec.ts
  • test/unit/server/utils/import-resolver.spec.ts
  • test/unit/server/utils/likes-evolution.spec.ts
  • test/unit/shared/types/index.spec.ts
  • test/unit/uno-preset-a11y.spec.ts
  • test/unit/uno-preset-rtl.spec.ts
  • uno.config.ts
💤 Files with no reviewable changes (3)
  • .storybook/manager.ts
  • server/routes/skills/[...pkg].get.ts
  • test/unit/app/utils/npm/common.spec.ts

@@ -1,36 +1,9 @@
import crypto from 'node:crypto'
import { H3, HTTPError, handleCors, type H3Event } from 'h3-next'
import type { ConnectorState, PendingOperation, ApiResponse, ConnectorEndpoints } from './types.ts'
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Reinstate compile-time endpoint parity check.

Line 1 now omits the AssertEndpointsImplemented safeguard, so endpoint drift between ConnectorEndpoints and this server can go unnoticed at compile time.

Suggested fix
-import type { ConnectorState, PendingOperation, ApiResponse, ConnectorEndpoints } from './types.ts'
+import type {
+  ConnectorState,
+  PendingOperation,
+  ApiResponse,
+  ConnectorEndpoints,
+  AssertEndpointsImplemented,
+} from './types.ts'
 export const CONNECTOR_VERSION = pkg.version
+
+type ImplementedEndpoint =
+  | 'POST /connect'
+  | 'GET /state'
+  | 'POST /operations'
+  | 'POST /operations/batch'
+  | 'DELETE /operations'
+  | 'DELETE /operations/all'
+  | 'POST /approve'
+  | 'POST /approve-all'
+  | 'POST /retry'
+  | 'POST /execute'
+  | 'GET /org/:org/users'
+  | 'GET /org/:org/teams'
+  | 'GET /team/:scopeTeam/users'
+  | 'GET /package/:pkg/collaborators'
+  | 'GET /user/packages'
+  | 'GET /user/orgs'
+
+const _endpointCheck: AssertEndpointsImplemented<ImplementedEndpoint> = true

import type { H3Event } from 'h3'
import { SLINGSHOT_HOST } from '#shared/utils/constants'
import { useServerSession } from '#server/utils/server-session'
import { clientUri } from '#oauth/config'
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

Restore @ts-expect-error for virtual module import.

Same issue as in server/utils/atproto/oauth.ts: the #oauth/config module is dynamically generated at build time and lacks TypeScript declarations. The removed @ts-expect-error suppression is causing the type check to fail.

🐛 Proposed fix
 import { createError, getQuery, sendRedirect, setCookie, getCookie, deleteCookie } from 'h3'
+// `@ts-expect-error` virtual file from oauth module
 import { clientUri } from '#oauth/config'
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
import { clientUri } from '#oauth/config'
// `@ts-expect-error` virtual file from oauth module
import { clientUri } from '#oauth/config'
🧰 Tools
🪛 GitHub Check: 💪 Type check

[failure] 8-8:
Cannot find module '#oauth/config' or its corresponding type declarations.


[failure] 8-8:
Cannot find module '#oauth/config' or its corresponding type declarations.

import type { EventHandlerRequest, H3Event, SessionManager } from 'h3'
import { JoseKey, Keyset, oauthRedirectUriSchema, webUriSchema } from '@atproto/oauth-client-node'
import { NodeOAuthClient, AtprotoDohHandleResolver } from '@atproto/oauth-client-node'
import { clientUri } from '#oauth/config'
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

Restore @ts-expect-error for virtual module import.

The #oauth/config module is generated at build time via addServerTemplate in modules/oauth.ts and has no static TypeScript declarations. The @ts-expect-error comment that was removed was intentionally suppressing TS2307. Its removal is causing the type check pipeline to fail.

🐛 Proposed fix
 import { JoseKey, Keyset, oauthRedirectUriSchema, webUriSchema } from '@atproto/oauth-client-node'
 import { NodeOAuthClient, AtprotoDohHandleResolver } from '@atproto/oauth-client-node'
+// `@ts-expect-error` virtual file from oauth module
 import { clientUri } from '#oauth/config'
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
import { clientUri } from '#oauth/config'
// `@ts-expect-error` virtual file from oauth module
import { clientUri } from '#oauth/config'
🧰 Tools
🪛 GitHub Check: 💪 Type check

[failure] 11-11:
Cannot find module '#oauth/config' or its corresponding type declarations.


[failure] 11-11:
Cannot find module '#oauth/config' or its corresponding type declarations.

Comment on lines 1 to +2
import type { ReplacementSuggestion } from '~/composables/useCompareReplacements'
import type { ModuleReplacement } from 'module-replacements'
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Import order doesn't follow the stated convention.

According to the PR objectives, imports should follow: "type → external → internal → relative". The external type import on Line 2 (module-replacements) should come before the internal type import on Line 1 (~/composables/useCompareReplacements).

🔄 Proposed fix to correct import order
-import type { ReplacementSuggestion } from '~/composables/useCompareReplacements'
 import type { ModuleReplacement } from 'module-replacements'
+import type { ReplacementSuggestion } from '~/composables/useCompareReplacements'
 import { mountSuspended } from '@nuxt/test-utils/runtime'
 import { afterEach, describe, expect, it, vi } from 'vitest'
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
import type { ReplacementSuggestion } from '~/composables/useCompareReplacements'
import type { ModuleReplacement } from 'module-replacements'
import type { ModuleReplacement } from 'module-replacements'
import type { ReplacementSuggestion } from '~/composables/useCompareReplacements'
import { mountSuspended } from '@nuxt/test-utils/runtime'
import { afterEach, describe, expect, it, vi } from 'vitest'

Copy link
Contributor

@ghostdevv ghostdevv left a comment

Choose a reason for hiding this comment

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

are we doing this programmatically?

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