@@ -3,13 +3,13 @@ import path from 'node:path'
3
3
4
4
import type { TSESLint , TSESTree } from '@typescript-eslint/utils'
5
5
import debug from 'debug'
6
- import { dequal } from 'dequal'
7
6
import type { Annotation } from 'doctrine'
8
7
import doctrine from 'doctrine'
9
8
import type { AST } from 'eslint'
10
9
import { SourceCode } from 'eslint'
11
10
import type { TsConfigJsonResolved } from 'get-tsconfig'
12
11
import { getTsconfig } from 'get-tsconfig'
12
+ import stableHash from 'stable-hash'
13
13
14
14
import type {
15
15
ChildContext ,
@@ -1103,44 +1103,19 @@ function childContext(
1103
1103
}
1104
1104
}
1105
1105
1106
- type OptionsVersionsCache = Record <
1107
- 'settings' | 'parserOptions' | 'parser' ,
1108
- { value : unknown ; version : number }
1109
- >
1110
-
1111
- const optionsVersionsCache : OptionsVersionsCache = {
1112
- settings : { value : null , version : 0 } ,
1113
- parserOptions : { value : null , version : 0 } ,
1114
- parser : { value : null , version : 0 } ,
1115
- }
1116
-
1117
- function getOptionsVersion ( key : keyof OptionsVersionsCache , value : unknown ) {
1118
- const entry = optionsVersionsCache [ key ]
1119
-
1120
- if ( ! dequal ( value , entry . value ) ) {
1121
- entry . value = value
1122
- entry . version += 1
1123
- }
1124
-
1125
- return String ( entry . version )
1126
- }
1127
-
1128
1106
function makeContextCacheKey ( context : RuleContext | ChildContext ) {
1129
1107
const { settings, parserPath, parserOptions, languageOptions } = context
1130
1108
1131
- let hash = getOptionsVersion ( 'settings' , settings )
1132
-
1133
- const usedParserOptions = languageOptions ?. parserOptions ?? parserOptions
1134
-
1135
- hash += getOptionsVersion ( 'parserOptions' , usedParserOptions )
1109
+ let hash =
1110
+ stableHash ( settings ) +
1111
+ stableHash ( languageOptions ?. parserOptions ?? parserOptions )
1136
1112
1137
1113
if ( languageOptions ) {
1138
- const { ecmaVersion , sourceType } = languageOptions
1139
- hash += String ( ecmaVersion ) + String ( sourceType )
1114
+ hash +=
1115
+ String ( languageOptions . ecmaVersion ) + String ( languageOptions . sourceType )
1140
1116
}
1141
1117
1142
- hash += getOptionsVersion (
1143
- 'parser' ,
1118
+ hash += stableHash (
1144
1119
parserPath ?? languageOptions ?. parser ?. meta ?? languageOptions ?. parser ,
1145
1120
)
1146
1121
0 commit comments