Skip to content

Commit

Permalink
Add types
Browse files Browse the repository at this point in the history
Closes GH-6.

Reviewed-by: Christian Murphy <christian.murphy.42@gmail.com>
Reviewed-by: Titus Wormer <tituswormer@gmail.com>
  • Loading branch information
pd4d10 committed Aug 22, 2020
1 parent 880e006 commit fdeff60
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 3 deletions.
11 changes: 8 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,18 @@
"contributors": [
"Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)"
],
"types": "types/index.d.ts",
"files": [
"types/index.d.ts",
"index.js"
],
"dependencies": {
"hast-util-sanitize": "^2.0.0"
"hast-util-sanitize": "^3.0.0"
},
"devDependencies": {
"browserify": "^16.0.0",
"deepmerge": "^4.0.0",
"dtslint": "^3.0.0",
"nyc": "^15.0.0",
"prettier": "^2.0.0",
"rehype": "^11.0.0",
Expand All @@ -48,7 +51,8 @@
"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 All @@ -68,7 +72,8 @@
"prettier": true,
"esnext": false,
"rules": {
"unicorn/string-content": "off"
"unicorn/string-content": "off",
"import/no-extraneous-dependencies": "off"
},
"ignores": [
"rehype-sanitize.js"
Expand Down
8 changes: 8 additions & 0 deletions types/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// TypeScript Version: 3.4

import {Plugin} from 'unified'
import {Schema} from 'hast-util-sanitize'

declare const rehypeSanitize: Plugin<[Schema?]>

export = rehypeSanitize
13 changes: 13 additions & 0 deletions types/rehype-sanitize-tests.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import unified = require('unified')
import sanitize = require('rehype-sanitize')

unified().use(sanitize)
unified().use(sanitize, {})
unified().use(sanitize, {
attributes: {
video: ['src']
}
})
unified().use(sanitize, {
tagNames: ['video']
})
10 changes: 10 additions & 0 deletions types/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"compilerOptions": {
"lib": ["es2015"],
"strict": true,
"baseUrl": ".",
"paths": {
"rehype-sanitize": ["index.d.ts"]
}
}
}
7 changes: 7 additions & 0 deletions types/tslint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": "dtslint/dtslint.json",
"rules": {
"semicolon": false,
"whitespace": false
}
}

0 comments on commit fdeff60

Please sign in to comment.