File tree Expand file tree Collapse file tree 5 files changed +45
-2
lines changed Expand file tree Collapse file tree 5 files changed +45
-2
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
- // Rank of a heading: H1 -> 1, H2 -> 2, etc.
1
+ /**
2
+ * @typedef {import('hast').Element } HastElement
3
+ */
4
+
5
+ /**
6
+ * Rank of a heading: H1 -> 1, H2 -> 2, etc.
7
+ *
8
+ * @param {HastElement } node
9
+ * @returns {number|null }
10
+ */
2
11
export function headingRank ( node ) {
3
12
var name =
4
13
( node && node . type === 'element' && node . tagName . toLowerCase ( ) ) || ''
Original file line number Diff line number Diff line change 28
28
"sideEffects" : false ,
29
29
"type" : " module" ,
30
30
"main" : " index.js" ,
31
+ "types" : " index.d.ts" ,
31
32
"files" : [
33
+ " index.d.ts" ,
32
34
" index.js"
33
35
],
36
+ "dependencies" : {
37
+ "@types/hast" : " ^2.0.0"
38
+ },
34
39
"devDependencies" : {
40
+ "@types/tape" : " ^4.0.0" ,
35
41
"c8" : " ^7.0.0" ,
36
42
"hastscript" : " ^7.0.0" ,
37
43
"prettier" : " ^2.0.0" ,
38
44
"remark-cli" : " ^9.0.0" ,
39
45
"remark-preset-wooorm" : " ^8.0.0" ,
46
+ "rimraf" : " ^3.0.0" ,
40
47
"tape" : " ^5.0.0" ,
48
+ "type-coverage" : " ^2.0.0" ,
49
+ "typescript" : " ^4.0.0" ,
41
50
"xo" : " ^0.39.0"
42
51
},
43
52
"scripts" : {
53
+ "prepack" : " npm run build && npm run format" ,
54
+ "build" : " rimraf \" *.d.ts\" && tsc && type-coverage" ,
44
55
"format" : " remark . -qfo && prettier . -w --loglevel warn && xo --fix" ,
45
56
"test-api" : " node test.js" ,
46
57
"test-coverage" : " c8 --check-coverage --branches 100 --functions 100 --lines 100 --statements 100 --reporter lcov node test.js" ,
47
- "test" : " npm run format && npm run test-coverage"
58
+ "test" : " npm run build && npm run format && npm run test-coverage"
48
59
},
49
60
"prettier" : {
50
61
"tabWidth" : 2 ,
65
76
"plugins" : [
66
77
" preset-wooorm"
67
78
]
79
+ },
80
+ "typeCoverage" : {
81
+ "atLeast" : 100 ,
82
+ "detail" : true ,
83
+ "strict" : true
68
84
}
69
85
}
Original file line number Diff line number Diff line change @@ -3,9 +3,11 @@ import {h} from 'hastscript'
3
3
import { headingRank } from './index.js'
4
4
5
5
test ( 'headingRank' , function ( t ) {
6
+ // @ts -ignore runtime.
6
7
t . equal ( headingRank ( ) , null , 'should return null for non-nodes' )
7
8
8
9
t . equal (
10
+ // @ts -ignore runtime.
9
11
headingRank ( { type : 'text' , value : '!' } ) ,
10
12
null ,
11
13
'should return null for non-elements'
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