@@ -3,13 +3,13 @@ import path from 'node:path'
33
44import type { TSESLint , TSESTree } from '@typescript-eslint/utils'
55import debug from 'debug'
6- import { dequal } from 'dequal'
76import type { Annotation } from 'doctrine'
87import doctrine from 'doctrine'
98import type { AST } from 'eslint'
109import { SourceCode } from 'eslint'
1110import type { TsConfigJsonResolved } from 'get-tsconfig'
1211import { getTsconfig } from 'get-tsconfig'
12+ import stableHash from 'stable-hash'
1313
1414import type {
1515 ChildContext ,
@@ -1103,44 +1103,19 @@ function childContext(
11031103 }
11041104}
11051105
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-
11281106function makeContextCacheKey ( context : RuleContext | ChildContext ) {
11291107 const { settings, parserPath, parserOptions, languageOptions } = context
11301108
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 )
11361112
11371113 if ( languageOptions ) {
1138- const { ecmaVersion , sourceType } = languageOptions
1139- hash += String ( ecmaVersion ) + String ( sourceType )
1114+ hash +=
1115+ String ( languageOptions . ecmaVersion ) + String ( languageOptions . sourceType )
11401116 }
11411117
1142- hash += getOptionsVersion (
1143- 'parser' ,
1118+ hash += stableHash (
11441119 parserPath ?? languageOptions ?. parser ?. meta ?? languageOptions ?. parser ,
11451120 )
11461121
0 commit comments