@@ -21,7 +21,7 @@ import type {
21
21
} from '../types'
22
22
23
23
import { getValue } from './get-value'
24
- import { hashObject , hashify } from './hash'
24
+ import { hashObject } from './hash'
25
25
import { hasValidExtension , ignore } from './ignore'
26
26
import { parse } from './parse'
27
27
import { relative , resolve } from './resolve'
@@ -1103,55 +1103,46 @@ function childContext(
1103
1103
}
1104
1104
}
1105
1105
1106
- type OptionsHashesCache = Record <
1107
- 'settings' | 'parserOptions' | 'parserMeta ' ,
1108
- { value : unknown ; hash : string }
1106
+ type OptionsVersionsCache = Record <
1107
+ 'settings' | 'parserOptions' | 'parser ' ,
1108
+ { value : unknown ; version : number }
1109
1109
>
1110
1110
1111
- const optionsHashesCache : OptionsHashesCache = {
1112
- settings : { value : null , hash : '' } ,
1113
- parserOptions : { value : null , hash : '' } ,
1114
- parserMeta : { value : null , hash : '' } ,
1111
+ const optionsVersionsCache : OptionsVersionsCache = {
1112
+ settings : { value : null , version : 0 } ,
1113
+ parserOptions : { value : null , version : 0 } ,
1114
+ parser : { value : null , version : 0 } ,
1115
1115
}
1116
1116
1117
- function getOptionsHash ( key : keyof OptionsHashesCache , value : unknown ) {
1118
- const entry = optionsHashesCache [ key ]
1117
+ function getOptionsVersion ( key : keyof OptionsVersionsCache , value : unknown ) {
1118
+ const entry = optionsVersionsCache [ key ]
1119
1119
1120
- if ( dequal ( value , entry . value ) ) {
1121
- return entry . hash
1120
+ if ( ! dequal ( value , entry . value ) ) {
1121
+ entry . value = value
1122
+ entry . version += 1
1122
1123
}
1123
1124
1124
- const hash = hashify ( value ) . digest ( 'hex' )
1125
-
1126
- optionsHashesCache [ key ] . value = value
1127
- optionsHashesCache [ key ] . hash = hash
1128
-
1129
- return hash
1125
+ return String ( entry . version )
1130
1126
}
1131
1127
1132
1128
function makeContextCacheKey ( context : RuleContext | ChildContext ) {
1133
1129
const { settings, parserPath, parserOptions, languageOptions } = context
1134
1130
1135
- let hash = getOptionsHash ( 'settings' , settings )
1131
+ let hash = getOptionsVersion ( 'settings' , settings )
1136
1132
1137
1133
const usedParserOptions = languageOptions ?. parserOptions ?? parserOptions
1138
1134
1139
- hash += getOptionsHash ( 'parserOptions' , usedParserOptions )
1135
+ hash += getOptionsVersion ( 'parserOptions' , usedParserOptions )
1140
1136
1141
1137
if ( languageOptions ) {
1142
1138
const { ecmaVersion, sourceType } = languageOptions
1143
1139
hash += String ( ecmaVersion ) + String ( sourceType )
1144
1140
}
1145
1141
1146
- if ( parserPath ) {
1147
- hash += parserPath
1148
- } else {
1149
- const { meta } = languageOptions ?. parser ?? { }
1150
-
1151
- if ( meta ) {
1152
- hash += getOptionsHash ( 'parserMeta' , meta )
1153
- }
1154
- }
1142
+ hash += getOptionsVersion (
1143
+ 'parser' ,
1144
+ parserPath ?? languageOptions ?. parser ?. meta ?? languageOptions ?. parser ,
1145
+ )
1155
1146
1156
1147
return hash
1157
1148
}
0 commit comments