Skip to content

Commit 9a4fe34

Browse files
fix: relax type for rule.meta.docs.recommended (#235)
1 parent 57734b4 commit 9a4fe34

File tree

3 files changed

+40
-1
lines changed

3 files changed

+40
-1
lines changed

packages/config-helpers/tests/types/types.test.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,23 @@ defineConfig(
7171

7272
globalIgnores(["node_modules"]);
7373
globalIgnores(["dist", "build"], "my name");
74+
75+
defineConfig({
76+
plugins: {
77+
"some-plugin": {
78+
rules: {
79+
"some-rule": {
80+
meta: {
81+
docs: {
82+
recommended: "not a boolean!",
83+
},
84+
},
85+
86+
create() {
87+
return {};
88+
},
89+
},
90+
},
91+
},
92+
},
93+
});

packages/core/src/types.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,10 @@ export interface RulesMetaDocs {
127127

128128
/**
129129
* Indicates if the rule is generally recommended for all users.
130+
*
131+
* Note - this will always be a boolean for core rules, but may be used in any way by plugins.
130132
*/
131-
recommended?: boolean | undefined;
133+
recommended?: unknown;
132134

133135
/**
134136
* Indicates if the rule is frozen (no longer accepting feature requests).

packages/core/tests/types/types.test.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import type {
2323
RuleDefinition,
2424
RulesConfig,
2525
RulesMeta,
26+
RulesMetaDocs,
2627
RuleTextEdit,
2728
RuleTextEditor,
2829
RuleVisitor,
@@ -240,6 +241,9 @@ const testRule: RuleDefinition<{
240241
meta: {
241242
type: "problem",
242243
fixable: "code",
244+
docs: {
245+
recommended: true,
246+
},
243247
deprecated: {
244248
message: "use something else",
245249
url: "https://example.com",
@@ -413,3 +417,16 @@ export type Rule5 = TestRuleDefinition<{ Code: TestSourceCode }>;
413417

414418
// @ts-expect-error -- undefined value not allow for optional property (assumes `exactOptionalPropertyTypes` tsc compiler option)
415419
export type Rule6 = TestRuleDefinition<{ RuleOptions: undefined }>;
420+
421+
export const shouldAllowRecommendedBoolean: RulesMetaDocs = {
422+
recommended: true,
423+
};
424+
export const shouldAllowRecommendedString: RulesMetaDocs = {
425+
recommended: "strict",
426+
};
427+
428+
export const shouldAllowRecommendedObject: RulesMetaDocs = {
429+
recommended: {
430+
someKey: "some value",
431+
},
432+
};

0 commit comments

Comments
 (0)