Skip to content

Commit

Permalink
Add types
Browse files Browse the repository at this point in the history
Reviewed-by: Christian Murphy <christian.murphy.42@gmail.com>
Reviewed-by: Titus Wormer <tituswormer@gmail.com>

Closes GH-13.
  • Loading branch information
remcohaszing committed May 19, 2020
1 parent b5e3ef3 commit c5a4eae
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 4 deletions.
1 change: 1 addition & 0 deletions .prettierignore
@@ -1,3 +1,4 @@
coverage/
remark-rehype.js
remark-rehype.min.js
**/*.md
12 changes: 8 additions & 4 deletions package.json
Expand Up @@ -27,13 +27,16 @@
"John Otander <johnotander@gmail.com> (https://johno.com)"
],
"files": [
"index.js"
"index.js",
"types/index.d.ts"
],
"types": "types/index.d.ts",
"dependencies": {
"mdast-util-to-hast": "^8.0.0"
"mdast-util-to-hast": "^9.1.0"
},
"devDependencies": {
"browserify": "^16.0.0",
"dtslint": "^3.4.1",
"nyc": "^15.0.0",
"prettier": "^2.0.0",
"rehype-stringify": "^6.0.0",
Expand All @@ -47,13 +50,14 @@
"xo": "^0.28.0"
},
"scripts": {
"format": "remark . -qfo && prettier --write \"**/*.js\" && xo --fix",
"format": "remark . -qfo && prettier --write . && xo --fix",
"build-bundle": "browserify . -s remarkRehype > remark-rehype.js",
"build-mangle": "browserify . -s remarkRehype -p tinyify > remark-rehype.min.js",
"build": "npm run build-bundle && npm run build-mangle",
"test-api": "node test",
"test-coverage": "nyc --reporter lcov tape test.js",
"test": "npm run format && npm run build && npm run test-coverage"
"test-types": "dtslint types",
"test": "npm run format && npm run build && npm run test-coverage && npm run test-types"
},
"nyc": {
"check-coverage": true,
Expand Down
7 changes: 7 additions & 0 deletions types/index.d.ts
@@ -0,0 +1,7 @@
// Minimum TypeScript Version: 3.2
import {Plugin, Processor} from 'unified'
import {Options} from 'mdast-util-to-hast'

declare const remark2rehype: Plugin<[Options?] | [Processor?, Options?]>

export = remark2rehype
10 changes: 10 additions & 0 deletions types/remark-rehype-tests.ts
@@ -0,0 +1,10 @@
import unified = require('unified')
import remark2rehype = require('remark-rehype')

unified().use(remark2rehype)

unified().use(remark2rehype, {allowDangerousHtml: true})

unified().use(remark2rehype, unified())

unified().use(remark2rehype, unified(), {allowDangerousHtml: true})
10 changes: 10 additions & 0 deletions types/tsconfig.json
@@ -0,0 +1,10 @@
{
"compilerOptions": {
"lib": ["es2015"],
"strict": true,
"baseUrl": ".",
"paths": {
"remark-rehype": ["index.d.ts"]
}
}
}
7 changes: 7 additions & 0 deletions types/tslint.json
@@ -0,0 +1,7 @@
{
"extends": "dtslint/dtslint.json",
"rules": {
"semicolon": false,
"whitespace": false
}
}

0 comments on commit c5a4eae

Please sign in to comment.