-
-
Notifications
You must be signed in to change notification settings - Fork 721
perf(linter): cache file extension #14794
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
CodSpeed Performance ReportMerging #14794 will not alter performanceComparing Summary
Footnotes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR optimizes linter performance by caching file extensions to avoid repeated computation. Instead of calling file_path().extension() multiple times across different rules, the file extension is now computed once during context initialization and stored for reuse.
- Adds
file_extension()method toContextHostandLintContextthat returns cached extension - Updates all Vue, React, Jest, ESLint, and Unicorn rules to use the new cached method
- Removes redundant imports and simplifies extension checking logic in several files
Reviewed Changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| crates/oxc_linter/src/context/host.rs | Adds file extension caching field and getter method to ContextHost |
| crates/oxc_linter/src/context/mod.rs | Adds file_extension() method to LintContext that delegates to ContextHost |
| crates/oxc_linter/src/rules/vue/*.rs | Updates Vue rules to use cached file extension method |
| crates/oxc_linter/src/rules/react/*.rs | Updates React rules to use cached file extension method |
| crates/oxc_linter/src/rules/jest/no_large_snapshots.rs | Simplifies snapshot file detection using cached extension |
| crates/oxc_linter/src/rules/eslint/*.rs | Updates ESLint rules to use cached file extension method |
| crates/oxc_linter/src/rules/unicorn/no_empty_file.rs | Optimizes extension comparison using cached method |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
|
Interesting to see this is hot 🤯 |
Merge activity
|
Getting file extensions shows up as slow in multiple rules. Computing it once and then storing it should be much faster. <img width="713" height="366" alt="Screenshot 2025-10-20 at 12 00 35 AM" src="https://github.com/user-attachments/assets/b074bbf1-8a1f-4910-98d0-40f66eb3b39c" />
8a1a226 to
7be9489
Compare

Getting file extensions shows up as slow in multiple rules. Computing it once and then storing it should be much faster.