Skip to content

Commit

Permalink
Refactor to use @imports
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Jan 3, 2025
1 parent aa0dae3 commit 1077ff3
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* @typedef {import('./lib/index.js').Options} Options
* @typedef {import('./lib/parse-argv.js').Options} Options
*/

export {args} from './lib/index.js'
8 changes: 3 additions & 5 deletions lib/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
/**
* @typedef {import('unified-engine').Callback} EngineCallback
* @typedef {import('unified-engine').Context} EngineContext
*
* @typedef {import('./parse-argv.js').Options} Options
* @typedef {import('./parse-argv.js').State} State
* @import {Options} from 'unified-args'
* @import {Callback as EngineCallback, Context as EngineContext} from 'unified-engine'
* @import {State} from './parse-argv.js'
*/

import process from 'node:process'
Expand Down
6 changes: 2 additions & 4 deletions lib/parse-argv.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
/**
* @typedef {import('unified-engine').Options} EngineOptions
* @typedef {import('unified-engine').Preset} Preset
*
* @typedef {import('./schema.js').Field} Field
* @import {Options as EngineOptions, Preset} from 'unified-engine'
* @import {Field} from './schema.js'
*/

/**
Expand Down
6 changes: 5 additions & 1 deletion test/fixtures/plugins/plugin.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
/** @type {import('unified').Plugin<[unknown?]>} */
/**
* @import {Plugin} from 'unified'
*/

/** @type {Plugin<[unknown?]>} */
export default function plugin(options) {
console.log(JSON.stringify(options))
}
12 changes: 6 additions & 6 deletions test/fixtures/processor.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
/**
* @typedef {import('unist').Literal} Literal
* @typedef {import('unist').Node} Node
* @import {Compiler, Parser, Plugin} from 'unified'
* @import {Literal, Node} from 'unist'
*/

import {unified} from 'unified'

export const processor = unified()
.use(
/** @type {import('unified').Plugin<[], string, Node>} */
/** @type {Plugin<[], string, Node>} */
// @ts-expect-error: TS is wrong about `this`.
function () {
/** @type {import('unified').Parser<Node>} */
/** @type {Parser<Node>} */
this.parser = function (value) {
/** @type {Literal} */
const node = {type: 'text', value}
Expand All @@ -19,10 +19,10 @@ export const processor = unified()
}
)
.use(
/** @type {import('unified').Plugin<[], Node, string>} */
/** @type {Plugin<[], Node, string>} */
// @ts-expect-error: TS is wrong about `this`.
function () {
/** @type {import('unified').Compiler<Node, string>} */
/** @type {Compiler<Node, string>} */
this.compiler = function (tree) {
const node = /** @type {Literal} */ (tree)
return String(node.value)
Expand Down
2 changes: 1 addition & 1 deletion test/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* @typedef {import('execa').ExecaError<string>} ExecaError
* @import {ExecaError} from 'execa'
*/

import assert from 'node:assert/strict'
Expand Down

0 comments on commit 1077ff3

Please sign in to comment.