diff --git a/package.json b/package.json index 631b169..08c95ef 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,8 @@ "Titus Wormer (https://wooorm.com)" ], "files": [ - "index.js" + "index.js", + "types/index.d.ts" ], "dependencies": { "github-slugger": "^1.1.1", @@ -35,6 +36,7 @@ }, "devDependencies": { "browserify": "^16.0.0", + "dtslint": "^4.0.0", "nyc": "^15.0.0", "prettier": "^2.0.0", "rehype": "^11.0.0", @@ -42,6 +44,7 @@ "remark-preset-wooorm": "^7.0.0", "tape": "^5.0.0", "tinyify": "^2.0.0", + "unified": "^9.0.0", "xo": "^0.32.0" }, "scripts": { @@ -51,13 +54,17 @@ "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, "lines": 100, "functions": 100, - "branches": 100 + "branches": 100, + "ignores": [ + "**/*.ts" + ] }, "prettier": { "tabWidth": 2, diff --git a/types/index.d.ts b/types/index.d.ts new file mode 100644 index 0000000..dd7e876 --- /dev/null +++ b/types/index.d.ts @@ -0,0 +1,9 @@ +// Minimum TypeScript Version: 3.0 +import {Plugin} from 'unified' + +/** + * Add `id`s to headings. + */ +declare const slug: Plugin<[]> + +export = slug diff --git a/types/rehype-slug-tests.ts b/types/rehype-slug-tests.ts new file mode 100644 index 0000000..c019c6b --- /dev/null +++ b/types/rehype-slug-tests.ts @@ -0,0 +1,4 @@ +import unified = require('unified') +import slug = require('rehype-slug') + +unified().use(slug) diff --git a/types/tsconfig.json b/types/tsconfig.json new file mode 100644 index 0000000..cc59418 --- /dev/null +++ b/types/tsconfig.json @@ -0,0 +1,10 @@ +{ + "compilerOptions": { + "lib": ["es2015"], + "strict": true, + "baseUrl": ".", + "paths": { + "rehype-slug": ["index.d.ts"] + } + } +} diff --git a/types/tslint.json b/types/tslint.json new file mode 100644 index 0000000..70c4494 --- /dev/null +++ b/types/tslint.json @@ -0,0 +1,7 @@ +{ + "extends": "dtslint/dtslint.json", + "rules": { + "semicolon": false, + "whitespace": false + } +}