File tree 5 files changed +52
-2
lines changed
5 files changed +52
-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
+ /**
2
+ * @typedef {import('mdast').Heading } Heading
3
+ * @typedef {'atx'|'atx-closed'|'setext' } Style
4
+ */
5
+
6
+ /**
7
+ * @param {Heading } node
8
+ * @param {Style } [relative]
9
+ * @returns {Style|null }
10
+ */
1
11
export function headingStyle ( node , relative ) {
2
12
var last = node . children [ node . children . length - 1 ]
3
13
var depth = node . depth
@@ -30,7 +40,13 @@ export function headingStyle(node, relative) {
30
40
return consolidate ( depth , relative )
31
41
}
32
42
33
- // Get the probable style of an atx-heading, depending on preferred style.
43
+ /**
44
+ * Get the probable style of an atx-heading, depending on preferred style.
45
+ *
46
+ * @param {number } depth
47
+ * @param {Style } relative
48
+ * @returns {Style|null }
49
+ */
34
50
function consolidate ( depth , relative ) {
35
51
return depth < 3
36
52
? 'atx'
Original file line number Diff line number Diff line change 27
27
"sideEffects" : false ,
28
28
"type" : " module" ,
29
29
"main" : " index.js" ,
30
+ "types" : " index.d.ts" ,
30
31
"files" : [
32
+ " index.d.ts" ,
31
33
" index.js"
32
34
],
35
+ "dependencies" : {
36
+ "@types/mdast" : " ^3.0.0"
37
+ },
33
38
"devDependencies" : {
39
+ "@types/tape" : " ^4.0.0" ,
34
40
"c8" : " ^7.0.0" ,
35
41
"prettier" : " ^2.0.0" ,
36
42
"remark" : " ^13.0.0" ,
37
43
"remark-cli" : " ^9.0.0" ,
38
44
"remark-preset-wooorm" : " ^8.0.0" ,
45
+ "rimraf" : " ^3.0.0" ,
39
46
"tape" : " ^5.0.0" ,
47
+ "type-coverage" : " ^2.0.0" ,
48
+ "typescript" : " ^4.0.0" ,
40
49
"xo" : " ^0.39.0"
41
50
},
42
51
"scripts" : {
52
+ "prepack" : " npm run build && npm run format" ,
53
+ "build" : " rimraf \" *.d.ts\" && tsc && type-coverage" ,
43
54
"format" : " remark . -qfo && prettier . -w --loglevel warn && xo --fix" ,
44
55
"test-api" : " node test.js" ,
45
56
"test-coverage" : " c8 --check-coverage --branches 100 --functions 100 --lines 100 --statements 100 --reporter lcov node test.js" ,
46
- "test" : " npm run format && npm run test-coverage"
57
+ "test" : " npm run build && npm run format && npm run test-coverage"
47
58
},
48
59
"prettier" : {
49
60
"tabWidth" : 2 ,
64
75
"plugins" : [
65
76
" preset-wooorm"
66
77
]
78
+ },
79
+ "typeCoverage" : {
80
+ "atLeast" : 100 ,
81
+ "detail" : true ,
82
+ "strict" : true
67
83
}
68
84
}
Original file line number Diff line number Diff line change @@ -4,10 +4,12 @@ import {headingStyle} from './index.js'
4
4
5
5
test ( 'headingStyle' , function ( t ) {
6
6
t . throws ( function ( ) {
7
+ // @ts -ignore runtime.
7
8
headingStyle ( )
8
9
} , 'should fail without node' )
9
10
10
11
t . equal (
12
+ // @ts -ignore runtime.
11
13
headingStyle ( {
12
14
type : 'heading' ,
13
15
children : [ { type : 'text' , value : 'foo' } ]
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