@@ -127,7 +127,7 @@ const schema: JSONSchema4[] = [
127127/**
128128 * The default options for the rule.
129129 */
130- const defaultOptions : RawOptions = [
130+ const defaultOptions = [
131131 {
132132 allowRestParameter : false ,
133133 allowArgumentsKeyword : false ,
@@ -138,7 +138,7 @@ const defaultOptions: RawOptions = [
138138 ignoreGettersAndSetters : true ,
139139 } ,
140140 } ,
141- ] ;
141+ ] satisfies RawOptions ;
142142
143143/**
144144 * The possible error messages.
@@ -234,6 +234,29 @@ function getParamCountViolations(
234234 return [ ] ;
235235}
236236
237+ /**
238+ * Add the default options to the given options.
239+ */
240+ function getOptionsWithDefaults ( options : Readonly < Options > | null ) : Options {
241+ if ( options === null ) {
242+ return defaultOptions [ 0 ] ;
243+ }
244+
245+ const topLevel = {
246+ ...defaultOptions [ 0 ] ,
247+ ...options ,
248+ } ;
249+ return typeof topLevel . enforceParameterCount === "object"
250+ ? {
251+ ...topLevel ,
252+ enforceParameterCount : {
253+ ...defaultOptions [ 0 ] . enforceParameterCount ,
254+ ...topLevel . enforceParameterCount ,
255+ } ,
256+ }
257+ : topLevel ;
258+ }
259+
237260/**
238261 * Check if the given function node has a reset parameter this rule.
239262 */
@@ -243,10 +266,8 @@ function checkFunction(
243266 rawOptions : Readonly < RawOptions > ,
244267) : RuleResult < keyof typeof errorMessages , RawOptions > {
245268 const options = upgradeRawOverridableOptions ( rawOptions [ 0 ] ) ;
246- const optionsToUse = getCoreOptions < CoreOptions , Options > (
247- node ,
248- context ,
249- options ,
269+ const optionsToUse = getOptionsWithDefaults (
270+ getCoreOptions < CoreOptions , Options > ( node , context , options ) ,
250271 ) ;
251272
252273 if ( optionsToUse === null ) {
@@ -291,10 +312,11 @@ function checkIdentifier(
291312
292313 const functionNode = getEnclosingFunction ( node ) ;
293314 const options = upgradeRawOverridableOptions ( rawOptions [ 0 ] ) ;
294- const optionsToUse =
315+ const optionsToUse = getOptionsWithDefaults (
295316 functionNode === null
296317 ? options
297- : getCoreOptions < CoreOptions , Options > ( functionNode , context , options ) ;
318+ : getCoreOptions < CoreOptions , Options > ( functionNode , context , options ) ,
319+ ) ;
298320
299321 if ( optionsToUse === null ) {
300322 return {
0 commit comments