File tree 6 files changed +94
-9
lines changed
6 files changed +94
-9
lines changed Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ var inspect
9
9
try {
10
10
// eslint-disable-next-line no-useless-concat
11
11
inspect = require ( 'ut' + 'il' ) . inspect
12
- } catch ( error ) { }
12
+ } catch ( _ ) { }
13
13
14
14
exports = wrap ( unist )
15
15
module . exports = exports
@@ -75,7 +75,7 @@ function unist(node) {
75
75
position ( node . position )
76
76
77
77
for ( key in node ) {
78
- if ( defined . indexOf ( key ) === - 1 ) {
78
+ if ( ! defined . includes ( key ) ) {
79
79
vanilla ( key , node [ key ] )
80
80
}
81
81
}
@@ -96,7 +96,7 @@ function unist(node) {
96
96
function vanilla ( key , value ) {
97
97
try {
98
98
assert . deepStrictEqual ( value , JSON . parse ( JSON . stringify ( value ) ) )
99
- } catch ( error ) {
99
+ } catch ( _ ) {
100
100
assert . fail ( 'non-specced property `' + key + '` should be JSON' )
101
101
}
102
102
}
@@ -113,7 +113,7 @@ function view(value) {
113
113
return JSON . stringify ( value )
114
114
}
115
115
/* eslint-enable no-else-return */
116
- } catch ( error ) {
116
+ } catch ( _ ) {
117
117
/* istanbul ignore next - Cyclical. */
118
118
return String ( value )
119
119
}
Original file line number Diff line number Diff line change 20
20
"x-is-object" : " ^0.1.0"
21
21
},
22
22
"files" : [
23
- " index.js"
23
+ " index.js" ,
24
+ " types/index.d.ts"
24
25
],
26
+ "types" : " types/index.d.ts" ,
25
27
"devDependencies" : {
26
28
"browserify" : " ^16.0.0" ,
29
+ "dtslint" : " ^2.0.0" ,
27
30
"nyc" : " ^14.0.0" ,
28
31
"prettier" : " ^1.0.0" ,
29
- "remark-cli" : " ^6 .0.0" ,
30
- "remark-preset-wooorm" : " ^5 .0.0" ,
32
+ "remark-cli" : " ^7 .0.0" ,
33
+ "remark-preset-wooorm" : " ^6 .0.0" ,
31
34
"tape" : " ^4.0.0" ,
32
35
"tinyify" : " ^2.0.0" ,
33
- "xo" : " ^0.24 .0"
36
+ "xo" : " ^0.25 .0"
34
37
},
35
38
"scripts" : {
36
39
"format" : " remark . -qfo && prettier --write \" **/*.js\" && xo --fix" ,
39
42
"build" : " npm run build-bundle && npm run build-mangle" ,
40
43
"test-api" : " node test" ,
41
44
"test-coverage" : " nyc --reporter lcov tape test" ,
42
- "test" : " npm run format && npm run build && npm run test-coverage"
45
+ "test-types" : " dtslint types" ,
46
+ "test" : " npm run format && npm run build && npm run test-coverage && npm run test-types"
43
47
},
44
48
"prettier" : {
45
49
"tabWidth" : 2 ,
Original file line number Diff line number Diff line change
1
+ // TypeScript Version: 3.7
2
+
3
+ import { Node , Parent , Literal } from 'unist'
4
+
5
+ declare namespace unistUtilAssert {
6
+ /**
7
+ * A unist Node that is neither a Parent nor a Literal.
8
+ */
9
+ interface Void extends Node {
10
+ children : never
11
+ value : never
12
+ }
13
+ }
14
+
15
+ declare const unistUtilAssert : {
16
+ /**
17
+ * Assert that tree is a valid unist node.
18
+ * If tree is a parent, all children will be asserted as well.
19
+ */
20
+ ( tree : unknown ) : asserts tree is Node
21
+
22
+ /**
23
+ * Assert that tree is a valid unist parent.
24
+ * All children will be asserted as well.
25
+ */
26
+ parent ( tree : unknown ) : asserts tree is Parent
27
+
28
+ /**
29
+ * Assert that node is a valid unist literal.
30
+ */
31
+ text ( tree : unknown ) : asserts tree is Literal
32
+
33
+ /**
34
+ * Assert that node is a valid unist node, but neither parent nor literal.
35
+ */
36
+ void ( tree : unknown ) : asserts tree is unistUtilAssert . Void
37
+ }
38
+
39
+ export = unistUtilAssert
Original file line number Diff line number Diff line change
1
+ {
2
+ "compilerOptions" : {
3
+ "lib" : [" es2015" ],
4
+ "strict" : true ,
5
+ "baseUrl" : " ." ,
6
+ "paths" : {
7
+ "unist-util-assert" : [" 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
+ "semicolon" : false ,
5
+ "whitespace" : false
6
+ }
7
+ }
Original file line number Diff line number Diff line change
1
+ import * as assert from 'unist-util-assert'
2
+
3
+ function testAssert ( ) {
4
+ const node = { }
5
+ assert ( node )
6
+ node // $ExpectType Node
7
+ }
8
+
9
+ function testParentAssert ( ) {
10
+ const node = { }
11
+ assert . parent ( node )
12
+ node // $ExpectType Parent
13
+ }
14
+
15
+ function testTextAssert ( ) {
16
+ const node = { }
17
+ assert . text ( node )
18
+ node // $ExpectType Literal
19
+ }
20
+
21
+ function testVoidAssert ( ) {
22
+ const node = { }
23
+ assert . void ( node )
24
+ node // $ExpectType Void
25
+ }
You can’t perform that action at this time.
0 commit comments