Skip to content

Commit

Permalink
Refactor code-style
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Aug 10, 2023
1 parent 6ff4290 commit ad06700
Show file tree
Hide file tree
Showing 19 changed files with 2,979 additions and 1,768 deletions.
15 changes: 7 additions & 8 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@
import type {Node} from 'unist'
import type {VFile, VFileCompatible} from 'vfile'

/* eslint-disable @typescript-eslint/naming-convention */

type VFileWithOutput<Result> = Result extends Uint8Array // Buffer.
type VFileWithOutput<Result> = Result extends Uint8Array
? VFile
: Result extends object // Custom result type
? VFile & {result: Result}
: VFile

// Get the right most non-void thing.
type Specific<Left = void, Right = void> = Right extends void ? Left : Right
type Specific<Left = void, Right = void> = Right extends undefined | void
? Left
: Right

// Create a processor based on the input/output of a plugin.
type UsePlugin<
Expand Down Expand Up @@ -71,8 +71,6 @@ type UsePlugin<
// just keep it as it was.
Processor<ParseTree, CurrentTree, CompileTree, CompileResult>

/* eslint-enable @typescript-eslint/naming-convention */

/**
* Processor allows plugins to be chained together to transform content.
* The chain of plugins defines how content flows through it.
Expand Down Expand Up @@ -203,7 +201,7 @@ export type Processor<
* Current processor.
*/
use(
presetOrList: Preset | PluggableList
presetOrList: PluggableList | Preset
): Processor<ParseTree, CurrentTree, CompileTree, CompileResult>
} & FrozenProcessor<ParseTree, CurrentTree, CompileTree, CompileResult>

Expand Down Expand Up @@ -238,6 +236,7 @@ export type FrozenProcessor<
attachers: Array<[Plugin, ...unknown[]]>

Parser?: Parser<Specific<Node, ParseTree>> | undefined

Compiler?:
| Compiler<Specific<Node, CompileTree>, Specific<unknown, CompileResult>>
| undefined
Expand Down Expand Up @@ -656,7 +655,7 @@ export type Transformer<
node: Input,
file: VFile,
next: TransformCallback<Output>
) => Promise<Output | undefined | void> | Output | Error | undefined | void
) => Promise<Output | undefined | void> | Error | Output | undefined | void

/**
* Callback you must call when a transformer is done.
Expand Down
Loading

0 comments on commit ad06700

Please sign in to comment.