Repository navigation
chore: forbid circular imports with import/no-cycle - #2190
Merged
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Enable oxlint's import plugin and turn on import/no-cycle as an error so that a new import cycle fails `yarn lint` in CI. Type-only imports are ignored (`ignoreTypes`) because they are erased at build time. The compat Toolkit type imports form a cycle that has no effect at runtime. The only cycle left in src is the serialize recursion: serializeValue dispatches to serializeObject, which calls back into serializeValue through serializePlainObject and compareValues. Each of those imports is only used at call time, never while the module is being evaluated, so they carry an inline disable comment instead of being merged into one file. The rule adds about 0.2s to a full oxlint run.
raon0211
force-pushed
the
chore/no-cycle
branch
from
November 6, 2026 00:55
91b7190 to
7011792
Compare
This branch was successfully deployed
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.
Summary
Follow-up to #2189. This turns on oxlint's
import/no-cycleas an error, so a PR that introduces a circular import failsyarn lint. CI already lints every file.ignoreTypes: type-only imports are erased at build time, so they cannot cause evaluation-order problems. The one existing type-only cycle (compat/function/partial.ts/partialRight.ts→compat/toolkit.ts→compat/compat.ts) is left alone.srcis theutil/serializerecursion.serializeValue→serializeObject→serializePlainObject/compareValues→serializeValue. These functions are mutually recursive by design, and each import is used only at call time, never while the module is evaluated. So the six imports get an inlineoxlint-disable-next-line ... -- reasoncomment instead of the four files being merged into one.oxlintrun goes from about 4.4s to about 4.6s.Verification
I added a cycle temporarily and checked that the rule reports it, then reverted:
src/array/chunk.tsimports from../index.tssrc/compat/array/every.tsimports from../compat.tspartial.ts→toolkit.tsasimport type(current code)Linting one file is enough. oxlint follows the module graph, so
yarn oxlint src/array/chunk.tsreports the cycle on its own.Test plan
yarn lint: 0 errorsyarn format:checkyarn vitest run src/util/serialize