Menu

Post image 1
Post image 2
1 / 2
0

import-next/no-cycle Reported 0 Cycles on Next.js. We Found Why — and Fixed It.

DEV Community: node·Ofri Peretz·3 days ago
#JJQRNg5x
#dev#cycle#file#rule#cycles#import
Reading 0:00
15s threshold

We benchmarked import-next/no-cycle against eslint-plugin-import/no-cycle and oxlint on next.js — 131K stars, 14,556 source files. Both ESLint plugins agreed: 0 cycles . oxlint disagreed: 17 cycles . We trusted the consensus. Then we scoped the same rules to a 33-file subset of the same repo and ran again. Our rule found 5+ cycles immediately. Same config. Same files. Different scope. Different answer. That's not a fluke — it's a symptom. We audited the rule and found two bugs. Both are now fixed. Here's what they were. Bug 1: A depth limit of 10 that silently missed 12-hop cycles The original default in import-next/no-cycle was maxDepth: 10 . Reasonable assumption: most import chains are shallow. Real codebases disagree. Next.js's webpack-config.ts has a cycle approximately 12 hops deep. With maxDepth: 10 , the DFS stops at hop 10, marks those files as explored, and reports no cycle. The traversal never reaches the closing edge that would have revealed it. The failure mode is invisible.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.

Read More