Skip to content

Commit

Permalink
Refactor to use interface for exposed types
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Jan 20, 2025
1 parent 3a57a5b commit 4af823a
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 13 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
coverage/
node_modules/
yarn.lock
!/index.d.ts
13 changes: 13 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import type {Options as MicromarkOptions} from 'micromark-extension-gfm'
import type {Options as MdastOptions} from 'mdast-util-gfm'

export {default} from './lib/index.js'

/**
* Configuration for `remark-gfm`.
*
* Currently supports `singleTilde` as a parse option and
* `tableCellPadding`, `tablePipeAlign`, and `stringLength` as
* a serialization option.
*/
export interface Options extends MicromarkOptions, MdastOptions {}
5 changes: 1 addition & 4 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
/**
* @typedef {import('./lib/index.js').Options} Options
*/

// Note: types exposed from `index.d.ts`.
export {default} from './lib/index.js'
8 changes: 1 addition & 7 deletions lib/index.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
/**
* @import {Options as MdastOptions} from 'mdast-util-gfm'
* @import {Root} from 'mdast'
* @import {Options as MicromarkOptions} from 'micromark-extension-gfm'
* @import {Options} from 'remark-gfm'
* @import {} from 'remark-parse'
* @import {} from 'remark-stringify'
* @import {Processor} from 'unified'
*/

/**
* @typedef {MicromarkOptions & MdastOptions} Options
* Configuration.
*/

import {gfmFromMarkdown, gfmToMarkdown} from 'mdast-util-gfm'
import {gfm} from 'micromark-extension-gfm'

Expand Down
24 changes: 23 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
},
"exports": "./index.js",
"files": [
"index.d.ts.map",
"index.d.ts",
"index.js",
"lib/"
Expand Down Expand Up @@ -86,6 +85,29 @@
"version": "4.0.0",
"xo": {
"overrides": [
{
"files": [
"**/*.d.ts"
],
"rules": {
"@typescript-eslint/array-type": [
"error",
{
"default": "generic"
}
],
"@typescript-eslint/ban-types": [
"error",
{
"extendDefaults": true
}
],
"@typescript-eslint/consistent-type-definitions": [
"error",
"interface"
]
}
},
{
"files": [
"test/**/*.js"
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@
"target": "es2022"
},
"exclude": ["coverage/", "node_modules/"],
"include": ["**/*.js"]
"include": ["**/*.js", "index.d.ts"]
}

0 comments on commit 4af823a

Please sign in to comment.