Skip to content

Commit

Permalink
Refactor to move main types to index.d.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Apr 10, 2024
1 parent 388e7f7 commit 20691f8
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 16 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ node_modules/
*.log
.DS_Store
yarn.lock
!/index.d.ts
32 changes: 32 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/* eslint-disable @typescript-eslint/ban-types, @typescript-eslint/consistent-type-definitions */

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

/**
* Configuration.
*/
export interface Options {
/**
* Check relative values relative to this URL
* (optional, example: `'https://example.com/from'`).
*/
from?: string | null | undefined
/**
* Whether to ignore `localhost` links such as `http://localhost/*`,
* `http://127.0.0.1/*`
* (default: `false`).
*/
skipLocalhost?: boolean | null | undefined
/**
* Whether to let offline runs pass quietly
* (default: `false`).
*/
skipOffline?: boolean | null | undefined
/**
* List of patterns for URLs that should be skipped
* (optional);
* each URL will be tested against each pattern and will be ignored if
* `new RegExp(pattern).test(url) === true`.
*/
skipUrlPatterns?: ReadonlyArray<RegExp | string> | null | undefined
}
18 changes: 3 additions & 15 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,13 @@
* @typedef {import('mdast').Nodes} Nodes
* @typedef {import('mdast').Resource} Resource
* @typedef {import('mdast').Root} Root
*
* @typedef {import('remark-lint-no-dead-urls').Options} Options
*
* @typedef {import('vfile').VFile} VFile
*/

/**
* @typedef Options
* Configuration.
* @property {string | null | undefined} [from]
* Check relative values relative to this URL (optiona, example:
* `'https://example.com/from'`).
* @property {boolean | null | undefined} [skipLocalhost=false]
* Whether to ignore `localhost` links such as `http://localhost/*`,
* `http://127.0.0.1/*` (default: `false`).
* @property {boolean | null | undefined} [skipOffline=false]
* Whether to let offline runs pass quietly (default: `false`).
* @property {Array<RegExp | string> | null | undefined} [skipUrlPatterns]
* List of patterns for URLs that should be skipped (optional);
* each URL will be tested against each pattern and will be ignored if
* `new RegExp(pattern).test(url) === true`.
*
* @typedef {Extract<Nodes, Resource>} Resources
* Resource nodes.
*/
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": "es2020"
},
"exclude": ["coverage/", "node_modules/"],
"include": ["**/*.js"]
"include": ["**/*.js", "index.d.ts"]
}

0 comments on commit 20691f8

Please sign in to comment.