Skip to content

Commit 2cf540b

Browse files
committed
feat(kit): add Reporter interface and update make function to return Reporter type
1 parent 621e92f commit 2cf540b

File tree

4 files changed

+76
-40
lines changed

4 files changed

+76
-40
lines changed

packages/utilities/kit/docs/@eslint-react/namespaces/Reporter/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66

77
# Reporter
88

9+
## Interfaces
10+
11+
- [Reporter](interfaces/Reporter.md)
12+
913
## Variables
1014

1115
- [send](variables/send.md)

packages/utilities/kit/docs/@eslint-react/namespaces/Reporter/functions/make.md

Lines changed: 2 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
# Function: make()
88

9-
> **make**(`context`): `object`
9+
> **make**(`context`): [`Reporter`](../interfaces/Reporter.md)
1010
1111
## Parameters
1212

@@ -16,36 +16,4 @@
1616

1717
## Returns
1818

19-
`object`
20-
21-
### send()
22-
23-
> `readonly` **send**: (`descriptor`) => `void`
24-
25-
#### Parameters
26-
27-
##### descriptor
28-
29-
`undefined` | `null` | `ReportDescriptor`\<`string`\>
30-
31-
#### Returns
32-
33-
`void`
34-
35-
### sendOrElse()
36-
37-
> `readonly` **sendOrElse**: (`descriptor`, `cb`) => `unknown`
38-
39-
#### Parameters
40-
41-
##### descriptor
42-
43-
`undefined` | `null` | `ReportDescriptor`\<`string`\>
44-
45-
##### cb
46-
47-
() => `unknown`
48-
49-
#### Returns
50-
51-
`unknown`
19+
[`Reporter`](../interfaces/Reporter.md)
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
[**@eslint-react/kit**](../../../../README.md)
2+
3+
***
4+
5+
[@eslint-react/kit](../../../../README.md) / [Reporter](../README.md) / Reporter
6+
7+
# Interface: Reporter
8+
9+
## Properties
10+
11+
### send()
12+
13+
> **send**: \<`TMessageID`\>(`descriptor`) => `void`
14+
15+
#### Type Parameters
16+
17+
##### TMessageID
18+
19+
`TMessageID` *extends* `string`
20+
21+
#### Parameters
22+
23+
##### descriptor
24+
25+
`undefined` | `null` | `ReportDescriptor`\<`TMessageID`\>
26+
27+
#### Returns
28+
29+
`void`
30+
31+
***
32+
33+
### sendOrElse()
34+
35+
> **sendOrElse**: \<`TMessageID`, `TElse`\>(`descriptor`, `cb`) => `undefined` \| `TElse`
36+
37+
#### Type Parameters
38+
39+
##### TMessageID
40+
41+
`TMessageID` *extends* `string`
42+
43+
##### TElse
44+
45+
`TElse`
46+
47+
#### Parameters
48+
49+
##### descriptor
50+
51+
`undefined` | `null` | `ReportDescriptor`\<`TMessageID`\>
52+
53+
##### cb
54+
55+
() => `TElse`
56+
57+
#### Returns
58+
59+
`undefined` \| `TElse`

packages/utilities/kit/src/Reporter.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@ import type { ReportDescriptor } from "@typescript-eslint/utils/ts-eslint";
22
import type { RuleContext } from "./types";
33
import { type _, dual } from "@eslint-react/eff";
44

5+
export interface Reporter {
6+
send: <TMessageID extends string>(descriptor: _ | null | ReportDescriptor<TMessageID>) => void;
7+
// dprint-ignore
8+
sendOrElse: <TMessageID extends string, TElse>(descriptor: _ | null | ReportDescriptor<TMessageID>, cb: () => TElse) => _ | TElse;
9+
}
10+
511
export const send: {
612
<TMessageID extends string>(context: RuleContext, descriptor: _ | null | ReportDescriptor<TMessageID>): void;
713
<TMessageID extends string>(context: RuleContext): (descriptor: _ | null | ReportDescriptor<TMessageID>) => void;
@@ -20,10 +26,9 @@ export const sendOrElse: {
2026
return context.report(descriptor);
2127
});
2228

23-
export const make = (context: RuleContext) => {
29+
export function make(context: RuleContext): Reporter {
2430
return {
25-
send: (descriptor: _ | null | ReportDescriptor<string>) => send(context, descriptor),
26-
// dprint-ignore
27-
sendOrElse: (descriptor: _ | null | ReportDescriptor<string>, cb: () => unknown) => sendOrElse(context, descriptor, cb),
28-
} as const;
29-
};
31+
send: (...args) => send(context, ...args),
32+
sendOrElse: (...args) => sendOrElse(context, ...args),
33+
};
34+
}

0 commit comments

Comments
 (0)