Skip to content

Commit 0307ff2

Browse files
authored
revert(#111): remove scc (#118)
1 parent 38aa4cb commit 0307ff2

File tree

8 files changed

+8
-307
lines changed

8 files changed

+8
-307
lines changed

.changeset/hungry-clocks-pretend.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"eslint-plugin-import-x": patch
3+
---
4+
5+
Reverts #111. The introduction of SCC causes extra overhead that overcomes the early return it introduced.
6+
7+
A new `no-cycle-next` rule is being implemented using the graph. It won't be backward compatible with the current rule `no-cycle`. The current `no-cycle` rule will become `no-cycle-legacy` in the next major version.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@
4848
"eslint": "^8.56.0 || ^9.0.0-0"
4949
},
5050
"dependencies": {
51-
"@rtsao/scc": "^1.1.0",
5251
"@typescript-eslint/utils": "^7.4.0",
5352
"debug": "^4.3.4",
5453
"doctrine": "^3.0.0",

src/rules/no-cycle.ts

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import type { DeclarationMetadata, ModuleOptions } from '../utils'
66
import {
77
ExportMap,
8-
StronglyConnectedComponents,
98
isExternalModule,
109
createRule,
1110
moduleVisitor,
@@ -89,8 +88,6 @@ export = createRule<[Options?], MessageId>({
8988
isExternalModule(name, resolve(name, context)!, context)
9089
: () => false
9190

92-
const scc = StronglyConnectedComponents.get(filename, context)
93-
9491
return {
9592
...moduleVisitor(function checkSourceValue(sourceNode, importer) {
9693
if (ignoreModule(sourceNode.value)) {
@@ -130,18 +127,6 @@ export = createRule<[Options?], MessageId>({
130127
return // no-self-import territory
131128
}
132129

133-
/* If we're in the same Strongly Connected Component,
134-
* Then there exists a path from each node in the SCC to every other node in the SCC,
135-
* Then there exists at least one path from them to us and from us to them,
136-
* Then we have a cycle between us.
137-
*/
138-
if (scc) {
139-
const hasDependencyCycle = scc[filename] === scc[imported.path]
140-
if (!hasDependencyCycle) {
141-
return
142-
}
143-
}
144-
145130
const untraversed: Traverser[] = [{ mget: () => imported, route: [] }]
146131

147132
function detectCycle({ mget, route }: Traverser) {

src/utils/export-map.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1094,7 +1094,7 @@ export function recursivePatternCapture(
10941094
* don't hold full context object in memory, just grab what we need.
10951095
* also calculate a cacheKey, where parts of the cacheKey hash are memoized
10961096
*/
1097-
export function childContext(
1097+
function childContext(
10981098
path: string,
10991099
context: RuleContext | ChildContext,
11001100
): ChildContext {

src/utils/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ export * from './pkg-dir'
1717
export * from './pkg-up'
1818
export * from './read-pkg-up'
1919
export * from './resolve'
20-
export * from './scc'
2120
export * from './static-require'
2221
export * from './unambiguous'
2322
export * from './visit'

src/utils/scc.ts

Lines changed: 0 additions & 91 deletions
This file was deleted.

test/utils/scc.spec.ts

Lines changed: 0 additions & 193 deletions
This file was deleted.

yarn.lock

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1886,11 +1886,6 @@
18861886
dependencies:
18871887
"@xml-tools/parser" "^1.0.11"
18881888

1889-
"@rtsao/scc@^1.1.0":
1890-
version "1.1.0"
1891-
resolved "https://registry.yarnpkg.com/@rtsao/scc/-/scc-1.1.0.tgz#927dd2fae9bc3361403ac2c7a00c32ddce9ad7e8"
1892-
integrity sha512-zt6OdqaDoOnJ1ZYsCYGt9YmWzDXl4vQdKTyJev62gFhRGKdx7mcT54V9KIjg+d2wi9EXsPvAPKe7i7WjfVWB8g==
1893-
18941889
"@sinclair/typebox@^0.27.8":
18951890
version "0.27.8"
18961891
resolved "https://registry.yarnpkg.com/@sinclair/typebox/-/typebox-0.27.8.tgz#6667fac16c436b5434a387a34dedb013198f6e6e"

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy