File tree Expand file tree Collapse file tree 5 files changed +46
-1
lines changed Expand file tree Collapse file tree 5 files changed +46
-1
lines changed Original file line number Diff line number Diff line change 1
1
.DS_Store
2
+ * .d.ts
2
3
* .log
3
4
coverage /
4
5
node_modules /
Original file line number Diff line number Diff line change
1
+ /**
2
+ * @typedef {import('unist').Node } UnistNode
3
+ * @typedef {import('hast').Element } HastElement
4
+ * @typedef {import('unist-util-visit').Visitor<HastElement> } VisitElement
5
+ */
6
+
1
7
import { headingRank } from 'hast-util-heading-rank'
2
8
import { visit } from 'unist-util-visit'
3
9
10
+ /**
11
+ * @template {UnistNode} T
12
+ * @param {T } tree
13
+ * @param {number } shift
14
+ * @returns {T }
15
+ */
4
16
export function shiftHeading ( tree , shift ) {
5
17
if (
6
18
typeof shift !== 'number' ||
@@ -15,6 +27,7 @@ export function shiftHeading(tree, shift) {
15
27
16
28
return tree
17
29
30
+ /** @type {VisitElement } */
18
31
function visitor ( node ) {
19
32
var rank = headingRank ( node )
20
33
Original file line number Diff line number Diff line change 30
30
"sideEffects" : false ,
31
31
"type" : " module" ,
32
32
"main" : " index.js" ,
33
+ "types" : " index.d.ts" ,
33
34
"files" : [
35
+ " index.d.ts" ,
34
36
" index.js"
35
37
],
36
38
"dependencies" : {
39
+ "@types/hast" : " ^2.0.0" ,
40
+ "@types/unist" : " ^2.0.0" ,
37
41
"hast-util-heading-rank" : " ^2.0.0" ,
38
42
"unist-util-visit" : " ^3.0.0"
39
43
},
40
44
"devDependencies" : {
45
+ "@types/tape" : " ^4.0.0" ,
41
46
"c8" : " ^7.0.0" ,
42
47
"hastscript" : " ^7.0.0" ,
43
48
"prettier" : " ^2.0.0" ,
44
49
"remark-cli" : " ^9.0.0" ,
45
50
"remark-preset-wooorm" : " ^8.0.0" ,
51
+ "rimraf" : " ^3.0.0" ,
46
52
"tape" : " ^5.0.0" ,
53
+ "type-coverage" : " ^2.0.0" ,
54
+ "typescript" : " ^4.0.0" ,
47
55
"xo" : " ^0.39.0"
48
56
},
49
57
"scripts" : {
58
+ "prepack" : " npm run build && npm run format" ,
59
+ "build" : " rimraf \" *.d.ts\" && tsc && type-coverage" ,
50
60
"format" : " remark . -qfo && prettier . -w --loglevel warn && xo --fix" ,
51
61
"test-api" : " node test.js" ,
52
62
"test-coverage" : " c8 --check-coverage --branches 100 --functions 100 --lines 100 --statements 100 --reporter lcov node test.js" ,
53
- "test" : " npm run format && npm run test-coverage"
63
+ "test" : " npm run build && npm run format && npm run test-coverage"
54
64
},
55
65
"prettier" : {
56
66
"tabWidth" : 2 ,
71
81
"plugins" : [
72
82
" preset-wooorm"
73
83
]
84
+ },
85
+ "typeCoverage" : {
86
+ "atLeast" : 100 ,
87
+ "detail" : true ,
88
+ "strict" : true
74
89
}
75
90
}
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ import {shiftHeading} from './index.js'
5
5
test ( 'shiftHeading' , function ( t ) {
6
6
t . throws (
7
7
function ( ) {
8
+ // @ts -ignore runtime.
8
9
shiftHeading ( h ( '' ) )
9
10
} ,
10
11
/ ^ E r r o r : E x p e c t e d a n o n - n u l l f i n i t e i n t e g e r , n o t ` u n d e f i n e d ` $ / ,
Original file line number Diff line number Diff line change
1
+ {
2
+ "include" : [" *.js" ],
3
+ "compilerOptions" : {
4
+ "target" : " ES2020" ,
5
+ "lib" : [" ES2020" ],
6
+ "module" : " ES2020" ,
7
+ "moduleResolution" : " node" ,
8
+ "allowJs" : true ,
9
+ "checkJs" : true ,
10
+ "declaration" : true ,
11
+ "emitDeclarationOnly" : true ,
12
+ "allowSyntheticDefaultImports" : true ,
13
+ "skipLibCheck" : true
14
+ }
15
+ }
You can’t perform that action at this time.
0 commit comments