@@ -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,31 @@ function getParamCountViolations(
234234 return [ ] ;
235235}
236236
237+ /**
238+ * Add the default options to the given options.
239+ */
240+ function getOptionsWithDefaults (
241+ options : Readonly < Options > | null ,
242+ ) : Options | null {
243+ if ( options === null ) {
244+ return null ;
245+ }
246+
247+ const topLevel = {
248+ ...defaultOptions [ 0 ] ,
249+ ...options ,
250+ } ;
251+ return typeof topLevel . enforceParameterCount === "object"
252+ ? {
253+ ...topLevel ,
254+ enforceParameterCount : {
255+ ...defaultOptions [ 0 ] . enforceParameterCount ,
256+ ...topLevel . enforceParameterCount ,
257+ } ,
258+ }
259+ : topLevel ;
260+ }
261+
237262/**
238263 * Check if the given function node has a reset parameter this rule.
239264 */
@@ -243,10 +268,8 @@ function checkFunction(
243268 rawOptions : Readonly < RawOptions > ,
244269) : RuleResult < keyof typeof errorMessages , RawOptions > {
245270 const options = upgradeRawOverridableOptions ( rawOptions [ 0 ] ) ;
246- const optionsToUse = getCoreOptions < CoreOptions , Options > (
247- node ,
248- context ,
249- options ,
271+ const optionsToUse = getOptionsWithDefaults (
272+ getCoreOptions < CoreOptions , Options > ( node , context , options ) ,
250273 ) ;
251274
252275 if ( optionsToUse === null ) {
@@ -291,10 +314,11 @@ function checkIdentifier(
291314
292315 const functionNode = getEnclosingFunction ( node ) ;
293316 const options = upgradeRawOverridableOptions ( rawOptions [ 0 ] ) ;
294- const optionsToUse =
317+ const optionsToUse = getOptionsWithDefaults (
295318 functionNode === null
296319 ? options
297- : getCoreOptions < CoreOptions , Options > ( functionNode , context , options ) ;
320+ : getCoreOptions < CoreOptions , Options > ( functionNode , context , options ) ,
321+ ) ;
298322
299323 if ( optionsToUse === null ) {
300324 return {
0 commit comments