Repository navigation
Conversation
Return before import classification for specifiers that cannot be parent, index, or sibling imports. Reuse the existing lexical checks and retain classification for relative imports so internal-regex settings keep their precedence. Add resolver-backed regression coverage to ensure non-relative imports are not resolved and relative imports retain their existing behavior.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3298 +/- ##
==========================================
+ Coverage 79.59% 79.63% +0.03%
==========================================
Files 98 98
Lines 4549 4551 +2
Branches 1543 1576 +33
==========================================
+ Hits 3621 3624 +3
+ Misses 928 927 -1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
no-relative-packagescallsimportType()for every import, re-export andrequireit visits.importType()resolves the specifier before it classifies it, so every bare specifier (some-package,@scope/package/subpath) goes through the configured resolver:node_moduleslookups,package.jsonreads and entry-point probes.The rule only reports
parent,indexandsiblingimports, and those types come from the specifier text alone. Resolving a non-relative specifier can never change the result.The extra resolution costs time in large projects, and it touches files the rule does not need, such as the entry points of other packages in a monorepo. That matters for tools that sandbox or track file accesses.
Change
isRelativeToParent,isIndexandisRelativeToSibling, now exported fromsrc/core/importType.js.import/internal-regextaking precedence.Tests
requirecalls with a resolver that throws: each one produced a "Resolve error" before this change; now none is resolved.internal-regexprecedence keep their results.importTypetests: 36 passing.