Skip to content
8 changes: 6 additions & 2 deletions packages/core/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,9 @@ export interface ViolationReportBase {
/**
* The data to insert into the message.
*/
data?: Record<string, unknown> | undefined;
data?:
| Record<string, string | number | boolean | bigint | null | undefined> // NOTE: If you update this, please also update the `SuggestedEditBase['data']` type.
| undefined;

/**
* The fix to be applied for the violation.
Expand Down Expand Up @@ -485,7 +487,9 @@ export interface SuggestedEditBase {
/**
* The data to insert into the message.
*/
data?: Record<string, unknown> | undefined;
data?:
| Record<string, string | number | boolean | bigint | null | undefined> // NOTE: If you update this, please also update the `ViolationReportBase['data']` type.
| undefined;

/**
* The fix to be applied for the suggestion.
Expand Down
44 changes: 44 additions & 0 deletions packages/core/tests/types/types.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,28 @@ const testRule: RuleDefinition<{
foo: "foo",
bar: 1,
baz: true,
qux: false,
a: 1n,
b: null,
c: undefined,
d: void 0,
// @ts-expect-error -- Symbols are not allowed in `data`.
e: Symbol("b"),
// @ts-expect-error -- Objects are not allowed in `data`.
f: {
hi: "hi",
},
// @ts-expect-error -- Arrays are not allowed in `data`.
g: [1, 2, 3],
// @ts-expect-error -- Sets are not allowed in `data`.
h: new Set([1, 2, 3]),
// @ts-expect-error -- Maps are not allowed in `data`.
i: new Map([
["a", 1],
["b", 2],
]),
// @ts-expect-error -- Functions are not allowed in `data`.
j: () => {},
},
// @ts-expect-error -- 'fix' is required in suggestion objects
fix: null,
Expand All @@ -339,6 +361,28 @@ const testRule: RuleDefinition<{
foo: "foo",
bar: 1,
baz: true,
qux: false,
a: 1n,
b: null,
c: undefined,
d: void 0,
// @ts-expect-error -- Symbols are not allowed in `data`.
e: Symbol("b"),
// @ts-expect-error -- Objects are not allowed in `data`.
f: {
hi: "hi",
},
// @ts-expect-error -- Arrays are not allowed in `data`.
g: [1, 2, 3],
// @ts-expect-error -- Sets are not allowed in `data`.
h: new Set([1, 2, 3]),
// @ts-expect-error -- Maps are not allowed in `data`.
i: new Map([
["a", 1],
["b", 2],
]),
// @ts-expect-error -- Functions are not allowed in `data`.
j: () => {},
},
fix: null,
suggest: null,
Expand Down