@@ -3,6 +3,7 @@ import path from 'node:path'
33
44import type { TSESLint , TSESTree } from '@typescript-eslint/utils'
55import debug from 'debug'
6+ import { dequal } from 'dequal'
67import type { Annotation } from 'doctrine'
78import doctrine from 'doctrine'
89import type { AST } from 'eslint'
@@ -1102,21 +1103,29 @@ function childContext(
11021103 }
11031104}
11041105
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+ }
11091117
1110- function getOptionsHash ( key : string , value : unknown ) {
1118+ function getOptionsHash ( key : keyof OptionsHashesCache , value : unknown ) {
11111119 const entry = optionsHashesCache [ key ]
1112- const stringifiedValue = JSON . stringify ( value )
11131120
1114- if ( stringifiedValue === entry ? .value ) {
1121+ if ( dequal ( value , entry . value ) ) {
11151122 return entry . hash
11161123 }
11171124
11181125 const hash = hashify ( value ) . digest ( 'hex' )
1119- optionsHashesCache [ key ] = { value : stringifiedValue , hash }
1126+
1127+ optionsHashesCache [ key ] . value = value
1128+ optionsHashesCache [ key ] . hash = hash
11201129
11211130 return hash
11221131}
0 commit comments