|
16 | 16 | import type {Node} from 'unist'
|
17 | 17 | import type {VFile, VFileCompatible} from 'vfile'
|
18 | 18 |
|
19 |
| -/* eslint-disable @typescript-eslint/naming-convention */ |
20 |
| - |
21 |
| -type VFileWithOutput<Result> = Result extends Uint8Array // Buffer. |
| 19 | +type VFileWithOutput<Result> = Result extends Uint8Array |
22 | 20 | ? VFile
|
23 | 21 | : Result extends object // Custom result type
|
24 | 22 | ? VFile & {result: Result}
|
25 | 23 | : VFile
|
26 | 24 |
|
27 | 25 | // Get the right most non-void thing.
|
28 |
| -type Specific<Left = void, Right = void> = Right extends void ? Left : Right |
| 26 | +type Specific<Left = void, Right = void> = Right extends undefined | void |
| 27 | + ? Left |
| 28 | + : Right |
29 | 29 |
|
30 | 30 | // Create a processor based on the input/output of a plugin.
|
31 | 31 | type UsePlugin<
|
@@ -71,8 +71,6 @@ type UsePlugin<
|
71 | 71 | // just keep it as it was.
|
72 | 72 | Processor<ParseTree, CurrentTree, CompileTree, CompileResult>
|
73 | 73 |
|
74 |
| -/* eslint-enable @typescript-eslint/naming-convention */ |
75 |
| - |
76 | 74 | /**
|
77 | 75 | * Processor allows plugins to be chained together to transform content.
|
78 | 76 | * The chain of plugins defines how content flows through it.
|
@@ -203,7 +201,7 @@ export type Processor<
|
203 | 201 | * Current processor.
|
204 | 202 | */
|
205 | 203 | use(
|
206 |
| - presetOrList: Preset | PluggableList |
| 204 | + presetOrList: PluggableList | Preset |
207 | 205 | ): Processor<ParseTree, CurrentTree, CompileTree, CompileResult>
|
208 | 206 | } & FrozenProcessor<ParseTree, CurrentTree, CompileTree, CompileResult>
|
209 | 207 |
|
@@ -238,6 +236,7 @@ export type FrozenProcessor<
|
238 | 236 | attachers: Array<[Plugin, ...unknown[]]>
|
239 | 237 |
|
240 | 238 | Parser?: Parser<Specific<Node, ParseTree>> | undefined
|
| 239 | + |
241 | 240 | Compiler?:
|
242 | 241 | | Compiler<Specific<Node, CompileTree>, Specific<unknown, CompileResult>>
|
243 | 242 | | undefined
|
@@ -656,7 +655,7 @@ export type Transformer<
|
656 | 655 | node: Input,
|
657 | 656 | file: VFile,
|
658 | 657 | next: TransformCallback<Output>
|
659 |
| -) => Promise<Output | undefined | void> | Output | Error | undefined | void |
| 658 | +) => Promise<Output | undefined | void> | Error | Output | undefined | void |
660 | 659 |
|
661 | 660 | /**
|
662 | 661 | * Callback you must call when a transformer is done.
|
|
0 commit comments