Skip to content

Commit fb8cdb8

Browse files
authored
fix: use any[] type for context.options (#19584)
1 parent 071dcd3 commit fb8cdb8

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

lib/types/index.d.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1174,13 +1174,13 @@ export namespace Rule {
11741174
}
11751175

11761176
interface RuleContext
1177-
extends CoreRuleContext<
1178-
RuleContextTypeOptions & {
1179-
LangOptions: Linter.LanguageOptions;
1180-
Code: SourceCode;
1181-
Node: ESTree.Node;
1182-
}
1183-
> {
1177+
extends CoreRuleContext<{
1178+
LangOptions: Linter.LanguageOptions;
1179+
Code: SourceCode;
1180+
RuleOptions: any[];
1181+
Node: ESTree.Node;
1182+
MessageIds: string;
1183+
}> {
11841184
/*
11851185
* Need to extend the `RuleContext` interface to include the
11861186
* deprecated methods that have not yet been removed.

tests/lib/types/types.test.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -613,6 +613,13 @@ rule = {
613613
hasSuggestions: true,
614614
},
615615
};
616+
rule = {
617+
create(context) {
618+
const foo: string = context.options[0];
619+
const baz: number = context.options[1]?.baz ?? false;
620+
return {};
621+
},
622+
};
616623

617624
rule = {
618625
create(context: Rule.RuleContext) {
@@ -636,6 +643,8 @@ rule = {
636643
context.languageOptions
637644
.ecmaVersion satisfies Linter.LanguageOptions["ecmaVersion"];
638645

646+
context.options; // $ExpectType any[]
647+
639648
context.sourceCode;
640649
context.sourceCode.getLocFromIndex(42);
641650

0 commit comments

Comments
 (0)