-
-
Notifications
You must be signed in to change notification settings - Fork 8
Add TypeScript definitions #10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
b6283ce
Bump prettier to 2.x
remcohaszing fd1334f
Add TypeScript definitions
remcohaszing 34097cd
Move dtslint to devDependencies
remcohaszing b3c3c2b
Add @types/parse5 and vfile to dependencies
remcohaszing 906d842
Ignore JSON files for prettier and revert formatting
remcohaszing File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,5 @@ | ||
| coverage/ | ||
| hast-util-from-parse5.js | ||
| hast-util-from-parse5.min.js | ||
| *.html | ||
| *.md |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,8 +24,10 @@ | |
| "Titus Wormer <[email protected]> (https://wooorm.com)" | ||
| ], | ||
| "files": [ | ||
| "index.js" | ||
| "index.js", | ||
| "types/index.d.ts" | ||
| ], | ||
| "types": "types/index.d.ts", | ||
| "dependencies": { | ||
| "ccount": "^1.0.3", | ||
| "hastscript": "^5.0.0", | ||
|
|
@@ -34,28 +36,32 @@ | |
| "xtend": "^4.0.1" | ||
| }, | ||
| "devDependencies": { | ||
| "@types/parse5": "^5.0.2", | ||
| "browserify": "^16.0.0", | ||
| "dtslint": "^3.5.2", | ||
| "is-hidden": "^1.0.0", | ||
| "not": "^0.1.0", | ||
| "nyc": "^15.0.0", | ||
| "parse5": "^5.0.0", | ||
| "prettier": "^1.0.0", | ||
| "prettier": "^2.0.5", | ||
| "remark-cli": "^7.0.0", | ||
| "remark-preset-wooorm": "^6.0.0", | ||
| "tape": "^4.0.0", | ||
| "tinyify": "^2.0.0", | ||
| "to-vfile": "^6.0.0", | ||
| "unist-util-visit": "^2.0.0", | ||
| "vfile": "^4.1.0", | ||
| "xo": "^0.27.0" | ||
| }, | ||
| "scripts": { | ||
| "format": "remark . -qfo && prettier --write \"**/*.js\" && xo --fix", | ||
| "format": "remark . -qfo && prettier --write . && xo --fix", | ||
| "build-bundle": "browserify index.js -s hastUtilFromParse5 > hast-util-from-parse5.js", | ||
| "build-mangle": "browserify index.js -p tinyify -s hastUtilFromParse5 > hast-util-from-parse5.min.js", | ||
| "build": "npm run build-bundle && npm run build-mangle", | ||
| "test-api": "node test", | ||
| "test-coverage": "nyc --reporter lcov tape test", | ||
| "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" | ||
| }, | ||
| "prettier": { | ||
| "tabWidth": 2, | ||
|
|
@@ -72,7 +78,8 @@ | |
| "guard-for-in": "off" | ||
| }, | ||
| "ignores": [ | ||
| "hast-util-from-parse5.js" | ||
| "hast-util-from-parse5.js", | ||
| "**/*.ts" | ||
| ] | ||
| }, | ||
| "nyc": { | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| // TypeScript Version: 3.5 | ||
| import {Node} from 'unist' | ||
| import {Document} from 'parse5' | ||
| import {VFile} from 'vfile' | ||
|
|
||
| declare namespace hastUtilFromParse5 { | ||
| interface HastUtilFromParse5Options { | ||
| /** | ||
| * Whether the [*root*](https://github.com/syntax-tree/unist#root) of the | ||
| * [*tree*](https://github.com/syntax-tree/unist#tree) is in the `'html'` or `'svg'` | ||
| * space. | ||
| * | ||
| * If an element in with the SVG namespace is found in `ast`, `fromParse5` | ||
| * automatically switches to the SVG space when entering the element, and switches | ||
| * back when leaving. | ||
| * | ||
| * @default 'html' | ||
| */ | ||
| space?: 'html' | 'svg' | ||
|
|
||
| /** | ||
| * [`VFile`](https://github.com/vfile/vfile), used to add | ||
| * [positional information](https://github.com/syntax-tree/unist#positional-information) | ||
| * to [*nodes*](https://github.com/syntax-tree/hast#nodes). | ||
| * If given, the [*file*](https://github.com/syntax-tree/unist#file) should have the | ||
| * original HTML source as its contents. | ||
| */ | ||
| file?: VFile | ||
| /** | ||
| * | ||
| * Whether to add extra positional information about starting tags, closing tags, | ||
| * and attributes to elements. | ||
| * | ||
| * Note: not used without `file`. | ||
| * | ||
| * @default: false | ||
| */ | ||
| verbose?: boolean | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Transform [Parse5’s AST](https://github.com/inikulin/parse5/blob/master/packages/parse5/docs/tree-adapter/default/interface-list.md) | ||
| * to a [**hast**](https://github.com/syntax-tree/hast) | ||
| * [*tree*](https://github.com/syntax-tree/unist#tree). | ||
| * | ||
| * @param options If `options` is a [`VFile`](https://github.com/vfile/vfile), it’s treated | ||
| * as `{file: options}`. | ||
| */ | ||
| declare function hastUtilFromParse5( | ||
| ast: Document, | ||
| options?: hastUtilFromParse5.HastUtilFromParse5Options | VFile | ||
| ): Node | ||
|
|
||
| export = hastUtilFromParse5 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| import vfile = require('vfile') | ||
| import parse5 = require('parse5') | ||
| import fromParse5 = require('hast-util-from-parse5') | ||
|
|
||
| const file = vfile() | ||
| const ast = parse5.parse('', {sourceCodeLocationInfo: true}) | ||
| fromParse5(ast, file) | ||
| fromParse5(ast, {file}) | ||
| fromParse5(ast, {space: 'html'}) | ||
| fromParse5(ast, {space: 'svg'}) | ||
| fromParse5(ast, {verbose: true}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| { | ||
| "compilerOptions": { | ||
| "lib": ["es2015"], | ||
| "strict": true, | ||
| "baseUrl": ".", | ||
| "paths": { | ||
| "hast-util-from-parse5": ["index.d.ts"] | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| { | ||
| "extends": "dtslint/dtslint.json", | ||
| "rules": { | ||
| "no-redundant-jsdoc": false, | ||
| "semicolon": false, | ||
| "whitespace": false | ||
| } | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.