File tree Expand file tree Collapse file tree 2 files changed +10
-4
lines changed Expand file tree Collapse file tree 2 files changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -26,6 +26,7 @@ This change log adheres to standards from [Keep a CHANGELOG](https://keepachange
26
26
- [ meta] replace git.io link in comments with the original URL ([ #2444 ] , thanks [ @liby ] )
27
27
- [ Docs] remove global install in readme ([ #2412 ] , thanks [ @aladdin-add ] )
28
28
- [ readme] clarify ` eslint-import-resolver-typescript ` usage ([ #2503 ] , thanks [ @JounQin ] )
29
+ - [ Refactor] ` no-cycle ` : Add per-run caching of traversed paths ([ #2419 ] , thanks [ @nokel81 ] )
29
30
30
31
## [ 2.26.0] - 2022-04-05
31
32
@@ -1004,6 +1005,7 @@ for info on changes for earlier releases.
1004
1005
[ #2466 ] : https://github.com/import-js/eslint-plugin-import/pull/2466
1005
1006
[ #2440 ] : https://github.com/import-js/eslint-plugin-import/pull/2440
1006
1007
[ #2427 ] : https://github.com/import-js/eslint-plugin-import/pull/2427
1008
+ [ #2419 ] : https://github.com/import-js/eslint-plugin-import/pull/2419
1007
1009
[ #2417 ] : https://github.com/import-js/eslint-plugin-import/pull/2417
1008
1010
[ #2411 ] : https://github.com/import-js/eslint-plugin-import/pull/2411
1009
1011
[ #2399 ] : https://github.com/import-js/eslint-plugin-import/pull/2399
Original file line number Diff line number Diff line change @@ -9,7 +9,8 @@ import { isExternalModule } from '../core/importType';
9
9
import moduleVisitor , { makeOptionsSchema } from 'eslint-module-utils/moduleVisitor' ;
10
10
import docsUrl from '../docsUrl' ;
11
11
12
- // todo: cache cycles / deep relationships for faster repeat evaluation
12
+ const traversed = new Set ( ) ;
13
+
13
14
module . exports = {
14
15
meta : {
15
16
type : 'suggestion' ,
@@ -87,7 +88,6 @@ module.exports = {
87
88
}
88
89
89
90
const untraversed = [ { mget : ( ) => imported , route :[ ] } ] ;
90
- const traversed = new Set ( ) ;
91
91
function detectCycle ( { mget, route } ) {
92
92
const m = mget ( ) ;
93
93
if ( m == null ) return ;
@@ -101,7 +101,7 @@ module.exports = {
101
101
// Ignore only type imports
102
102
! isOnlyImportingTypes ,
103
103
) ;
104
-
104
+
105
105
/*
106
106
If cyclic dependency is allowed via dynamic import, skip checking if any module is imported dynamically
107
107
*/
@@ -138,7 +138,11 @@ module.exports = {
138
138
}
139
139
}
140
140
141
- return moduleVisitor ( checkSourceValue , context . options [ 0 ] ) ;
141
+ return Object . assign ( moduleVisitor ( checkSourceValue , context . options [ 0 ] ) , {
142
+ 'Program:exit' : ( ) => {
143
+ traversed . clear ( ) ;
144
+ } ,
145
+ } ) ;
142
146
} ,
143
147
} ;
144
148
You can’t perform that action at this time.
0 commit comments