Skip to content

Commit 02bac50

Browse files
authored
fix: require fix in suggestion objects (#298)
1 parent 27fdbe7 commit 02bac50

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

packages/core/src/types.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,7 @@ interface ViolationReportBase {
487487
/**
488488
* The data to insert into the message.
489489
*/
490-
data?: Record<string, string> | undefined;
490+
data?: Record<string, unknown> | undefined;
491491

492492
/**
493493
* The fix to be applied for the violation.
@@ -521,12 +521,12 @@ interface SuggestedEditBase {
521521
/**
522522
* The data to insert into the message.
523523
*/
524-
data?: Record<string, string> | undefined;
524+
data?: Record<string, unknown> | undefined;
525525

526526
/**
527527
* The fix to be applied for the suggestion.
528528
*/
529-
fix?: RuleFixer | null | undefined;
529+
fix: RuleFixer;
530530
}
531531

532532
type SuggestionMessage = { desc: string } | { messageId: string };

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,7 @@ const testRule: RuleDefinition<{
298298
start: { line: node.start, column: 1 },
299299
end: { line: node.start + 1, column: Infinity },
300300
},
301+
data: undefined,
301302
fix(fixer: RuleTextEditor): RuleTextEdit {
302303
return fixer.replaceText(
303304
node,
@@ -318,6 +319,12 @@ const testRule: RuleDefinition<{
318319
suggest: [
319320
{
320321
messageId: "Bar",
322+
data: {
323+
foo: "foo",
324+
bar: 1,
325+
baz: true,
326+
},
327+
// @ts-expect-error -- 'fix' is required in suggestion objects
321328
fix: null,
322329
},
323330
],
@@ -328,6 +335,11 @@ const testRule: RuleDefinition<{
328335
context.report({
329336
message: "This baz is foobar",
330337
loc: { line: node.start, column: 1 },
338+
data: {
339+
foo: "foo",
340+
bar: 1,
341+
baz: true,
342+
},
331343
fix: null,
332344
suggest: null,
333345
});

0 commit comments

Comments
 (0)