File tree 2 files changed +53
-3
lines changed
2 files changed +53
-3
lines changed Original file line number Diff line number Diff line change @@ -141,6 +141,7 @@ export interface RulesMetaDocs {
141
141
*/
142
142
export interface RulesMeta <
143
143
MessageIds extends string = string ,
144
+ RuleOptions = unknown [ ] ,
144
145
ExtRuleDocs = unknown ,
145
146
> {
146
147
/**
@@ -158,8 +159,10 @@ export interface RulesMeta<
158
159
*/
159
160
schema ?: JSONSchema4 | JSONSchema4 [ ] | false | undefined ;
160
161
161
- /** Any default options to be recursively merged on top of any user-provided options. */
162
- defaultOptions ?: unknown [ ] ;
162
+ /**
163
+ * Any default options to be recursively merged on top of any user-provided options.
164
+ **/
165
+ defaultOptions ?: RuleOptions ;
163
166
164
167
/**
165
168
* The messages that the rule can report.
@@ -561,7 +564,11 @@ export interface RuleDefinition<
561
564
/**
562
565
* The meta information for the rule.
563
566
*/
564
- meta ?: RulesMeta < Options [ "MessageIds" ] , Options [ "ExtRuleDocs" ] > ;
567
+ meta ?: RulesMeta <
568
+ Options [ "MessageIds" ] ,
569
+ Options [ "RuleOptions" ] ,
570
+ Options [ "ExtRuleDocs" ]
571
+ > ;
565
572
566
573
/**
567
574
* Creates the visitor that ESLint uses to apply the rule during traversal.
Original file line number Diff line number Diff line change @@ -290,3 +290,46 @@ const testRule: RuleDefinition<{
290
290
} ;
291
291
292
292
testRule . meta satisfies RulesMeta | undefined ;
293
+
294
+ const testRuleWithInvalidDefaultOptions : RuleDefinition < {
295
+ LangOptions : TestLanguageOptions ;
296
+ Code : TestSourceCode ;
297
+ RuleOptions : [ { foo : string ; bar : number } ] ;
298
+ Visitor : TestRuleVisitor ;
299
+ Node : TestNode ;
300
+ MessageIds : "badFoo" | "wrongBar" ;
301
+ ExtRuleDocs : never ;
302
+ } > = {
303
+ meta : {
304
+ type : "problem" ,
305
+ schema : [
306
+ {
307
+ type : "object" ,
308
+ properties : {
309
+ foo : {
310
+ type : "string" ,
311
+ } ,
312
+ bar : {
313
+ type : "integer" ,
314
+ } ,
315
+ } ,
316
+ additionalProperties : false ,
317
+ } ,
318
+ ] ,
319
+
320
+ defaultOptions : [
321
+ {
322
+ foo : "always" ,
323
+ bar : 5 ,
324
+ // @ts -expect-error invalid default option "baz"
325
+ baz : "invalid" ,
326
+ } ,
327
+ ] ,
328
+ } ,
329
+
330
+ create ( ) : TestRuleVisitor {
331
+ return { } ;
332
+ } ,
333
+ } ;
334
+
335
+ testRuleWithInvalidDefaultOptions . meta satisfies RulesMeta | undefined ;
You can’t perform that action at this time.
0 commit comments