fix: include Nuxt layers in icon scanner context.#505
Conversation
commit: |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (5)
💤 Files with no reviewable changes (2)
✅ Files skipped from review due to trivial changes (1)
📝 WalkthroughWalkthroughThis PR changes icon usage scanning to cover extended Nuxt layers rather than only the root directory. Estimated code review effort: 2 (Simple) | ~10 minutes Sequence Diagram(s)sequenceDiagram
participant Context as NuxtIconModuleContext
participant Scanner as IconUsageScanner
participant FS as File System
Context->>Scanner: scanFiles(layers.map(l => l.cwd), scannedIcons)
loop for each layer cwd
Scanner->>FS: glob(cwd)
end
Scanner->>Scanner: merge results into files Set
loop for each file
Scanner->>FS: read file
Scanner->>Scanner: extractFromCode(content, set)
end
Scanner-->>Context: scannedIcons updated
Related issues: Addresses reported failure to scan icons referenced in non-component files (e.g., Suggested labels: bug, enhancement, playground Suggested reviewers: antfu, danielroe 🐰 A dummy layer, plucked and grown, 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/scan.ts (1)
53-65: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick winParallelize per-layer globbing and dedupe files.
Sequential
awaitper layer serializes I/O unnecessarily, and overlapping layer directories can cause the same file to be globbed (and later read) more than once.♻️ Suggested refactor
- const files = [] - - for (const layer of nuxt.options._layers) { - files.push(...await glob( - this.globInclude, - { - ignore: this.globExclude, - cwd: layer.cwd, - absolute: true, - expandDirectories: false, - }, - )) - } + const fileResults = await Promise.all( + nuxt.options._layers.map(layer => glob( + this.globInclude, + { + ignore: this.globExclude, + cwd: layer.cwd, + absolute: true, + expandDirectories: false, + }, + )), + ) + const files = [...new Set(fileResults.flat())]🤖 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 `@src/scan.ts` around lines 53 - 65, Parallelize the per-layer globbing in the scan logic by replacing the sequential await inside the nuxt.options._layers loop with concurrent glob calls, then merge the results. In the scan flow around the files collection in the scan routine, dedupe the combined paths before they are returned or read so overlapping layer roots do not produce duplicates. Use the existing globInclude, globExclude, and layer.cwd handling in the same scan path so behavior stays unchanged apart from concurrency and deduplication.
🤖 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 `@dummy/app/components/Dummy.vue`:
- Around line 1-3: Fix the vue/multi-word-component-names lint failure by
renaming the single-word component used in Dummy.vue to a multi-word component
name. Update the component/file to a name like DummyIcon and adjust any
references so the template still renders the Icon correctly. If a single-word
name is truly intended, add the appropriate inline lint disable in the component
definition instead of leaving the current name unchanged.
---
Nitpick comments:
In `@src/scan.ts`:
- Around line 53-65: Parallelize the per-layer globbing in the scan logic by
replacing the sequential await inside the nuxt.options._layers loop with
concurrent glob calls, then merge the results. In the scan flow around the files
collection in the scan routine, dedupe the combined paths before they are
returned or read so overlapping layer roots do not produce duplicates. Use the
existing globInclude, globExclude, and layer.cwd handling in the same scan path
so behavior stays unchanged apart from concurrency and deduplication.
🪄 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: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: bc9b7134-17fc-4845-995a-940f6cd1d4e1
📒 Files selected for processing (4)
dummy/app/components/Dummy.vuedummy/nuxt.config.tsplayground/nuxt.config.tssrc/scan.ts
| <template> | ||
| <Icon name="uil:0-plus" /> | ||
| </template> |
There was a problem hiding this comment.
🩺 Stability & Availability | 🔴 Critical | ⚡ Quick win
Fix lint failure: component name must be multi-word.
CI is failing due to vue/multi-word-component-names. Rename the component (and file) to a multi-word name, e.g. DummyIcon.vue, or add an inline disable if a single-word name is intentional.
🛠️ Suggested fix
-<template>
- <Icon name="uil:0-plus" />
-</template>
+<!-- eslint-disable-next-line vue/multi-word-component-names -->
+<template>
+ <Icon name="uil:0-plus" />
+</template>Or rename dummy/app/components/Dummy.vue to dummy/app/components/DummyIcon.vue and update any references.
📝 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.
| <template> | |
| <Icon name="uil:0-plus" /> | |
| </template> | |
| <!-- eslint-disable-next-line vue/multi-word-component-names --> | |
| <template> | |
| <Icon name="uil:0-plus" /> | |
| </template> |
🧰 Tools
🪛 ESLint
[error] 1-1: Component name "Dummy" should always be multi-word.
(vue/multi-word-component-names)
🪛 GitHub Actions: ci-main / 0_ci (ubuntu-latest, lts_).txt
[error] 1-1: ESLint (vue/multi-word-component-names): Component name "Dummy" should always be multi-word
🪛 GitHub Actions: ci-main / ci (ubuntu-latest, lts_)
[error] 1-1: ESLint (vue/multi-word-component-names): Component name "Dummy" should always be multi-word
[error] 1-1: Command failed: "npm run lint" (eslint .) reported 1 error
🪛 GitHub Check: ci (ubuntu-latest, lts/*)
[failure] 1-1:
Component name "Dummy" should always be multi-word
🤖 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 `@dummy/app/components/Dummy.vue` around lines 1 - 3, Fix the
vue/multi-word-component-names lint failure by renaming the single-word
component used in Dummy.vue to a multi-word component name. Update the
component/file to a name like DummyIcon and adjust any references so the
template still renders the Icon correctly. If a single-word name is truly
intended, add the appropriate inline lint disable in the component definition
instead of leaving the current name unchanged.
Sources: Linters/SAST tools, Pipeline failures
|
I've provided the link to a reproduction of the problem this PR fixes. Summary |
🔗 Linked issue
This pull request resolves #358
📚 Description
nuxt.options._layersinstead of onlynuxt.options.rootDirnuxt.configinplaygroundadds../dummylayer for testing external layer resolution