File tree 7 files changed +70
-9
lines changed
7 files changed +70
-9
lines changed Original file line number Diff line number Diff line change 1
1
coverage /
2
2
mdast-util-definitions.js
3
3
mdast-util-definitions.min.js
4
+ * .md
Original file line number Diff line number Diff line change 30
30
" index.js"
31
31
],
32
32
"dependencies" : {
33
+ "@types/mdast" : " ^3.0.3" ,
33
34
"unist-util-visit" : " ^2.0.0"
34
35
},
35
36
"devDependencies" : {
36
37
"browserify" : " ^16.0.0" ,
38
+ "dtslint" : " ^3.4.2" ,
37
39
"nyc" : " ^15.0.0" ,
38
- "prettier" : " ^1 .0.0 " ,
39
- "remark" : " ^11 .0.0" ,
40
- "remark-cli" : " ^7 .0.0" ,
41
- "remark-preset-wooorm" : " ^6 .0.0" ,
40
+ "prettier" : " ^2 .0.5 " ,
41
+ "remark" : " ^12 .0.0" ,
42
+ "remark-cli" : " ^8 .0.0" ,
43
+ "remark-preset-wooorm" : " ^7 .0.0" ,
42
44
"tape" : " ^4.0.0" ,
43
45
"tinyify" : " ^2.0.0" ,
44
- "xo" : " ^0.26.0 "
46
+ "xo" : " ^0.29.1 "
45
47
},
46
48
"scripts" : {
47
- "format" : " remark . -qfo && prettier --write \" **/*.js \" && xo --fix" ,
49
+ "format" : " remark . -qfo && prettier --write . && xo --fix --ignore types " ,
48
50
"build-bundle" : " browserify . -s mdastUtilDefinitions > mdast-util-definitions.js" ,
49
51
"build-mangle" : " browserify . -s mdastUtilDefinitions -p tinyify > mdast-util-definitions.min.js" ,
50
52
"build" : " npm run build-bundle && npm run build-mangle" ,
51
53
"test-api" : " node test" ,
52
54
"test-coverage" : " nyc --reporter lcov tape test.js" ,
53
- "test" : " npm run format && npm run build && npm run test-coverage"
55
+ "test-types" : " dtslint types" ,
56
+ "test" : " npm run format && npm run build && npm run test-coverage && npm run test-types"
54
57
},
55
58
"nyc" : {
56
59
"check-coverage" : true ,
Original file line number Diff line number Diff line change @@ -4,12 +4,12 @@ var test = require('tape')
4
4
var remark = require ( 'remark' )
5
5
var definitions = require ( '.' )
6
6
7
- test ( 'mdast-util-definitions' , function ( t ) {
7
+ test ( 'mdast-util-definitions' , function ( t ) {
8
8
var getDefinition
9
9
var tree
10
10
11
11
t . throws (
12
- function ( ) {
12
+ function ( ) {
13
13
definitions ( )
14
14
} ,
15
15
/ m d a s t - u t i l - d e f i n i t i o n s e x p e c t e d n o d e / ,
Original file line number Diff line number Diff line change
1
+ // Minimum TypeScript Version: 3.2
2
+ import { Node } from 'unist'
3
+ import { Definition } from 'mdast'
4
+
5
+ declare namespace definitions {
6
+ interface Options {
7
+ /**
8
+ * Turn on (`true`) to use CommonMark precedence: ignore definitions found later for duplicate definitions. The default behavior is to prefer the last found definition.
9
+ *
10
+ * @default false
11
+ */
12
+ commonmark : boolean
13
+ }
14
+
15
+ /**
16
+ * @param identifier [Identifier](https://github.com/syntax-tree/mdast#association) of [definition](https://github.com/syntax-tree/mdast#definition).
17
+ */
18
+ type DefinitionCache = ( identifier : string ) => Definition | null
19
+ }
20
+
21
+ /**
22
+ * Create a cache of all [definition](https://github.com/syntax-tree/mdast#definition)s in [`node`](https://github.com/syntax-tree/unist#node).
23
+ */
24
+ declare function definitions (
25
+ node : Node ,
26
+ options ?: definitions . Options
27
+ ) : definitions . DefinitionCache
28
+
29
+ export = definitions
Original file line number Diff line number Diff line change
1
+ import remark = require( 'remark' )
2
+ import definitions = require( 'mdast-util-definitions' )
3
+
4
+ const ast = remark ( ) . parse ( '[example]: https://example.com "Example"' )
5
+
6
+ const definition = definitions ( ast )
7
+
8
+ definition ( 'example' )
9
+
10
+ definition ( 'foo' )
Original file line number Diff line number Diff line change
1
+ {
2
+ "compilerOptions" : {
3
+ "lib" : [" es2015" ],
4
+ "strict" : true ,
5
+ "baseUrl" : " ." ,
6
+ "paths" : {
7
+ "mdast-util-definitions" : [" index.d.ts" ]
8
+ }
9
+ }
10
+ }
Original file line number Diff line number Diff line change
1
+ {
2
+ "extends" : " dtslint/dtslint.json" ,
3
+ "rules" : {
4
+ "no-redundant-jsdoc" : false ,
5
+ "semicolon" : false ,
6
+ "whitespace" : false
7
+ }
8
+ }
You can’t perform that action at this time.
0 commit comments