diff --git a/.eslintrc.yaml b/.eslintrc.yaml index fc88f28..06689c1 100644 --- a/.eslintrc.yaml +++ b/.eslintrc.yaml @@ -4,5 +4,3 @@ extends: rules: func-style: off '@typescript-eslint/no-invalid-this': off - import/no-extraneous-dependencies: off - jsdoc/require-jsdoc: off diff --git a/src/unified-prettier.ts b/src/unified-prettier.ts index 31d8714..d5ec37a 100644 --- a/src/unified-prettier.ts +++ b/src/unified-prettier.ts @@ -49,6 +49,9 @@ const unifiedPrettier: Plugin<[Options?]> = function unifiedPrettier(options) { Atomics.wait(signal, 0, 0) const { message } = receiveMessageOnPort(localPort) as { + /** + * The response from the web worker. + */ message: Response } diff --git a/src/worker.ts b/src/worker.ts index 5c465fa..6a12aa9 100644 --- a/src/worker.ts +++ b/src/worker.ts @@ -5,16 +5,47 @@ import { format, getFileInfo, type Options, resolveConfig } from 'prettier' /** * @internal */ -export type Response = { error: unknown } | { result: string } +export type Response = + | { + /** + * The error thas has occurred. + */ + error: unknown + } + | { + /** + * The success result. + */ + result: string + } /** * @internal */ export interface Payload { + /** + * The content to format. + */ content: string + + /** + * The file path to use for looking up the Prettier configuration. + */ filepath: string + + /** + * Prettier options that were passed manually. + */ options: Options | undefined + + /** + * The port to use to communicate from a worker to the main thread. + */ port: MessagePort + + /** + * The signal to use to communicate from a worker to the main thread. + */ signal: Int32Array }