@@ -3,6 +3,7 @@ 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'
6
7
import type { Annotation } from 'doctrine'
7
8
import doctrine from 'doctrine'
8
9
import type { AST } from 'eslint'
@@ -1102,21 +1103,29 @@ function childContext(
1102
1103
}
1103
1104
}
1104
1105
1105
- const optionsHashesCache : Record <
1106
- string ,
1107
- { value : string ; hash : string } | undefined
1108
- > = { }
1106
+ type OptionsHashesCache = Record <
1107
+ 'settings' | 'parserOptions' | 'parserMeta' | 'languageOptions' ,
1108
+ { value : unknown ; hash : string }
1109
+ >
1110
+
1111
+ const optionsHashesCache : OptionsHashesCache = {
1112
+ settings : { value : null , hash : '' } ,
1113
+ parserOptions : { value : null , hash : '' } ,
1114
+ parserMeta : { value : null , hash : '' } ,
1115
+ languageOptions : { value : null , hash : '' } ,
1116
+ }
1109
1117
1110
- function getOptionsHash ( key : string , value : unknown ) {
1118
+ function getOptionsHash ( key : keyof OptionsHashesCache , value : unknown ) {
1111
1119
const entry = optionsHashesCache [ key ]
1112
- const stringifiedValue = JSON . stringify ( value )
1113
1120
1114
- if ( stringifiedValue === entry ? .value ) {
1121
+ if ( dequal ( value , entry . value ) ) {
1115
1122
return entry . hash
1116
1123
}
1117
1124
1118
1125
const hash = hashify ( value ) . digest ( 'hex' )
1119
- optionsHashesCache [ key ] = { value : stringifiedValue , hash }
1126
+
1127
+ optionsHashesCache [ key ] . value = value
1128
+ optionsHashesCache [ key ] . hash = hash
1120
1129
1121
1130
return hash
1122
1131
}
0 commit comments