refactor(linter): share edit-distance typo matching#18544
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. |
There was a problem hiding this comment.
Pull request overview
This PR refactors typo-matching logic by extracting a shared edit-distance utility that can be reused across multiple linter rules. The change improves code maintainability by eliminating duplicated logic.
Changes:
- Introduces a new
edit_distanceutility module with Levenshtein distance calculation and best-match finding - Refactors
nextjs/no_typosto use the shared utility instead of local implementation - Refactors
eslint/valid_typeofto use edit distance matching instead of hardcoded typo patterns
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| crates/oxc_linter/src/utils/mod.rs | Adds module declaration and exports for the new edit_distance utility |
| crates/oxc_linter/src/utils/edit_distance.rs | New utility module providing min_edit_distance and best_match functions for typo detection |
| crates/oxc_linter/src/rules/nextjs/no_typos.rs | Replaces local edit distance implementation with shared utility |
| crates/oxc_linter/src/rules/eslint/valid_typeof.rs | Replaces hardcoded typo patterns with edit distance matching (threshold=2) |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Merge activity
|
b4279f4 to
59e5de5
Compare

No description provided.