Repository navigation
fix(core): give PERF009 findings a real line number - #200
Conversation
PERF009 (heavy dependency import) always reported line: 0 because it
sourced its data from `imports: string[]`, which never tracked line
numbers. Since component-rule's suppression check only looks up a
`svelte-vitals-disable-next-line` directive when a finding's line > 0,
PERF009 findings could never be suppressed.
ComponentFacts gains `importSpans: { source: string; line: number }[]`
(alongside the untouched `imports` field), collected the same way
PERF010's `namespaceImports` already is. PERF009 now reports the real
import line, so suppression directives work like every other rule.
|
Warning Review limit reached
Next review available in: 6 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (1)
📝 WalkthroughWalkthroughAdds line-aware ChangesPERF009 line tracking
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
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.
Pull request overview
This PR fixes a long-standing issue where PERF009 findings always reported line: 0, which prevented svelte-vitals-disable-next-line PERF009 suppression directives from matching. It extends component import facts to include per-import line numbers and updates the PERF009 rule and tests accordingly.
Changes:
- Add
ComponentFacts.importSpans(module specifier + source line) and deriveimportsfrom it during parsing. - Update
PERF009to iterateimportSpansand emit findings with real line numbers (including dedupe “first-seen line” behavior). - Update unit/E2E tests and generated action dist output to include the new required
importSpansfield and add suppression regression coverage.
Reviewed changes
Copilot reviewed 13 out of 14 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| packages/core/src/component.ts | Extends ComponentFacts with importSpans to carry import line info. |
| packages/core/src/component-parse.ts | Collects import spans (specifier + line) and derives imports from them. |
| packages/core/src/component-collect.ts | Ensures emptyComponentFacts initializes importSpans. |
| packages/core/src/rules/perf/perf009-heavy-import.ts | Switches PERF009 to use import spans so findings have real line numbers. |
| packages/core/test/bundle-rules.test.ts | Adds PERF009 line-number + suppression regression tests; adapts fixtures to importSpans. |
| packages/core/test/component-collect.test.ts | Updates empty facts expectations to include importSpans. |
| packages/core/test/component-rule.test.ts | Updates ComponentFacts test helper defaults to include importSpans. |
| packages/core/test/architecture-rules.test.ts | Updates ComponentFacts test helper defaults to include importSpans. |
| packages/core/test/correctness-rules.test.ts | Updates ComponentFacts test helper defaults to include importSpans. |
| packages/core/test/security-rules.test.ts | Updates ComponentFacts test helper defaults to include importSpans. |
| packages/cli/test/suppression-e2e.test.ts | Updates ComponentFacts test helper defaults to include importSpans. |
| packages/cli/test/malformed-svelte.test.ts | Updates malformed-file fixtures to include importSpans. |
| packages/action/dist/index.js | Regenerates the action bundle to reflect core’s import span changes. |
| .changeset/perf009-line-tracking.md | Adds a changeset documenting the PERF009 line-number fix and new importSpans. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| applies: (c) => c.importSpans.length > 0, | ||
| bad: (c) => { | ||
| // `Object.hasOwn` (not `in`) so inherited keys like `toString` never match; | ||
| // dedupe so the same package imported in both scripts isn't double-penalized. | ||
| const seen = new Set<string>(); | ||
| const out: { line: number; message: string }[] = []; | ||
| for (const src of c.imports) { | ||
| for (const { source: src, line } of c.importSpans) { | ||
| if (!Object.hasOwn(HEAVY_PACKAGES, src) || seen.has(src)) continue; | ||
| seen.add(src); | ||
| out.push({ line: 0, message: `Heavy import "${src}" — ${HEAVY_PACKAGES[src]}` }); | ||
| out.push({ line, message: `Heavy import "${src}" — ${HEAVY_PACKAGES[src]}` }); | ||
| } |
Summary
line: 0, silently defeatingsvelte-vitals-disable-next-line PERF009suppression directives.ComponentFacts.importSpans(source + line per import) alongside the existingimports: string[], and switches PERF009 to use it.Test plan
pnpm --filter @svelte-vitals/core test— 401/401 passing, including new line-number and suppression regression tests.pnpm --filter svelte-vitals test— 563/563 passing (fixtures updated for the new required field).@svelte-vitals/coreminor).Generated via an
/improveadvisor session, planplans/028-perf009-line-tracking.md.🤖 Generated with Claude Code
Summary by CodeRabbit
// svelte-vitals-disable-next-line PERF009suppression directives now work reliably.