From aa6ea0dfb3b6c756bb53f9490e01b46fc327c9e9 Mon Sep 17 00:00:00 2001 From: Rongjian Zhang Date: Tue, 29 Sep 2020 20:43:50 +0800 Subject: [PATCH] Add types Closes GH-17. --- package.json | 8 ++++++-- types/index.d.ts | 7 +++++++ types/rehype-raw-tests.ts | 4 ++++ types/tsconfig.json | 10 ++++++++++ types/tslint.json | 7 +++++++ 5 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 types/index.d.ts create mode 100644 types/rehype-raw-tests.ts create mode 100644 types/tsconfig.json create mode 100644 types/tslint.json diff --git a/package.json b/package.json index d0bf0e8..3e83db4 100644 --- a/package.json +++ b/package.json @@ -21,14 +21,17 @@ "contributors": [ "Titus Wormer (https://wooorm.com)" ], + "types": "types/index.d.ts", "files": [ - "index.js" + "index.js", + "types/index.d.ts" ], "dependencies": { "hast-util-raw": "^5.0.0" }, "devDependencies": { "browserify": "^16.0.0", + "dtslint": "^3.0.0", "nyc": "^15.0.0", "prettier": "^2.0.0", "rehype-stringify": "^8.0.0", @@ -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, diff --git a/types/index.d.ts b/types/index.d.ts new file mode 100644 index 0000000..3f6cb29 --- /dev/null +++ b/types/index.d.ts @@ -0,0 +1,7 @@ +// TypeScript Version: 3.4 + +import {Plugin} from 'unified' + +declare const rehypeRaw: Plugin<[]> + +export = rehypeRaw diff --git a/types/rehype-raw-tests.ts b/types/rehype-raw-tests.ts new file mode 100644 index 0000000..68f473c --- /dev/null +++ b/types/rehype-raw-tests.ts @@ -0,0 +1,4 @@ +import unified = require('unified') +import raw = require('rehype-raw') + +unified().use(raw) diff --git a/types/tsconfig.json b/types/tsconfig.json new file mode 100644 index 0000000..389f23e --- /dev/null +++ b/types/tsconfig.json @@ -0,0 +1,10 @@ +{ + "compilerOptions": { + "lib": ["es2015"], + "strict": true, + "baseUrl": ".", + "paths": { + "rehype-raw": ["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 + } +}