@@ -127,7 +127,7 @@ const schema: JSONSchema4[] = [
127
127
/**
128
128
* The default options for the rule.
129
129
*/
130
- const defaultOptions : RawOptions = [
130
+ const defaultOptions = [
131
131
{
132
132
allowRestParameter : false ,
133
133
allowArgumentsKeyword : false ,
@@ -138,7 +138,7 @@ const defaultOptions: RawOptions = [
138
138
ignoreGettersAndSetters : true ,
139
139
} ,
140
140
} ,
141
- ] ;
141
+ ] satisfies RawOptions ;
142
142
143
143
/**
144
144
* The possible error messages.
@@ -234,6 +234,31 @@ function getParamCountViolations(
234
234
return [ ] ;
235
235
}
236
236
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
+
237
262
/**
238
263
* Check if the given function node has a reset parameter this rule.
239
264
*/
@@ -243,10 +268,8 @@ function checkFunction(
243
268
rawOptions : Readonly < RawOptions > ,
244
269
) : RuleResult < keyof typeof errorMessages , RawOptions > {
245
270
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 ) ,
250
273
) ;
251
274
252
275
if ( optionsToUse === null ) {
@@ -291,10 +314,11 @@ function checkIdentifier(
291
314
292
315
const functionNode = getEnclosingFunction ( node ) ;
293
316
const options = upgradeRawOverridableOptions ( rawOptions [ 0 ] ) ;
294
- const optionsToUse =
317
+ const optionsToUse = getOptionsWithDefaults (
295
318
functionNode === null
296
319
? options
297
- : getCoreOptions < CoreOptions , Options > ( functionNode , context , options ) ;
320
+ : getCoreOptions < CoreOptions , Options > ( functionNode , context , options ) ,
321
+ ) ;
298
322
299
323
if ( optionsToUse === null ) {
300
324
return {
0 commit comments