Skip to content

Commit 87d88f7

Browse files
authoredJul 23, 2020
Add types
Closes GH-28. Closes GH-32. Reviewed-by: Christian Murphy <christian.murphy.42@gmail.com> Reviewed-by: Jonathan Haines <jonno.haines@gmail.com> Reviewed-by: Junyoung Choi <fluke8259@gmail.com> Reviewed-by: Titus Wormer <tituswormer@gmail.com>
1 parent 3126be4 commit 87d88f7

File tree

5 files changed

+55
-3
lines changed

5 files changed

+55
-3
lines changed
 

‎package.json

+8-3
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,21 @@
2828
"Junyoung Choi <fluke8259@gmail.com>",
2929
"Jonathan Soeder <jonathan.soeder@gmail.com>"
3030
],
31+
"types": "types/index.d.ts",
3132
"files": [
33+
"types/index.d.ts",
3234
"index.js"
3335
],
3436
"dependencies": {
35-
"hast-util-sanitize": "^2.0.0",
37+
"hast-util-sanitize": "^3.0.0",
3638
"hast-util-to-html": "^7.0.0",
37-
"mdast-util-to-hast": "^8.2.0",
39+
"mdast-util-to-hast": "^9.0.0",
3840
"xtend": "^4.0.1"
3941
},
4042
"devDependencies": {
4143
"browserify": "^16.0.0",
4244
"commonmark.json": "^0.29.0",
45+
"dtslint": "^3.0.0",
4346
"is-hidden": "^1.0.0",
4447
"nyc": "^15.0.0",
4548
"prettier": "^2.0.0",
@@ -51,6 +54,7 @@
5154
"tape": "^5.0.0",
5255
"tinyify": "^2.0.0",
5356
"to-vfile": "^6.0.0",
57+
"unified": "^9.0.0",
5458
"xo": "^0.32.0"
5559
},
5660
"scripts": {
@@ -60,7 +64,8 @@
6064
"build": "npm run build-bundle && npm run build-mangle",
6165
"test-api": "node test",
6266
"test-coverage": "nyc --reporter lcov tape test/index.js",
63-
"test": "npm run format && npm run build && npm run test-coverage"
67+
"test-types": "dtslint types",
68+
"test": "npm run format && npm run build && npm run test-coverage && npm run test-types"
6469
},
6570
"nyc": {
6671
"check-coverage": true,

‎types/index.d.ts

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// TypeScript Version: 3.5
2+
3+
import {Plugin} from 'unified'
4+
import {HastUtilToHtmlOptions} from 'hast-util-to-html'
5+
import {Schema} from 'hast-util-sanitize'
6+
import {Handlers} from 'mdast-util-to-hast'
7+
8+
interface htmlOptions extends HastUtilToHtmlOptions {
9+
/**
10+
* How to sanitize the output
11+
*/
12+
sanitize?: boolean | Schema
13+
14+
/**
15+
* Object mapping mdast nodes to functions handling them
16+
*/
17+
handlers?: Handlers
18+
}
19+
20+
declare const html: Plugin<[htmlOptions?]>
21+
export = html

‎types/remark-html-tests.ts

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import unified = require('unified')
2+
import html = require('remark-html')
3+
4+
unified().use(html)
5+
unified().use(html, {preferUnquoted: true})
6+
unified().use(html, {sanitize: false})
7+
unified().use(html, {sanitize: false})
8+
unified().use(html, {sanitize: {allowComments: false}})
9+
unified().use(html, {handlers: {hr: (h, node) => h(node, 'hr')}})

‎types/tsconfig.json

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"compilerOptions": {
3+
"lib": ["es2015"],
4+
"strict": true,
5+
"baseUrl": ".",
6+
"paths": {
7+
"remark-html": ["index.d.ts"]
8+
}
9+
}
10+
}

‎types/tslint.json

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"extends": "dtslint/dtslint.json",
3+
"rules": {
4+
"semicolon": false,
5+
"whitespace": false
6+
}
7+
}

0 commit comments

Comments
 (0)
Please sign in to comment.