Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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?:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think rather than the note, we should use a type alias to make sure they are in sync:
type MessagePlaceholderData = Record<string, string | number | boolean | bigint | null | undefined> and then reference them for the root and suggestions.

Copy link
Member Author

@lumirlumir lumirlumir Nov 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes — this approach makes sense to me as well.

I also checked eslint’s types, and it looks like there are two other places this type could be reused:

So maybe define a reusable type like the following, export it, and apply it in eslint once a new version of @eslint/core is released?

export type MessagePlaceholderData = Record<string, string | number | boolean | bigint | null | undefined> | undefined;

Any further thoughts on this @eslint/eslint-team ?


If this approach and the type name look reasonable, I can go ahead and open a PR in eslint for this change.

| 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