Skip to content

fix(deps): per-icon lucide-solid imports to shrink vite transform burst (#389) - #433

Merged
omridevk merged 3 commits into
mainfrom
fix/389-lucide-per-icon-imports
Aug 12, 2026
Merged

omridevk merged 3 commits into
mainfrom
fix/389-lucide-per-icon-imports

Conversation

@omridevk

@omridevk omridevk commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor

Root cause (#389 strand)

The @conciv/app vitest-browser suite's cold-start import burst was 92% lucide-solid: barrel imports pulled all ~1700 icon modules through the vite transform on every cold run (solid packages are excluded from dep-prebundle, so the icons never hit the .vite cache). On starved x86 CI runners that 60-530s window is where Chromium's network service kills all page websockets at one instant, the vite client reloads the tester frame, and vitest browser mode cannot reconnect (upstream vitest-dev/vitest#10791) — the rotating-victim Browser connection was closed failure.

Profiled with DEBUG=vite:transform: 1969 of 2759 transformed modules were lucide-solid icons. With this change: 826 modules; local cold import 27.2s → 12.8s; Rosetta rig (x86, --cpus 1, cold .vite) import 190-290s → 46-69s, strand 0/6 vs 1/6 control (historical cold baseline ~35-50%/run).

Change

  • Per-icon default imports (lucide-solid/icons/<name>) across 54 files — lucide's own recommended pattern for vite dev perf.
  • no-restricted-imports guard in .oxlintrc.json so the barrel can't come back (type-only imports still allowed).
  • lucide-solid ships no "type" field and one ambient .d.ts shared across export conditions, so NodeNext types the per-icon default export as the module namespace (TS2604) — unfixed as of lucide-solid@1.31.0. Wildcard ambient overrides don't work (TS only consults them on resolution miss); each NodeNext package gets one generated lucide-solid-icons.d.ts with exact-specifier augmentation per icon (repo-wide union, identical content). apps/conciv needs none (bundler resolution). Deletable once upstream ships dual declarations.

Verification

  • typecheck 93/93, lint 98/98, build green; ui-kit-system/chat/chat-tools + app suites all green locally.
  • fallow audit --changed-since main: pass, zero INTRODUCED.
  • Rig A/B above; CI hammer on this PR is the decisive strand-rate check.

Closes #389

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Refactor

    • Updated icon usage across the app and UI components without changing appearance or behavior.
    • Improved module configuration for modern bundler-based builds.
  • New Features

    • Added linting that detects and automatically updates legacy icon imports to individual icon modules.
  • Bug Fixes

    • Added handling and diagnostics for unsupported or unresolved icon imports.
  • Tests

    • Added coverage for valid imports, type-only imports, automatic fixes, and unresolved aliases.

…st (#389)

Barrel imports from lucide-solid pulled all ~1700 icon modules through
the vite transform on every cold start (92% of @conciv/app's
vitest-browser cold-start import burst). Converted every value import
across the 54 files that used the barrel to per-icon default imports
resolved from lucide-solid's actual export map, and added a
no-restricted-imports guard so the barrel can't come back (type-only
imports still allowed).

lucide-solid ships no "type": "module" field and shares one ambient
.d.ts across its import/require/browser export conditions, so under
this repo's strict NodeNext module resolution the per-icon default
export types as the whole module namespace instead of the icon
component (TS2604). A wildcard ambient override
(`declare module 'lucide-solid/icons/*'`) does not fix this: TypeScript
only consults wildcard ambient modules when normal resolution fails,
and it succeeds here (just with the wrong shape). Exact-specifier
module augmentation does override the resolved type, so each affected
package gets one generated src/lucide-solid-icons.d.ts (or
src/cards/lucide-solid-icons.d.ts where the cards tsconfig scopes
separately) with one declare-module block per icon in the repo-wide
union, identical content everywhere. apps/conciv needs no shim: its
tsconfig uses moduleResolution: "bundler", which isn't affected.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Aug 12, 2026 •

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The PR adds the conciv/lucide-per-icon Oxlint rule, tests its diagnostics and autofixes, enables it, and converts repository-wide runtime Lucide imports to icon-specific modules. Type-only imports remain separate.

Changes

Lucide direct import migration

Layer / File(s) Summary
Import rule and project wiring
packages/oxlint-plugin/src/*, packages/oxlint-plugin/package.json, .oxlintrc.json, tsconfig.base.json
Adds and registers the rule, configures it as an error, adds its development dependency, and updates module settings.
Rule fixtures and autofix tests
packages/oxlint-plugin/test/*
Tests barrel-import diagnostics, ignored type-only imports, direct imports, unresolved aliases, and autofix behavior.
Runtime icon import migration
apps/conciv/src/**, packages/core/src/**, packages/extensions/**, packages/tools/src/**, packages/ui-kit-chat-tools/src/**, packages/ui-kit-chat/src/**, packages/ui-kit-system/src/**
Replaces lucide-solid barrel imports with individual lucide-solid/icons/* imports without changing component behavior.

Estimated code review effort: 4 (Complex) | ~45 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 3

❌ Failed checks (3 warnings)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning Issue #389 requires an RCA and fix for browser connection and extension teardown failures, but the changes address import performance and linting instead. Add the required RCA and targeted fix for the browser and extension teardown failure, or link this PR to the issue tracking the import-performance work.
Out of Scope Changes check ⚠️ Warning The import migration, Oxlint rule, and TypeScript configuration changes are unrelated to the browser failure and teardown RCA required by issue #389. Remove unrelated performance changes from this PR, or correct the linked issue to match the documented import-performance objectives.
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 clearly summarizes the primary change: replacing lucide-solid barrel imports with per-icon imports to reduce Vite transformation time.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/389-lucide-per-icon-imports

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install failed. For unrecoverable errors, disable the tool in CodeRabbit configuration.


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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
packages/ui-kit-system/src/lucide-solid-icons.d.ts (1)

1-475: 📐 Maintainability & Code Quality | 🔵 Trivial | 🏗️ Heavy lift

11 byte-identical 475-line declaration files. Each file declares the same 66 lucide-solid/icons/* modules with the same body. The shared root cause is the generator: it emits the union of all icons into every package instead of emitting one shared declaration that packages reference. This adds about 5,200 duplicated lines and creates drift risk, because adding one icon requires regenerating 11 files.

Two additional consequences:

  1. Each package declares icons it does not import. For example, the tanstack extension uses one icon.
  2. declare module 'lucide-solid/icons/<name>' is a global augmentation. If two of these packages are ever compiled in one TypeScript program, the duplicate module declarations conflict.

Recommended direction: publish one declaration file from a single shared package, then reference it from each package tsconfig.json through types or an include path. Keep the generator, but have it write one file.

Note the path inconsistency as well: 9 files sit at <package>/src/, but two sit under src/cards/. Align them if the per-package files are kept.

  • packages/ui-kit-system/src/lucide-solid-icons.d.ts#L1-L475: keep this as the single source of truth, or move it to a dedicated types package, and export it for the other packages to reference.
  • packages/core/src/cards/lucide-solid-icons.d.ts#L1-L475: delete and reference the shared declaration; also move out of src/cards/ if the file is kept.
  • packages/extensions/recorder/src/lucide-solid-icons.d.ts#L1-L475: delete and reference the shared declaration.
  • packages/extensions/tanstack/src/lucide-solid-icons.d.ts#L1-L475: delete and reference the shared declaration.
  • packages/extensions/terminal/src/lucide-solid-icons.d.ts#L1-L475: delete and reference the shared declaration.
  • packages/extensions/test-runner/src/lucide-solid-icons.d.ts#L1-L475: delete and reference the shared declaration.
  • packages/extensions/try-it/src/lucide-solid-icons.d.ts#L1-L475: delete and reference the shared declaration.
  • packages/extensions/whiteboard/src/lucide-solid-icons.d.ts#L1-L475: delete and reference the shared declaration.
  • packages/tools/src/cards/lucide-solid-icons.d.ts#L1-L475: delete and reference the shared declaration; also move out of src/cards/ if the file is kept.
  • packages/ui-kit-chat-tools/src/lucide-solid-icons.d.ts#L1-L475: delete and reference the shared declaration.
  • packages/ui-kit-chat/src/lucide-solid-icons.d.ts#L1-L475: delete and reference the shared declaration.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/ui-kit-system/src/lucide-solid-icons.d.ts` around lines 1 - 475,
Replace the generator’s per-package output with one shared declaration
containing the 66 lucide-solid icon modules, keeping
packages/ui-kit-system/src/lucide-solid-icons.d.ts as the source of truth or
moving it to a dedicated types package. Configure every other package to
reference that declaration through its tsconfig types/include settings, and
delete the duplicated files in packages/core/src/cards/lucide-solid-icons.d.ts,
packages/extensions/recorder/src/lucide-solid-icons.d.ts,
packages/extensions/tanstack/src/lucide-solid-icons.d.ts,
packages/extensions/terminal/src/lucide-solid-icons.d.ts,
packages/extensions/test-runner/src/lucide-solid-icons.d.ts,
packages/extensions/try-it/src/lucide-solid-icons.d.ts,
packages/extensions/whiteboard/src/lucide-solid-icons.d.ts,
packages/tools/src/cards/lucide-solid-icons.d.ts,
packages/ui-kit-chat-tools/src/lucide-solid-icons.d.ts, and
packages/ui-kit-chat/src/lucide-solid-icons.d.ts; if retained, move the files
currently under src/cards/ to the common declaration location.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@packages/ui-kit-system/src/lucide-solid-icons.d.ts`:
- Around line 1-475: Replace the generator’s per-package output with one shared
declaration containing the 66 lucide-solid icon modules, keeping
packages/ui-kit-system/src/lucide-solid-icons.d.ts as the source of truth or
moving it to a dedicated types package. Configure every other package to
reference that declaration through its tsconfig types/include settings, and
delete the duplicated files in packages/core/src/cards/lucide-solid-icons.d.ts,
packages/extensions/recorder/src/lucide-solid-icons.d.ts,
packages/extensions/tanstack/src/lucide-solid-icons.d.ts,
packages/extensions/terminal/src/lucide-solid-icons.d.ts,
packages/extensions/test-runner/src/lucide-solid-icons.d.ts,
packages/extensions/try-it/src/lucide-solid-icons.d.ts,
packages/extensions/whiteboard/src/lucide-solid-icons.d.ts,
packages/tools/src/cards/lucide-solid-icons.d.ts,
packages/ui-kit-chat-tools/src/lucide-solid-icons.d.ts, and
packages/ui-kit-chat/src/lucide-solid-icons.d.ts; if retained, move the files
currently under src/cards/ to the common declaration location.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 14fa6ae0-3cd3-474c-865d-2a70ef8f2304

📥 Commits

Reviewing files that changed from the base of the PR and between 7b59af1 and 9a70cbb.

📒 Files selected for processing (66)
  • .oxlintrc.json
  • apps/conciv/src/composer/actions.tsx
  • apps/conciv/src/composer/launch-menu.tsx
  • apps/conciv/src/composer/model-selector.tsx
  • apps/conciv/src/composer/session-selector.tsx
  • apps/conciv/src/pane/grab-reference.tsx
  • apps/conciv/src/pane/indicators.tsx
  • apps/conciv/src/pane/pane-composer.tsx
  • apps/conciv/src/pane/tool-fallback-card.tsx
  • apps/conciv/src/routes/panel.$sessionId.tsx
  • apps/conciv/src/routes/quick.tsx
  • apps/conciv/src/shell/notices.tsx
  • packages/core/src/cards/code-run-card.tsx
  • packages/core/src/cards/lucide-solid-icons.d.ts
  • packages/extensions/recorder/src/client.tsx
  • packages/extensions/recorder/src/lucide-solid-icons.d.ts
  • packages/extensions/recorder/src/tool/card.tsx
  • packages/extensions/tanstack/src/client/inspector-chip.tsx
  • packages/extensions/tanstack/src/lucide-solid-icons.d.ts
  • packages/extensions/terminal/src/client.tsx
  • packages/extensions/terminal/src/client/terminal-actions.tsx
  • packages/extensions/terminal/src/lucide-solid-icons.d.ts
  • packages/extensions/test-runner/src/lucide-solid-icons.d.ts
  • packages/extensions/test-runner/src/tool/card.tsx
  • packages/extensions/try-it/src/client/connect-pane.tsx
  • packages/extensions/try-it/src/lucide-solid-icons.d.ts
  • packages/extensions/whiteboard/src/client.tsx
  • packages/extensions/whiteboard/src/client/inbox.tsx
  • packages/extensions/whiteboard/src/lucide-solid-icons.d.ts
  • packages/extensions/whiteboard/src/tool/canvas/card.tsx
  • packages/extensions/whiteboard/src/tool/comment/card.tsx
  • packages/tools/src/cards/lucide-solid-icons.d.ts
  • packages/tools/src/cards/ui-card.tsx
  • packages/ui-kit-chat-tools/src/lucide-solid-icons.d.ts
  • packages/ui-kit-chat-tools/src/styled/tools/apply-patch-diff.tsx
  • packages/ui-kit-chat-tools/src/styled/tools/bash-card.tsx
  • packages/ui-kit-chat-tools/src/styled/tools/discovered-apis-card.tsx
  • packages/ui-kit-chat-tools/src/styled/tools/file-edit-card.tsx
  • packages/ui-kit-chat-tools/src/styled/tools/file-read-card.tsx
  • packages/ui-kit-chat-tools/src/styled/tools/search-card.tsx
  • packages/ui-kit-chat-tools/src/styled/tools/todo-card.tsx
  • packages/ui-kit-chat-tools/src/styled/tools/tool-lookup-card.tsx
  • packages/ui-kit-chat/src/lucide-solid-icons.d.ts
  • packages/ui-kit-chat/src/styled/action-bar.tsx
  • packages/ui-kit-chat/src/styled/activity.tsx
  • packages/ui-kit-chat/src/styled/attachment-dispatch.tsx
  • packages/ui-kit-chat/src/styled/attachment-ui.tsx
  • packages/ui-kit-chat/src/styled/branch-picker.tsx
  • packages/ui-kit-chat/src/styled/chain-of-thought.stories.tsx
  • packages/ui-kit-chat/src/styled/chain-of-thought.tsx
  • packages/ui-kit-chat/src/styled/composer.tsx
  • packages/ui-kit-chat/src/styled/model-selector.tsx
  • packages/ui-kit-chat/src/styled/now-line.tsx
  • packages/ui-kit-chat/src/styled/thread.tsx
  • packages/ui-kit-chat/src/tools/primitives/status-visual.tsx
  • packages/ui-kit-chat/src/tools/styled/collapsible-card.tsx
  • packages/ui-kit-chat/src/tools/styled/collapsible-section.tsx
  • packages/ui-kit-chat/src/tools/styled/json-tree.tsx
  • packages/ui-kit-chat/src/tools/styled/meta-tool-card.tsx
  • packages/ui-kit-chat/src/tools/styled/note-row.tsx
  • packages/ui-kit-chat/src/tools/styled/permission-card.tsx
  • packages/ui-kit-chat/src/tools/styled/tool-fallback.tsx
  • packages/ui-kit-chat/src/tools/styled/tool-group.tsx
  • packages/ui-kit-chat/src/tools/styled/tool-icon.tsx
  • packages/ui-kit-system/src/lucide-solid-icons.d.ts
  • packages/ui-kit-system/src/toast.tsx

omridevk and others added 2 commits August 12, 2026 10:08
The per-icon lucide-solid default-import fix (previous commit) needed
type shims because lucide-solid ships no "type": "module" field and
shares one ambient .d.ts across its import/require/browser export
conditions. Under NodeNext, TypeScript infers that ambient .d.ts as
CommonJS-implied and applies esModuleInterop synthetic-default
semantics, so a per-icon default import types as the whole module
namespace instead of the icon component. Exact-specifier module
augmentation worked around it, but needed a generated shim file
duplicated into every affected package.

Flip the repo's moduleResolution to "bundler" instead (module:
"ESNext" to match), the same combination apps/conciv already proved
out. Bundler resolution reads a package's conditional exports map
directly rather than inferring an implied module format from a
missing "type" field, so lucide-solid's per-icon subpaths type-check
correctly with zero shims. Removed apps/conciv's now-redundant local
module/moduleResolution override since it's identical to the new
base. No other fallout: the repo's relative imports already carry
".js" extensions, which stay valid path segments under bundler
resolution; tsc only ever emits declarations here (emitDeclarationOnly
via each package's tsconfig.build.json), so no runtime JS output
changes. pnpm release:check (build + publint + attw) is the
artifact-correctness gate that now covers what NodeNext used to check
at the source level.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…static path guard

The static no-restricted-imports entry banning the lucide-solid barrel
only caught the mistake after the fact and offered no fix. Replace it
with an oxlint JS plugin rule that flags any value import from the
'lucide-solid' barrel (type-only imports stay allowed) and, when the
guessed per-icon path actually resolves on disk via the same node
module resolution the runtime uses, autofixes it to per-icon default
imports in one pass, splitting any type-only names into a separate
import type. Icon file names are derived with a plain camelCase to
kebab-case conversion, verified against the real lucide-solid package
export map: it matches the canonical name for the ~86% of icons that
were never renamed, and correctly recognizes when a name is a legacy
alias for a renamed icon (verified with MoreHorizontal, which is not a
mechanical kebab-case of its own name) by reporting without a fix
rather than emitting a guessed, wrong import path.

Added lucide-solid as a devDependency of @conciv/oxlint-plugin so its
own test fixtures can resolve real per-icon paths the same way a
consuming package would.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (2)
packages/oxlint-plugin/src/lucide-per-icon.js (2)

56-65: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Default and namespace barrel imports bypass the rule.

splitSpecifiers drops ImportDefaultSpecifier and ImportNamespaceSpecifier. import * as Icons from 'lucide-solid' therefore produces no diagnostic and still pulls the whole barrel through the transform, which is the cost this PR removes. Add a non-fixable diagnostic for those forms.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/oxlint-plugin/src/lucide-per-icon.js` around lines 56 - 65, Update
splitSpecifiers to detect ImportDefaultSpecifier and ImportNamespaceSpecifier
entries and emit a non-fixable diagnostic for those import forms, while
preserving the existing value/type classification for named ImportSpecifier
entries. Ensure namespace and default barrel imports are not silently accepted
or transformed without reporting.

6-12: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Resolve canonical Lucide icon paths before reporting them as unresolved.

kebabCase maps Grid2x2 to grid-2-x-2 and ArrowUpAZ to arrow-up-az, but the valid entry points are grid-2x2 and arrow-up-a-z. The rule therefore emits barrelImportUnresolved, incorrectly suggests a legacy alias, and cannot autofix these imports. Resolve against the package's icon entry points or try the supported candidate spellings before reporting an icon as unresolved.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/oxlint-plugin/src/lucide-per-icon.js` around lines 6 - 12, Update
the icon-resolution flow that uses kebabCase to resolve canonical Lucide
entry-point names before emitting barrelImportUnresolved. Support candidates
such as grid-2x2 and arrow-up-a-z, resolving against the package’s available
icon paths or supported spelling alternatives; only report unresolved icons and
suggest legacy aliases after all valid candidates fail, while preserving autofix
behavior for resolved imports.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/oxlint-plugin/test/run-lint.ts`:
- Around line 31-40: Update lintFix to wrap scratch-file creation and reading in
a try/finally so rm(scratchAbsolute) always executes, including when readFile or
oxlint fails. Replace the blanket catch around runFile with handling that
suppresses expected non-zero oxlint diagnostic exits while propagating spawn or
tooling failures; preserve the existing returned fixed content behavior and do
not change the test-controlled execFile arguments.

In `@tsconfig.base.json`:
- Around line 6-7: Update the shared tsconfig.base.json compiler settings to use
NodeNext for module and moduleResolution, and move the bundler resolution
setting into the browser-bundled package configurations. Ensure Node-executed
packages inherit NodeNext while browser packages explicitly retain bundler
resolution.

---

Nitpick comments:
In `@packages/oxlint-plugin/src/lucide-per-icon.js`:
- Around line 56-65: Update splitSpecifiers to detect ImportDefaultSpecifier and
ImportNamespaceSpecifier entries and emit a non-fixable diagnostic for those
import forms, while preserving the existing value/type classification for named
ImportSpecifier entries. Ensure namespace and default barrel imports are not
silently accepted or transformed without reporting.
- Around line 6-12: Update the icon-resolution flow that uses kebabCase to
resolve canonical Lucide entry-point names before emitting
barrelImportUnresolved. Support candidates such as grid-2x2 and arrow-up-a-z,
resolving against the package’s available icon paths or supported spelling
alternatives; only report unresolved icons and suggest legacy aliases after all
valid candidates fail, while preserving autofix behavior for resolved imports.
🪄 Autofix

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: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: c7664567-c6c3-4065-b560-8656c1e0a5db

📥 Commits

Reviewing files that changed from the base of the PR and between 9a70cbb and 3cb9bac.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (14)
  • .oxlintrc.json
  • apps/conciv/tsconfig.json
  • packages/oxlint-plugin/package.json
  • packages/oxlint-plugin/src/lucide-per-icon.js
  • packages/oxlint-plugin/src/plugin.js
  • packages/oxlint-plugin/test/fixtures/lucide-per-icon/already-per-icon.tsx
  • packages/oxlint-plugin/test/fixtures/lucide-per-icon/barrel-value-import.tsx
  • packages/oxlint-plugin/test/fixtures/lucide-per-icon/mixed-value-and-type.tsx
  • packages/oxlint-plugin/test/fixtures/lucide-per-icon/type-only-import.tsx
  • packages/oxlint-plugin/test/fixtures/lucide-per-icon/unresolvable-legacy-alias.tsx
  • packages/oxlint-plugin/test/lucide-per-icon.test.ts
  • packages/oxlint-plugin/test/oxlintrc-lucide-per-icon.json
  • packages/oxlint-plugin/test/run-lint.ts
  • tsconfig.base.json
💤 Files with no reviewable changes (1)
  • apps/conciv/tsconfig.json

Comment on lines +31 to +40
export async function lintFix(configFile: string, fixture: string): Promise<string> {
const source = await readFile(join(packageDir, fixture), 'utf8')
const scratchPath = `${fixture}.scratch.tsx`
const scratchAbsolute = join(packageDir, scratchPath)
await writeFile(scratchAbsolute, source)
await runFile(oxlintBin, ['-c', configFile, '--fix', scratchPath], {cwd: packageDir}).catch(() => undefined)
const fixed = await readFile(scratchAbsolute, 'utf8')
await rm(scratchAbsolute)
return fixed
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Guarantee scratch-file cleanup and do not hide oxlint failures.

Two problems in lintFix:

  1. rm(scratchAbsolute) runs only on the success path. If readFile throws, the scratch file stays in test/fixtures/lucide-per-icon/. A leaked .scratch.tsx file is then picked up by later lint runs and can be committed. Move the cleanup into a finally block.

  2. .catch(() => undefined) discards every failure of the oxlint invocation, including a missing binary. lintFix then returns the unmodified source, and the test fails with a message that blames the rule instead of the tooling. oxlint exits non-zero when diagnostics remain, so keep that case silent, but surface spawn failures.

The ast-grep detect-child-process-typescript hint on the execFile import is a false positive here. All arguments are test-controlled literals.

🛡️ Proposed fix
 export async function lintFix(configFile: string, fixture: string): Promise<string> {
   const source = await readFile(join(packageDir, fixture), 'utf8')
   const scratchPath = `${fixture}.scratch.tsx`
   const scratchAbsolute = join(packageDir, scratchPath)
   await writeFile(scratchAbsolute, source)
-  await runFile(oxlintBin, ['-c', configFile, '--fix', scratchPath], {cwd: packageDir}).catch(() => undefined)
-  const fixed = await readFile(scratchAbsolute, 'utf8')
-  await rm(scratchAbsolute)
-  return fixed
+  try {
+    await runFile(oxlintBin, ['-c', configFile, '--fix', scratchPath], {cwd: packageDir}).catch((error: unknown) => {
+      if (isRecord(error) && typeof error.code === 'string') throw error
+      return undefined
+    })
+    return await readFile(scratchAbsolute, 'utf8')
+  } finally {
+    await rm(scratchAbsolute, {force: true})
+  }
 }
🧰 Tools
🪛 ast-grep (0.45.1)

[warning] Importing child_process exposes a command-execution surface; ensure any command/argument built from input is validated, and prefer execFile/spawn with an argument array over exec.
Context: import {execFile} from 'node:child_process'
Note: [CWE-78] Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection').

(detect-child-process-typescript)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/oxlint-plugin/test/run-lint.ts` around lines 31 - 40, Update lintFix
to wrap scratch-file creation and reading in a try/finally so
rm(scratchAbsolute) always executes, including when readFile or oxlint fails.
Replace the blanket catch around runFile with handling that suppresses expected
non-zero oxlint diagnostic exits while propagating spawn or tooling failures;
preserve the existing returned fixed content behavior and do not change the
test-controlled execFile arguments.

Source: Linters/SAST tools

Comment thread tsconfig.base.json
Comment on lines +6 to +7
"module": "ESNext",
"moduleResolution": "bundler",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Description: Find packages that still declare NodeNext and those that run under Node.
fd -t f 'tsconfig*.json' --exclude node_modules --exec sh -c 'printf "== %s\n" "$1"; grep -n "moduleResolution\|\"module\"" "$1"' _ {}
# Check whether AGENTS.md still mandates NodeNext.
rg -n 'NodeNext|moduleResolution' --glob 'AGENTS.md' --glob '**/AGENTS.md'

Repository: conciv-dev/conciv

Length of output: 3910


🏁 Script executed:

#!/bin/bash
set -eu
printf '%s\n' '== instruction and skill files =='
git ls-files '*AGENTS.md' '*CLAUDE.md' '.github/skills/*' | sed -n '1,160p'
printf '%s\n' '== root files =='
git ls-files | sed -n '1,100p'
printf '%s\n' '== candidate instruction text =='
for f in AGENTS.md CLAUDE.md .github/skills/code-review/SKILL.md; do
  if [ -f "$f" ]; then
    printf '\n== %s ==\n' "$f"
    sed -n '1,180p' "$f"
  fi
done
printf '%s\n' '== tsconfig.base.json =='
cat -n tsconfig.base.json
printf '%s\n' '== package config inheritance and scripts =='
for f in packages/{cli,serve,harness,harness-init,core,tools,publish,extension-compiler}/tsconfig.json apps/conciv/tsconfig.json; do
  if [ -f "$f" ]; then
    printf '\n== %s ==\n' "$f"
    cat -n "$f"
  fi
done
printf '%s\n' '== package scripts for candidate Node packages =='
for f in packages/{cli,serve,harness,harness-init,core,tools,publish,extension-compiler}/package.json apps/conciv/package.json; do
  if [ -f "$f" ]; then
    printf '\n== %s ==\n' "$f"
    grep -nE '"(name|type|main|module|exports|bin|scripts)"|"(dev|build|test|start|serve|cli|harness)' "$f" | sed -n '1,100p'
  fi
done

Repository: conciv-dev/conciv

Length of output: 30282


🏁 Script executed:

#!/bin/bash
set -eu
printf '%s\n' '== TanStack Intent skill check =='
pnpm dlx `@tanstack/intent`@latest list
printf '%s\n' '== all tsconfig inheritance and module settings =='
python3 - <<'PY'
import json
from pathlib import Path

for path in sorted(Path('.').rglob('tsconfig*.json')):
    if 'node_modules' in path.parts:
        continue
    try:
        data = json.loads(path.read_text())
    except Exception:
        continue
    compiler = data.get('compilerOptions', {})
    if 'extends' in data or 'module' in compiler or 'moduleResolution' in compiler:
        print(path)
        print('  extends:', data.get('extends'))
        print('  module:', compiler.get('module'))
        print('  moduleResolution:', compiler.get('moduleResolution'))
PY
printf '%s\n' '== build configuration files =='
git ls-files '*tsdown*' '*vite.config.*' '*package.json' | rg '(^|/)(tsdown|vite\.config|package\.json)' | sed -n '1,180p'
printf '%s\n' '== build scripts and tsdown references =='
rg -n '"build"|tsdown|tsconfig' packages/{cli,serve,harness,harness-init,core,tools,publish,extension-compiler} apps/conciv --glob 'package.json' --glob '*.config.*' --glob '*.json' | sed -n '1,220p'

Repository: conciv-dev/conciv

Length of output: 20383


🏁 Script executed:

#!/bin/bash
set -eu
printf '%s\n' '== tsdown configs =='
for f in packages/{cli,serve,harness,harness-init,core,tools,extension-compiler}/tsdown.config.ts; do
  if [ -f "$f" ]; then
    printf '\n== %s ==\n' "$f"
    cat -n "$f"
  fi
done
printf '%s\n' '== package exports and entry fields =='
python3 - <<'PY'
import json
from pathlib import Path

names = {
    'packages/cli/package.json',
    'packages/serve/package.json',
    'packages/harness/package.json',
    'packages/harness-init/package.json',
    'packages/core/package.json',
    'packages/tools/package.json',
    'packages/extension-compiler/package.json',
    'packages/publish/package.json',
}
for name in sorted(names):
    path = Path(name)
    data = json.loads(path.read_text())
    print(f'== {name} ==')
    for key in ('type', 'main', 'module', 'bin', 'exports', 'files'):
        if key in data:
            print(json.dumps({key: data[key]}, indent=2))
PY
printf '%s\n' '== relative imports and require calls in Node-side source =='
rg -n --glob '*.ts' --glob '*.tsx' \
  '(^|[^[:alnum:]_])(import|export)[[:space:]]+[^;]*from[[:space:]]+['"'"'"]\.{1,2}/|(^|[^[:alnum:]_])import[[:space:]]*\\(['"'"'"]\.{1,2}/|(^|[^[:alnum:]_])require[[:space:]]*\\(' \
  packages/{cli,serve,harness,harness-init,core,tools,extension-compiler,publish}/src \
  | sed -n '1,260p'
printf '%s\n' '== build output references =='
rg -n 'bundle|outDir|entry|dts|platform|format|external|unbundle|inlineOnly|input' packages/{cli,serve,harness,harness-init,core,tools,extension-compiler}/tsdown.config.ts

Repository: conciv-dev/conciv

Length of output: 10016


🏁 Script executed:

#!/bin/bash
set -eu
python3 - <<'PY'
import json
import re
from pathlib import Path

packages = [
    Path('packages/cli'),
    Path('packages/serve'),
    Path('packages/harness'),
    Path('packages/harness-init'),
    Path('packages/core'),
    Path('packages/tools'),
    Path('packages/extension-compiler'),
    Path('packages/publish'),
]
pattern = re.compile(
    r"""(?:\b(?:from|import)\s*\(?\s*['"](?P<import>[^'"]+)['"]|\brequire\s*\(\s*['"](?P<require>[^'"]+)['"])"""
)
relative = re.compile(r'^\.\.?/')
extensions = ('.ts', '.tsx', '.mts', '.cts', '.js', '.jsx', '.mjs', '.cjs', '.json')

for package in packages:
    manifest = json.loads((package / 'package.json').read_text())
    print(f'== {package} ({manifest.get("name")}) ==')
    count = 0
    for source in sorted((package / 'src').rglob('*')):
        if source.suffix not in {'.ts', '.tsx', '.mts', '.cts'}:
            continue
        text = source.read_text(errors='replace')
        for match in pattern.finditer(text):
            specifier = match.group('import') or match.group('require')
            if not relative.match(specifier) or specifier.endswith(extensions):
                continue
            count += 1
            target = (source.parent / specifier).resolve()
            candidates = [
                target,
                Path(str(target) + '.ts'),
                Path(str(target) + '.tsx'),
                Path(str(target) + '.mts'),
                Path(str(target) + '.cts'),
                target / 'index.ts',
                target / 'index.tsx',
                target / 'index.mts',
                target / 'index.cts',
            ]
            existing = [str(p) for p in candidates if p.exists()]
            print(f'{source}:{text[:source.read_text().find(chr(10), 0)] if False else ""}{specifier} -> {existing}')
    print(f'extensionless relative specifiers: {count}')
PY
printf '%s\n' '== direct source-entry execution references =='
rg -n 'src/.*\.ts|tsx|tsx|tsx' \
  packages/{cli,serve,harness,harness-init,core,tools,extension-compiler,publish}/package.json \
  package.json turbo.json .github --glob '*.json' --glob '*.yml' --glob '*.yaml' \
  | sed -n '1,180p'
printf '%s\n' '== publish package complete script section =='
sed -n '1,45p' packages/publish/package.json

Repository: conciv-dev/conciv

Length of output: 2858


🏁 Script executed:

#!/bin/bash
set -eu
python3 - <<'PY'
import json
import re
from pathlib import Path

packages = [
    Path('packages/cli'),
    Path('packages/serve'),
    Path('packages/harness'),
    Path('packages/harness-init'),
    Path('packages/core'),
    Path('packages/tools'),
    Path('packages/extension-compiler'),
    Path('packages/publish'),
]
pattern = re.compile(
    r"""(?:\b(?:from|import)\s*\(?\s*['"](?P<import>[^'"]+)['"]|\brequire\s*\(\s*['"](?P<require>[^'"]+)['"])"""
)
relative = re.compile(r'^\.\.?/')
extensions = ('.ts', '.tsx', '.mts', '.cts', '.js', '.jsx', '.mjs', '.cjs', '.json')

for package in packages:
    manifest = json.loads((package / 'package.json').read_text())
    print(f'== {package} ({manifest.get("name")}) ==')
    count = 0
    for source in sorted((package / 'src').rglob('*')):
        if source.suffix not in {'.ts', '.tsx', '.mts', '.cts'}:
            continue
        text = source.read_text(errors='replace')
        for match in pattern.finditer(text):
            specifier = match.group('import') or match.group('require')
            if not relative.match(specifier) or specifier.endswith(extensions):
                continue
            count += 1
            target = (source.parent / specifier).resolve()
            candidates = [
                target,
                Path(str(target) + '.ts'),
                Path(str(target) + '.tsx'),
                Path(str(target) + '.mts'),
                Path(str(target) + '.cts'),
                target / 'index.ts',
                target / 'index.tsx',
                target / 'index.mts',
                target / 'index.cts',
            ]
            existing = [str(p) for p in candidates if p.exists()]
            print(f'{source}:{specifier} -> {existing}')
    print(f'extensionless relative specifiers: {count}')
PY
printf '%s\n' '== direct source-entry execution references =='
rg -n 'src/.*\.ts|tsx|tsx|tsx' \
  packages/{cli,serve,harness,harness-init,core,tools,extension-compiler,publish}/package.json \
  package.json turbo.json .github --glob '*.json' --glob '*.yml' --glob '*.yaml' \
  | sed -n '1,180p'
printf '%s\n' '== publish package complete script section =='
sed -n '1,45p' packages/publish/package.json

Repository: conciv-dev/conciv

Length of output: 2858


🏁 Script executed:

#!/bin/bash
set -eu
printf '%s\n' '== focused diff =='
git diff -- tsconfig.base.json AGENTS.md
printf '%s\n' '== available tool versions =='
command -v node || true
node --version 2>/dev/null || true
command -v tsc || true
tsc --version 2>/dev/null || true
printf '%s\n' '== import and require forms in Node-side source =='
rg -n --glob '*.ts' --glob '*.tsx' \
  '\b(require|import|export)\b' \
  packages/{cli,serve,harness,harness-init,core,tools,extension-compiler,publish}/src \
  | sed -n '1,220p'

Repository: conciv-dev/conciv

Length of output: 21774


🏁 Script executed:

#!/bin/bash
set -eu
tmp="$(mktemp -d)"
trap 'rm -rf "$tmp"' EXIT
mkdir -p "$tmp/src"
cat >"$tmp/src/main.ts" <<'EOF'
import {value} from './dep'
export {value}
EOF
cat >"$tmp/src/dep.ts" <<'EOF'
export const value = 1
EOF
cat >"$tmp/tsconfig.bundler.json" <<'EOF'
{
  "compilerOptions": {
    "target": "ES2022",
    "module": "ESNext",
    "moduleResolution": "bundler",
    "strict": true,
    "noEmit": true
  },
  "include": ["src/**/*.ts"]
}
EOF
cat >"$tmp/tsconfig.nodenext.json" <<'EOF'
{
  "compilerOptions": {
    "target": "ES2022",
    "module": "NodeNext",
    "moduleResolution": "NodeNext",
    "strict": true,
    "noEmit": true
  },
  "include": ["src/**/*.ts"]
}
EOF
printf '%s\n' '== bundler diagnostics =='
tsc -p "$tmp/tsconfig.bundler.json" --pretty false 2>&1 || true
printf '%s\n' '== NodeNext diagnostics =='
tsc -p "$tmp/tsconfig.nodenext.json" --pretty false 2>&1 || true

Repository: conciv-dev/conciv

Length of output: 208


🏁 Script executed:

#!/bin/bash
set -eu
tmp="$(mktemp -d)"
trap 'rm -rf "$tmp"' EXIT
mkdir -p "$tmp/src"
cat >"$tmp/package.json" <<'EOF'
{"type":"module"}
EOF
cat >"$tmp/src/main.ts" <<'EOF'
import {value} from './dep'
export {value}
EOF
cat >"$tmp/src/dep.ts" <<'EOF'
export const value = 1
EOF
cat >"$tmp/tsconfig.bundler.json" <<'EOF'
{
  "compilerOptions": {
    "target": "ES2022",
    "module": "ESNext",
    "moduleResolution": "bundler",
    "strict": true,
    "noEmit": true
  },
  "include": ["src/**/*.ts"]
}
EOF
cat >"$tmp/tsconfig.nodenext.json" <<'EOF'
{
  "compilerOptions": {
    "target": "ES2022",
    "module": "NodeNext",
    "moduleResolution": "NodeNext",
    "strict": true,
    "noEmit": true
  },
  "include": ["src/**/*.ts"]
}
EOF
printf '%s\n' '== bundler diagnostics =='
tsc -p "$tmp/tsconfig.bundler.json" --pretty false 2>&1 || true
printf '%s\n' '== NodeNext diagnostics =='
tsc -p "$tmp/tsconfig.nodenext.json" --pretty false 2>&1 || true

Repository: conciv-dev/conciv

Length of output: 421


Keep NodeNext for Node-executed packages.

tsconfig.base.json sets module to ESNext and moduleResolution to bundler, but AGENTS.md requires NodeNext. Node-side packages inherit this configuration. Restore NodeNext in the shared config and scope bundler to browser-bundled packages.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tsconfig.base.json` around lines 6 - 7, Update the shared tsconfig.base.json
compiler settings to use NodeNext for module and moduleResolution, and move the
bundler resolution setting into the browser-bundled package configurations.
Ensure Node-executed packages inherit NodeNext while browser packages explicitly
retain bundler resolution.

Sources: Coding guidelines, Learnings

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.

Flaky: grab-reference.browser.test.tsx dies with 'Browser connection was closed' + extension teardown unhandled (CI shard-4)

1 participant