Skip to content

Commit f244dbf

Browse files
authored
fix: use MessagePlaceholderData type from @eslint/core (#20348)
1 parent 8f360ad commit f244dbf

2 files changed

Lines changed: 92 additions & 2 deletions

File tree

lib/types/index.d.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ import type {
7070
SuggestedEditBase,
7171
SuggestedEdit,
7272
ViolationReport,
73+
MessagePlaceholderData,
7374
} from "@eslint/core";
7475

7576
//------------------------------------------------------------------------------
@@ -1458,7 +1459,7 @@ export namespace RuleTester {
14581459
interface SuggestionOutput {
14591460
messageId?: string;
14601461
desc?: string;
1461-
data?: Record<string, unknown> | undefined;
1462+
data?: MessagePlaceholderData | undefined;
14621463
output: string;
14631464
}
14641465

@@ -1470,7 +1471,7 @@ export namespace RuleTester {
14701471
interface TestCaseError {
14711472
message?: string | RegExp;
14721473
messageId?: string;
1473-
data?: any;
1474+
data?: MessagePlaceholderData | undefined;
14741475
line?: number | undefined;
14751476
column?: number | undefined;
14761477
endLine?: number | undefined;

tests/lib/types/types.test.ts

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1844,6 +1844,52 @@ ruleTester.run("my-rule", rule, {
18441844
{ code: "foo", errors: [/foo/] },
18451845
{ code: "foo", errors: [{ message: "foo" }] },
18461846
{ code: "foo", errors: [{ message: "foo", data: { foo: true } }] },
1847+
{ code: "foo", errors: [{ message: "foo", data: undefined }] },
1848+
{
1849+
code: "foo",
1850+
errors: [
1851+
{
1852+
message: "foo",
1853+
// @ts-expect-error -- `data` cannot be `null`
1854+
data: null,
1855+
},
1856+
],
1857+
},
1858+
{
1859+
code: "foo",
1860+
errors: [
1861+
{
1862+
message: "foo",
1863+
data: {
1864+
foo: "foo",
1865+
bar: 1,
1866+
baz: true,
1867+
qux: false,
1868+
a: 1n,
1869+
b: null,
1870+
c: undefined,
1871+
d: void 0,
1872+
// @ts-expect-error -- Symbols are not allowed in `data`.
1873+
e: Symbol("b"),
1874+
// @ts-expect-error -- Objects are not allowed in `data`.
1875+
f: {
1876+
hi: "hi",
1877+
},
1878+
// @ts-expect-error -- Arrays are not allowed in `data`.
1879+
g: [1, 2, 3],
1880+
// @ts-expect-error -- Sets are not allowed in `data`.
1881+
h: new Set([1, 2, 3]),
1882+
// @ts-expect-error -- Maps are not allowed in `data`.
1883+
i: new Map([
1884+
["a", 1],
1885+
["b", 2],
1886+
]),
1887+
// @ts-expect-error -- Functions are not allowed in `data`.
1888+
j: () => {},
1889+
},
1890+
},
1891+
],
1892+
},
18471893
{ code: "foo", errors: [{ message: "foo", line: 0 }] },
18481894
{
18491895
code: "foo",
@@ -1859,6 +1905,49 @@ ruleTester.run("my-rule", rule, {
18591905
messageId: "foo",
18601906
output: "foo",
18611907
},
1908+
{
1909+
messageId: "foo",
1910+
output: "foo",
1911+
data: undefined,
1912+
},
1913+
{
1914+
messageId: "foo",
1915+
output: "foo",
1916+
// @ts-expect-error -- `data` cannot be `null`
1917+
data: null,
1918+
},
1919+
{
1920+
messageId: "foo",
1921+
desc: "foo",
1922+
output: "foo",
1923+
data: {
1924+
foo: "foo",
1925+
bar: 1,
1926+
baz: true,
1927+
qux: false,
1928+
a: 1n,
1929+
b: null,
1930+
c: undefined,
1931+
d: void 0,
1932+
// @ts-expect-error -- Symbols are not allowed in `data`.
1933+
e: Symbol("b"),
1934+
// @ts-expect-error -- Objects are not allowed in `data`.
1935+
f: {
1936+
hi: "hi",
1937+
},
1938+
// @ts-expect-error -- Arrays are not allowed in `data`.
1939+
g: [1, 2, 3],
1940+
// @ts-expect-error -- Sets are not allowed in `data`.
1941+
h: new Set([1, 2, 3]),
1942+
// @ts-expect-error -- Maps are not allowed in `data`.
1943+
i: new Map([
1944+
["a", 1],
1945+
["b", 2],
1946+
]),
1947+
// @ts-expect-error -- Functions are not allowed in `data`.
1948+
j: () => {},
1949+
},
1950+
},
18621951
],
18631952
},
18641953
],

0 commit comments

Comments
 (0)